Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Soft Works <softworkz-at-hotmail.com@ffmpeg.org>
To: Stefano Sabatini <stefasab@gmail.com>,
	FFmpeg development discussions and patches
	<ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v6 6/8] fftools/ffmpeg_graphprint: Add options for filtergraph printing
Date: Wed, 12 Mar 2025 04:01:01 +0000
Message-ID: <DM8P223MB0365A68EA1E880C4209AC7FBBAD02@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <Z89vrVVbF7+r1wia@mariano>



> -----Original Message-----
> From: Stefano Sabatini <stefasab@gmail.com>
> Sent: Dienstag, 11. März 2025 00:03
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Cc: softworkz <softworkz@hotmail.com>
> Subject: Re: [FFmpeg-devel] [PATCH v6 6/8] fftools/ffmpeg_graphprint:
> Add options for filtergraph printing


Hi Stefano,

I've made all of your changes unless mentioned below, ran patcheck, found two or three more bits, but a lot of its output is not applicable I suppose.


Here are some notes:


> > +    [SECTION_ID_HWFRAMESCONTEXT] =    { SECTION_ID_HWFRAMESCONTEXT, "HwFramesContext", 0, { SECTION_ID_ERROR, -1 },  },
> > +
> > +    [SECTION_ID_ERROR] =              { SECTION_ID_ERROR, "Error", 0, { -1 } },
> 
> > +    [SECTION_ID_LOGS] =               { SECTION_ID_LOGS, "Log", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_LOG, -1 } },
> > +    [SECTION_ID_LOG] =                { SECTION_ID_LOG, "LogEntry", 0, { -1 },  },
> 
> Why not Logs/Log? It's OK but I'd keep ID and names in synch to
> simplify reading/editing.

The last three ones weren't even used - removed.


> > +static void print_hwdevicecontext(AVTextFormatContext *w, const AVHWDeviceContext *hw_device_context)
> > +{
> > +    avtext_print_section_header(w, NULL, SECTION_ID_HWDEViCECONTEXT);
> > +
> 
> > +    print_int("HasHwDeviceContext", 1);
> > +    print_str("DeviceType", av_hwdevice_get_type_name(hw_device_context->type));
> 
> 
> Is this even needed? If missing I'd expect type to be none. Or not?


av_hwdevice_get_type_name does not return "none" but NULL for the "none" enum id.

The reasoning was slightly different, though: Typically, you deserialize JSON (or XML) into an object model. If the DeviceType is not present in the target object model (missing enum member), the cannot be deserialized which means that it gets lost - including the information that there was a device context in place. The HasHwDeviceContext (and similar members) prevents that by separating presence and type information.

But I have reduced these that now and also dropped the extra section for hw_device_context.


> > +        print_str("SwPixelFormatAlias", pixdescSw->alias);
> > +    }
> > +
> 
> > +    print_int("Width", hw_frames_context->width);
> > +    print_int("Height", hw_frames_context->height);
> 
> is this meaningful in case of no context? Or should we rather skip them?

What do you mean by "no context"?. The function is only entered if a hwframes context exists.
In that case it's interesting to know width and height of the frames context as it may differ from the presentation frame size.



> > +        ////case AVMEDIA_TYPE_SUBTITLE:
> > +        ////    print_str("Format",  av_x_if_null(av_get_subtitle_fmt_name(link->format), "?"));
> > +        ////    print_int("Width", link->w);
> > +        ////    print_int("Height", link->h);
> > +        ////    print_q("TimeBase", link->time_base, '/');
> > +        ////    break;
> 
> I guess this does not exist yet right?

This does exist and is working, just not in ffmpeg yet (https://github.com/ffstaging/FFmpeg/pull/18)
But it's only av_get_subtitle_fmt_name(), so I left just that line commented. (I can also remove it if it should)



> > +    avtext_print_section_header(w, NULL, SECTION_ID_FILTER);
> > +
> > +    print_str("Name", filter->name);
> > +
> > +    if (filter->filter) {
> 
> > +        print_str("Name2", filter->filter->name);
> 
> something more descriptive such as "class name"? 

I've made it more clear now. There's a filter_id and a filter_name, no more name2/3.



> > +        print_str("DestName", link->dst->name);
> > +        print_str("DestPadName", avfilter_pad_get_name(link->dstpad, 0));
> > +        print_str("SourceName", link->src->name);
> 
> possibly unrelated, but I'm a bit surprised by the asymmetry

In case you meant why there's no SourcePadName in this snippet, that's because the source is the filter under which these ouputs are shown. I have changed that now, so there's pad_index, pad_name, dest_filter_id and dest_pad_name for outputs and similar for inputs.

Generally, there's asymmetry in quite a number of cases. What might explain it somewhat is that those graphs have a fixed direction.



> > +    if ((ret = avtext_context_open(&tctx, text_formatter, wctx, w_args, sections, FF_ARRAY_ELEMS(sections), 0, 0, 0, 0, -1, NULL)) >= 0) {
> 
> > +        avtext_print_section_header(tctx, NULL, SECTION_ID_ROOT);
> > +        avtext_print_section_header(tctx, NULL, SECTION_ID_FILTERGRAPHS);
> > +        avtext_print_section_header(tctx, NULL, SECTION_ID_FILTERGRAPH);
> > +
> > +        av_bprint_clear(target_buf);
> 
> If I understand this is printing the sections and then discarding the
> generated buffer, right? Maybe add a not to explain why this is done

Done:

// Due to the threading model each graph needs to print itself into a buffer
// from its own thread. The actual printing happens short before cleanup in ffmpeg.c
// where all grahps are assembled together. To make this work, we need to put the
// formatting context into the same state like it would be when printing all at once,
// so here we print the section headers and clear the buffer to get into the right state.



> > +        if (print_graphs) {
> > +            printf("%s", target_buf.str);
> 
> > +            av_log(NULL, AV_LOG_INFO, "%s    %c", target_buf.str, '\n');
> 
> why it not hardcoding the newline in the message?


I can't remember, not sure which or whether there was a good reason.



> > +    { "print_graphs_format", OPT_TYPE_STRING, 0,
> > +        { &print_graphs_format },
> 
> > +      "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)", "format" },
> 
> non blocking but it would be good to avoid the hardcode in a case a
> new format is added (or we'll skip update)


There's again the problem of static initialization order. While I'm sure that this could be worked out in some tricky way, I wonder whether that's worth the effort. When was the last time that a new text format has been added? And when some new format gets added, it will need to be "hard-coded" in the doc files and at various other places anyway.



> About the output style, this is using FooBar style against foo_bar
> employed by ffprobe itself. I'm not against this, but I wonder if this
> was considered and if using a more consistent style across tools is
> helpful.

Back then, I hadn't thought much about it. I just did what I thought is natural for JSON and XML documents. 
Even though it will cause me some headaches, your point is undeniably valid, so I've reworked everything to snake case and also adjusted the naming of some elements for better clarity.


Thanks again for your reviews,
best wishes,
sw

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2025-03-12  4:01 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19  9:59 [FFmpeg-devel] [PATCH 0/3] print_graphs: Complete Filtergraph Printing ffmpegagent
2025-02-19  9:59 ` [FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg_filter: Move some declaration to new header file softworkz
2025-02-19  9:59 ` [FFmpeg-devel] [PATCH 2/3] fftools/ffmpeg_graphprint: Add options for filtergraph printing softworkz
2025-02-21  9:22   ` Andreas Rheinhardt
2025-02-21  9:42     ` Soft Works
2025-02-21 11:11       ` Andreas Rheinhardt
2025-02-21 11:25         ` Soft Works
2025-02-21 13:09   ` Nicolas George
2025-02-21 13:49     ` Soft Works
2025-02-24 10:41       ` Nicolas George
2025-02-24 13:19         ` Soft Works
2025-02-26 14:42           ` Nicolas George
2025-02-27 13:11             ` Soft Works
2025-02-19  9:59 ` [FFmpeg-devel] [PATCH 3/3] fftools: Enable filtergraph printing and update docs softworkz
2025-02-21 11:27 ` [FFmpeg-devel] [PATCH v2 0/4] print_graphs: Complete Filtergraph Printing ffmpegagent
2025-02-21 11:27   ` [FFmpeg-devel] [PATCH v2 1/4] fftools/ffmpeg_filter: Move some declaration to new header file softworkz
2025-02-21 11:27   ` [FFmpeg-devel] [PATCH v2 2/4] avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() softworkz
2025-02-21 11:27   ` [FFmpeg-devel] [PATCH v2 3/4] fftools/ffmpeg_graphprint: Add options for filtergraph printing softworkz
2025-02-21 11:27   ` [FFmpeg-devel] [PATCH v2 4/4] fftools: Enable filtergraph printing and update docs softworkz
2025-03-01 10:01   ` [FFmpeg-devel] [PATCH v3 0/7] print_graphs: Complete Filtergraph Printing ffmpegagent
2025-03-01 10:01     ` [FFmpeg-devel] [PATCH v3 1/7] fftools/textformat: Extract and generalize textformat api from ffprobe.c softworkz
2025-03-02 17:54       ` Stefano Sabatini
2025-03-02 19:44         ` Soft Works
2025-03-05 20:20           ` Stefano Sabatini
2025-03-05 20:58             ` Soft Works
2025-03-08 14:00       ` Stefano Sabatini
2025-03-08 15:01         ` Soft Works
2025-03-08 14:36       ` Stefano Sabatini
2025-03-08 15:30         ` Soft Works
2025-03-08 18:12           ` Stefano Sabatini
2025-03-08 19:25             ` Soft Works
2025-03-09 18:55         ` Soft Works
2025-03-01 10:01     ` [FFmpeg-devel] [PATCH v3 2/7] fftools/ffprobe: Change to use textformat api softworkz
2025-03-08 14:18       ` Stefano Sabatini
2025-03-01 10:02     ` [FFmpeg-devel] [PATCH v3 3/7] fftools/ffprobe: Rename writer_print_section_* and WriterContext softworkz
2025-03-08 14:46       ` Stefano Sabatini
2025-03-08 15:46         ` Soft Works
2025-03-08 17:54         ` Soft Works
2025-03-01 10:02     ` [FFmpeg-devel] [PATCH v3 4/7] fftools/ffmpeg_filter: Move some declaration to new header file softworkz
2025-03-01 10:02     ` [FFmpeg-devel] [PATCH v3 5/7] avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() softworkz
2025-03-01 10:02     ` [FFmpeg-devel] [PATCH v3 6/7] fftools/ffmpeg_graphprint: Add options for filtergraph printing softworkz
2025-03-01 10:02     ` [FFmpeg-devel] [PATCH v3 7/7] fftools: Enable filtergraph printing and update docs softworkz
2025-03-01 22:54     ` [FFmpeg-devel] [PATCH v4 0/7] print_graphs: Complete Filtergraph Printing ffmpegagent
2025-03-01 22:54       ` [FFmpeg-devel] [PATCH v4 1/7] fftools/textformat: Extract and generalize textformat api from ffprobe.c softworkz
2025-03-01 22:54       ` [FFmpeg-devel] [PATCH v4 2/7] fftools/ffprobe: Change to use textformat api softworkz
2025-03-01 22:54       ` [FFmpeg-devel] [PATCH v4 3/7] fftools/ffprobe: Rename writer_print_section_* and WriterContext softworkz
2025-03-01 22:54       ` [FFmpeg-devel] [PATCH v4 4/7] fftools/ffmpeg_filter: Move some declaration to new header file softworkz
2025-03-01 22:54       ` [FFmpeg-devel] [PATCH v4 5/7] avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() softworkz
2025-03-01 22:54       ` [FFmpeg-devel] [PATCH v4 6/7] fftools/ffmpeg_graphprint: Add options for filtergraph printing softworkz
2025-03-01 22:54       ` [FFmpeg-devel] [PATCH v4 7/7] fftools: Enable filtergraph printing and update docs softworkz
2025-03-08 17:55       ` [FFmpeg-devel] [PATCH v5 0/8] print_graphs: Complete Filtergraph Printing ffmpegagent
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 1/8] fftools/textformat: Extract and generalize textformat api from ffprobe.c softworkz
2025-03-08 19:08           ` Stefano Sabatini
2025-03-08 19:49             ` Soft Works
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 2/8] fftools/ffprobe: Change to use textformat api softworkz
2025-03-08 19:23           ` Stefano Sabatini
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 3/8] fftools/ffprobe: Rename writer_print_section_* and WriterContext softworkz
2025-03-08 19:24           ` Stefano Sabatini
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 4/8] fftools/ffmpeg_filter: Move some declaration to new header file softworkz
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 5/8] avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() softworkz
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 6/8] fftools/ffmpeg_graphprint: Add options for filtergraph printing softworkz
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 7/8] fftools: Enable filtergraph printing and update docs softworkz
2025-03-08 17:55         ` [FFmpeg-devel] [PATCH v5 8/8] fftools/ffprobe: Rename AVTextFormatContext variables (w => tc) softworkz
2025-03-08 19:30           ` Stefano Sabatini
2025-03-08 20:16         ` [FFmpeg-devel] [PATCH v6 0/8] print_graphs: Complete Filtergraph Printing ffmpegagent
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 1/8] fftools/textformat: Extract and generalize textformat api from ffprobe.c softworkz
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 2/8] fftools/ffprobe: Change to use textformat api softworkz
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 3/8] fftools/ffprobe: Rename writer_print_section_* and WriterContext softworkz
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 4/8] fftools/ffmpeg_filter: Move some declaration to new header file softworkz
2025-03-10 21:47             ` Stefano Sabatini
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 5/8] avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() softworkz
2025-03-10 22:11             ` Stefano Sabatini
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 6/8] fftools/ffmpeg_graphprint: Add options for filtergraph printing softworkz
2025-03-10 23:03             ` Stefano Sabatini
2025-03-12  4:01               ` Soft Works [this message]
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 7/8] fftools: Enable filtergraph printing and update docs softworkz
2025-03-10 23:04             ` Stefano Sabatini
2025-03-10 23:23               ` Soft Works
2025-03-08 20:16           ` [FFmpeg-devel] [PATCH v6 8/8] fftools/ffprobe: Rename AVTextFormatContext variables (w => tfc) softworkz
2025-03-10 21:46           ` [FFmpeg-devel] [PATCH v6 0/8] print_graphs: Complete Filtergraph Printing Stefano Sabatini
2025-03-12  4:04           ` [FFmpeg-devel] [PATCH v7 0/7] " ffmpegagent
2025-03-12  4:04             ` [FFmpeg-devel] [PATCH v7 1/7] fftools/textformat: Extract and generalize textformat api from ffprobe.c softworkz
2025-03-12  4:04             ` [FFmpeg-devel] [PATCH v7 2/7] fftools/ffprobe: Change to use textformat api softworkz
2025-03-12  4:04             ` [FFmpeg-devel] [PATCH v7 3/7] fftools/ffprobe: Rename writer_print_section_* and WriterContext softworkz
2025-03-12  4:04             ` [FFmpeg-devel] [PATCH v7 4/7] fftools/ffmpeg_filter: Move some declaration to new header file softworkz
2025-03-12  4:04             ` [FFmpeg-devel] [PATCH v7 5/7] avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() softworkz
2025-03-12  4:04             ` [FFmpeg-devel] [PATCH v7 6/7] fftools/ffmpeg_graphprint: Add options for filtergraph printing softworkz
2025-03-12  4:04             ` [FFmpeg-devel] [PATCH v7 7/7] fftools/ffprobe: Rename AVTextFormatContext variables (w => tfc) softworkz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8P223MB0365A68EA1E880C4209AC7FBBAD02@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \
    --to=softworkz-at-hotmail.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=stefasab@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git