From: ffmpegagent <ffmpegagent@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Soft Works <softworkz-at-hotmail.com@ffmpeg.org>, softworkz <softworkz@hotmail.com>, Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH v4 0/7] print_graphs: Complete Filtergraph Printing Date: Sat, 01 Mar 2025 22:54:44 +0000 Message-ID: <pull.52.v4.ffstaging.FFmpeg.1740869691.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.52.v3.ffstaging.FFmpeg.1740823324.ffmpegagent@gmail.com> This new version of the patchset starts by extracting the text formatting and writing APIs from ffprobe.c into a subfolder under fftools. The type naming follows public API naming style, ramping up for making it a public API in the future without another big renaming. The extraction of the text formatting APIs can be followed in smaller steps in the recent patchset "[RFC] avtextformat: Transform text writing into an independent API". To make this more review-friendly, the ffprobe changes are done in two steps. The 2nd commit includes all essential changes while the large part of renamings is deferred to the 3rd commit (containing renamings only). The graph-printing uses the extracted APIs. It supports all ffprobe output formats now. Otherwise it's functional equivalent to the previous version: * Different to other graph printing methods, this is outputting: * both, simple and complex filtergraphs * all graphs with runtime state (including auto-inserted filters) * each graph with its inputs and outputs * all filters with their in- and output pads * all connections between all input- and output pads * for each connection: * the runtime-negotiated format and media type * the hw context * if video hw context, both: hw pixfmt + sw pixfmt * Output can either be printed to stdout or written to specified file * Output is machine-readable Right after filtergraph configuration, the connection details are often not complete yet. On the other side, when waiting too long or if an error occurs somewhere, the graph info might never be printed. Experience has shown, that the most suitable and realiable point in time for printing graph information is right before cleanup. Due to the changes for multi-threading, this is no longer doable as easy as before, so the following method is used: Each filtergraph initiates its own graph printing short before cleanup into a buffer. Before final cleanup in ffmpeg.c, the outputs from the individual graphs are pieced together for the actual output to file or console. (the structure according to the output format remains valid) Example output: https://gist.github.com/softworkz/2a9e8699b288f5d40fa381c2a496e165 Update V2 * Change NULL checks to match common code style * Add Add avfilter_link_get_hw_frames_ctx() function to avoid importing filters.h * Do the same without including avfilter/filters.h (as per note from Andreas Reinhardt) Update V3 * Includes extraction and generalization of the text formatting APIs * All output formats supported now Update V4 * Fix "new warnings" were generated * Fix missing colon in commit message * Rebase due to changesin ApiChanges softworkz (7): fftools/textformat: Extract and generalize textformat api from ffprobe.c fftools/ffprobe: Change to use textformat api fftools/ffprobe: Rename writer_print_section_* and WriterContext fftools/ffmpeg_filter: Move some declaration to new header file avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() fftools/ffmpeg_graphprint: Add options for filtergraph printing fftools: Enable filtergraph printing and update docs doc/APIchanges | 3 + doc/ffmpeg.texi | 10 + fftools/Makefile | 23 + fftools/ffmpeg.c | 4 + fftools/ffmpeg.h | 3 + fftools/ffmpeg_filter.c | 193 +-- fftools/ffmpeg_filter.h | 232 +++ fftools/ffmpeg_graphprint.c | 518 +++++++ fftools/ffmpeg_graphprint.h | 35 + fftools/ffmpeg_opt.c | 12 + fftools/ffprobe.c | 2190 ++++------------------------ fftools/textformat/avtextformat.c | 671 +++++++++ fftools/textformat/avtextformat.h | 171 +++ fftools/textformat/avtextwriters.h | 68 + fftools/textformat/tf_compact.c | 282 ++++ fftools/textformat/tf_default.c | 145 ++ fftools/textformat/tf_flat.c | 174 +++ fftools/textformat/tf_ini.c | 160 ++ fftools/textformat/tf_json.c | 215 +++ fftools/textformat/tf_xml.c | 221 +++ fftools/textformat/tw_avio.c | 129 ++ fftools/textformat/tw_buffer.c | 92 ++ fftools/textformat/tw_stdout.c | 82 ++ libavfilter/avfilter.c | 9 + libavfilter/avfilter.h | 12 + libavfilter/version.h | 2 +- 26 files changed, 3576 insertions(+), 2080 deletions(-) create mode 100644 fftools/ffmpeg_filter.h create mode 100644 fftools/ffmpeg_graphprint.c create mode 100644 fftools/ffmpeg_graphprint.h create mode 100644 fftools/textformat/avtextformat.c create mode 100644 fftools/textformat/avtextformat.h create mode 100644 fftools/textformat/avtextwriters.h create mode 100644 fftools/textformat/tf_compact.c create mode 100644 fftools/textformat/tf_default.c create mode 100644 fftools/textformat/tf_flat.c create mode 100644 fftools/textformat/tf_ini.c create mode 100644 fftools/textformat/tf_json.c create mode 100644 fftools/textformat/tf_xml.c create mode 100644 fftools/textformat/tw_avio.c create mode 100644 fftools/textformat/tw_buffer.c create mode 100644 fftools/textformat/tw_stdout.c base-commit: 0245e9382c748eba91645b65a377c4c9c4a44849 Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-52%2Fsoftworkz%2Fsubmit_print_graphs5-v4 Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-52/softworkz/submit_print_graphs5-v4 Pull-Request: https://github.com/ffstaging/FFmpeg/pull/52 Range-diff vs v3: 1: 6239813ba0 = 1: 55bfc6c6a6 fftools/textformat: Extract and generalize textformat api from ffprobe.c 2: 805f66cd92 = 2: 1950903610 fftools/ffprobe: Change to use textformat api 3: 8dcc17112d = 3: 01cc022c3b fftools/ffprobe: Rename writer_print_section_* and WriterContext 4: 06174ae7ef ! 4: aed98ad79d fftools/ffmpeg_filter: Move some declaration to new header file @@ fftools/ffmpeg_filter.h (new) + +} FilterGraphPriv; + -+static FilterGraphPriv *fgp_from_fg(FilterGraph *fg) ++static inline FilterGraphPriv *fgp_from_fg(FilterGraph *fg) +{ + return (FilterGraphPriv*)fg; +} + -+static const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg) ++static inline const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg) +{ + return (const FilterGraphPriv*)fg; +} @@ fftools/ffmpeg_filter.h (new) + } sub2video; +} InputFilterPriv; + -+static InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter) ++static inline InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter) +{ + return (InputFilterPriv*)ifilter; +} @@ fftools/ffmpeg_filter.h (new) + unsigned flags; +} OutputFilterPriv; + -+static OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter) ++static inline OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter) +{ + return (OutputFilterPriv*)ofilter; +} 5: d93c23872f ! 5: 4b8d7ee51b avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() @@ Metadata Author: softworkz <softworkz@hotmail.com> ## Commit message ## - avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() + avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() ## doc/APIchanges ## @@ doc/APIchanges: The last version increases of all libraries were on 2024-03-07 @@ doc/APIchanges: The last version increases of all libraries were on 2024-03-07 +2025-02-xx - xxxxxxxxxx - lavfi 10.10.100 - avfilter.h + Add avfilter_link_get_hw_frames_ctx(). + - 2025-02-xx - xxxxxxxxxx - lavu 59.57.100 - log.h - Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME. + 2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h + Add AV_PIX_FMT_GRAY32BE and AV_PIX_FMT_GRAY32LE. ## libavfilter/avfilter.c ## 6: 9d76b4df1b ! 6: f43eb56f39 fftools/ffmpeg_graphprint: Add options for filtergraph printing @@ fftools/ffmpeg_graphprint.c (new) +#include "libavutil/hwcontext.h" +#include "textformat/avtextformat.h" + ++typedef enum { ++ SECTION_ID_ROOT, ++ SECTION_ID_PROGRAM_VERSION, ++ SECTION_ID_FILTERGRAPHS, ++ SECTION_ID_FILTERGRAPH, ++ SECTION_ID_INPUTS, ++ SECTION_ID_INPUT, ++ SECTION_ID_OUTPUTS, ++ SECTION_ID_OUTPUT, ++ SECTION_ID_FILTERS, ++ SECTION_ID_FILTER, ++ SECTION_ID_HWDEViCECONTEXT, ++ SECTION_ID_HWFRAMESCONTEXT, ++ SECTION_ID_ERROR, ++ SECTION_ID_LOG, ++ SECTION_ID_LOGS, ++} SectionID; ++ ++static struct AVTextFormatSection sections[] = { ++ [SECTION_ID_ROOT] = { SECTION_ID_ROOT, "GraphDescription", AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER, ++ { SECTION_ID_ERROR, SECTION_ID_PROGRAM_VERSION, SECTION_ID_FILTERGRAPHS, SECTION_ID_LOGS, -1} }, ++ [SECTION_ID_PROGRAM_VERSION] = { SECTION_ID_PROGRAM_VERSION, "ProgramVersion", 0, { -1 } }, ++ ++ [SECTION_ID_FILTERGRAPHS] = { SECTION_ID_FILTERGRAPHS, "Graphs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTERGRAPH, -1 } }, ++ [SECTION_ID_FILTERGRAPH] = { SECTION_ID_FILTERGRAPH, "Graph", 0, { SECTION_ID_INPUTS, SECTION_ID_OUTPUTS, SECTION_ID_FILTERS, -1 }, }, ++ ++ [SECTION_ID_INPUTS] = { SECTION_ID_INPUTS, "Inputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_INPUT, SECTION_ID_ERROR, -1 } }, ++ [SECTION_ID_INPUT] = { SECTION_ID_INPUT, "Input", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, ++ ++ [SECTION_ID_OUTPUTS] = { SECTION_ID_OUTPUTS, "Outputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_OUTPUT, SECTION_ID_ERROR, -1 } }, ++ [SECTION_ID_OUTPUT] = { SECTION_ID_OUTPUT, "Output", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, ++ ++ [SECTION_ID_FILTERS] = { SECTION_ID_FILTERS, "Filters", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTER, SECTION_ID_ERROR, -1 } }, ++ [SECTION_ID_FILTER] = { SECTION_ID_FILTER, "Filter", 0, { SECTION_ID_HWDEViCECONTEXT, SECTION_ID_ERROR, -1 }, }, ++ ++ [SECTION_ID_HWDEViCECONTEXT] = { SECTION_ID_HWDEViCECONTEXT, "HwDeviceContext", 0, { SECTION_ID_ERROR, -1 }, }, ++ [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 }, }, ++}; ++ +/* Text Format API Shortcuts */ +#define print_int(k, v) avtext_print_integer(w, k, v) +#define print_q(k, v, s) avtext_print_rational(w, k, v, s) @@ fftools/ffmpeg_graphprint.c (new) + +static void print_link(AVTextFormatContext *w, AVFilterLink *link) +{ ++ AVBufferRef *hw_frames_ctx; + char layoutString[64]; + + switch (link->type) { @@ fftools/ffmpeg_graphprint.c (new) + break; + } + -+ AVBufferRef *hw_frames_ctx = avfilter_link_get_hw_frames_ctx(link); ++ hw_frames_ctx = avfilter_link_get_hw_frames_ctx(link); + + if (hw_frames_ctx && hw_frames_ctx->buffer) { + print_hwframescontext(w, (AVHWFramesContext *)hw_frames_ctx->data); @@ fftools/ffmpeg_graphprint.h (new) +#include "libavutil/bprint.h" +#include "textformat/avtextformat.h" + -+typedef enum { -+ SECTION_ID_ROOT, -+ SECTION_ID_PROGRAM_VERSION, -+ SECTION_ID_FILTERGRAPHS, -+ SECTION_ID_FILTERGRAPH, -+ SECTION_ID_INPUTS, -+ SECTION_ID_INPUT, -+ SECTION_ID_OUTPUTS, -+ SECTION_ID_OUTPUT, -+ SECTION_ID_FILTERS, -+ SECTION_ID_FILTER, -+ SECTION_ID_HWDEViCECONTEXT, -+ SECTION_ID_HWFRAMESCONTEXT, -+ SECTION_ID_ERROR, -+ SECTION_ID_LOG, -+ SECTION_ID_LOGS, -+ -+} SectionID; -+ -+static struct AVTextFormatSection sections[] = { -+ [SECTION_ID_ROOT] = { SECTION_ID_ROOT, "GraphDescription", AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER, -+ { SECTION_ID_ERROR, SECTION_ID_PROGRAM_VERSION, SECTION_ID_FILTERGRAPHS, SECTION_ID_LOGS, -1} }, -+ [SECTION_ID_PROGRAM_VERSION] = { SECTION_ID_PROGRAM_VERSION, "ProgramVersion", 0, { -1 } }, -+ -+ [SECTION_ID_FILTERGRAPHS] = { SECTION_ID_FILTERGRAPHS, "Graphs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTERGRAPH, -1 } }, -+ [SECTION_ID_FILTERGRAPH] = { SECTION_ID_FILTERGRAPH, "Graph", 0, { SECTION_ID_INPUTS, SECTION_ID_OUTPUTS, SECTION_ID_FILTERS, -1 }, }, -+ -+ [SECTION_ID_INPUTS] = { SECTION_ID_INPUTS, "Inputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_INPUT, SECTION_ID_ERROR, -1 } }, -+ [SECTION_ID_INPUT] = { SECTION_ID_INPUT, "Input", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, -+ -+ [SECTION_ID_OUTPUTS] = { SECTION_ID_OUTPUTS, "Outputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_OUTPUT, SECTION_ID_ERROR, -1 } }, -+ [SECTION_ID_OUTPUT] = { SECTION_ID_OUTPUT, "Output", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, -+ -+ [SECTION_ID_FILTERS] = { SECTION_ID_FILTERS, "Filters", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTER, SECTION_ID_ERROR, -1 } }, -+ [SECTION_ID_FILTER] = { SECTION_ID_FILTER, "Filter", 0, { SECTION_ID_HWDEViCECONTEXT, SECTION_ID_ERROR, -1 }, }, -+ -+ [SECTION_ID_HWDEViCECONTEXT] = { SECTION_ID_HWDEViCECONTEXT, "HwDeviceContext", 0, { SECTION_ID_ERROR, -1 }, }, -+ [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 }, }, -+}; -+ +int print_filtergraphs(FilterGraph **graphs, int nb_graphs, OutputFile **output_files, int nb_output_files); +int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph); + 7: 049f720ae7 = 7: c0cf4adcd9 fftools: Enable filtergraph printing and update docs -- ffmpeg-codebot _______________________________________________ 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".
next prev parent reply other threads:[~2025-03-01 22:55 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-02-19 9:59 [FFmpeg-devel] [PATCH 0/3] " 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-01 10:01 ` [FFmpeg-devel] [PATCH v3 2/7] fftools/ffprobe: Change to use textformat api softworkz 2025-03-01 10:02 ` [FFmpeg-devel] [PATCH v3 3/7] fftools/ffprobe: Rename writer_print_section_* and WriterContext softworkz 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 ` ffmpegagent [this message] 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
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=pull.52.v4.ffstaging.FFmpeg.1740869691.ffmpegagent@gmail.com \ --to=ffmpegagent@gmail.com \ --cc=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=softworkz-at-hotmail.com@ffmpeg.org \ --cc=softworkz@hotmail.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