[FFmpeg-devel] [PATCH v6 0/8] print_graphs: Complete Filtergraph Printing
ffmpegagent
ffmpegagent at gmail.com
Sat Mar 8 22:16:26 EET 2025
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
Update V5
* Fix copyright headers
* Return proper error codes rather than -1
* Fix misnamed local functions
* Fix typo
* Rename 'w' in ffprobe.c to 'tfc'
Update V6
* Fix commit message (8)
* Revert renaming of context in main()
softworkz (8):
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
fftools/ffprobe: Rename AVTextFormatContext variables (w => tfc)
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 | 2296 +++++-----------------------
fftools/textformat/avtextformat.c | 672 ++++++++
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, 3630 insertions(+), 2133 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-v6
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-52/softworkz/submit_print_graphs5-v6
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/52
Range-diff vs v5:
1: b26a45ea0e = 1: b26a45ea0e fftools/textformat: Extract and generalize textformat api from ffprobe.c
2: 2eb2b4ded5 = 2: 2eb2b4ded5 fftools/ffprobe: Change to use textformat api
3: 5ab9ac2a28 = 3: 5ab9ac2a28 fftools/ffprobe: Rename writer_print_section_* and WriterContext
4: 85735035e4 = 4: 85735035e4 fftools/ffmpeg_filter: Move some declaration to new header file
5: 811c5ab35c = 5: 811c5ab35c avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx()
6: 8ae08a7006 = 6: 8ae08a7006 fftools/ffmpeg_graphprint: Add options for filtergraph printing
7: 03663768dd = 7: 03663768dd fftools: Enable filtergraph printing and update docs
8: 61dc171fa1 ! 8: 0caab91adc fftools/ffprobe: Rename AVTextFormatContext variables (w => tc)
@@ Metadata
Author: softworkz <softworkz at hotmail.com>
## Commit message ##
- fftools/ffprobe: Rename AVTextFormatContext variables (w => tc)
+ fftools/ffprobe: Rename AVTextFormatContext variables (w => tfc)
Signed-off-by: softworkz <softworkz at hotmail.com>
@@ fftools/ffprobe.c: static void ffprobe_show_pixel_formats(AVTextFormatContext *w
}
static int opt_show_optional_fields(void *optctx, const char *opt, const char *arg)
-@@ fftools/ffprobe.c: static inline int check_section_show_entries(int section_id)
- int main(int argc, char **argv)
- {
- const AVTextFormatter *f;
-- AVTextFormatContext *tctx;
-+ AVTextFormatContext *tfc;
- AVTextWriterContext *wctx;
- char *buf;
- char *f_name = NULL, *f_args = NULL;
-@@ fftools/ffprobe.c: int main(int argc, char **argv)
- if (ret < 0)
- goto end;
-
-- if ((ret = avtext_context_open(&tctx, f, wctx, f_args,
-+ if ((ret = avtext_context_open(&tfc, f, wctx, f_args,
- sections, FF_ARRAY_ELEMS(sections), show_value_unit,
- use_value_prefix, use_byte_value_binary_prefix, use_value_sexagesimal_format,
- show_optional_fields, show_data_hash)) >= 0) {
- if (f == &avtextformatter_xml)
-- tctx->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES;
-+ tfc->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES;
-
-- avtext_print_section_header(tctx, NULL, SECTION_ID_ROOT);
-+ avtext_print_section_header(tfc, NULL, SECTION_ID_ROOT);
-
- if (do_show_program_version)
-- ffprobe_show_program_version(tctx);
-+ ffprobe_show_program_version(tfc);
- if (do_show_library_versions)
-- ffprobe_show_library_versions(tctx);
-+ ffprobe_show_library_versions(tfc);
- if (do_show_pixel_formats)
-- ffprobe_show_pixel_formats(tctx);
-+ ffprobe_show_pixel_formats(tfc);
-
- if (!input_filename &&
- ((do_show_format || do_show_programs || do_show_stream_groups || do_show_streams || do_show_chapters || do_show_packets || do_show_error) ||
-@@ fftools/ffprobe.c: int main(int argc, char **argv)
- av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
- ret = AVERROR(EINVAL);
- } else if (input_filename) {
-- ret = probe_file(tctx, input_filename, print_input_filename);
-+ ret = probe_file(tfc, input_filename, print_input_filename);
- if (ret < 0 && do_show_error)
-- show_error(tctx, ret);
-+ show_error(tfc, ret);
- }
-
- input_ret = ret;
-
-- avtext_print_section_footer(tctx);
-+ avtext_print_section_footer(tfc);
-
- ret = avtextwriter_context_close(&wctx);
- if (ret < 0)
- av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing writer): %s\n", av_err2str(ret));
-
-- ret = avtext_context_close(&tctx);
-+ ret = avtext_context_close(&tfc);
- if (ret < 0)
- av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing formatter): %s\n", av_err2str(ret));
-
--
ffmpeg-codebot
More information about the ffmpeg-devel
mailing list