[FFmpeg-devel] [PATCH 2/5] fftools: add -lavfi_dump option
Nicolas George
george at nsup.org
Wed Mar 2 20:40:20 EET 2022
Signed-off-by: Nicolas George <george at nsup.org>
---
doc/ffmpeg.texi | 4 ++++
fftools/ffmpeg.h | 1 +
fftools/ffmpeg_filter.c | 14 ++++++++++++++
fftools/ffmpeg_opt.c | 3 +++
4 files changed, 22 insertions(+)
Unchanged since last summer.
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 164419cad3..1f6c416390 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1864,6 +1864,10 @@ The default is the number of available CPUs.
Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
outputs. Equivalent to @option{-filter_complex}.
+ at anchor{lavfi_dump option}
+ at item -lavfi_dump (@emph{global})
+Dump the filter graphs and their negotiated formats to standard output.
+
@item -filter_complex_script @var{filename} (@emph{global})
This option is similar to @option{-filter_complex}, the only difference is that
its argument is the name of the file from which a complex filtergraph
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index cc8f767e5d..4b81cc19fa 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -635,6 +635,7 @@ extern char *filter_nbthreads;
extern int filter_complex_nbthreads;
extern int vstats_version;
extern int auto_conversion_filters;
+extern int dump_filtergraphs;
extern const AVIOInterruptCB int_cb;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b80d7189db..33ed91bf63 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1070,6 +1070,20 @@ int configure_filtergraph(FilterGraph *fg)
avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
goto fail;
+ if (dump_filtergraphs) {
+ char *dump = avfilter_graph_dump(fg->graph, "f=tech");
+ if (!dump)
+ return AVERROR(ENOMEM);
+ if (simple) {
+ OutputStream *ost = fg->outputs[0]->ost;
+ printf("Dump of filter graph for output #%d:%d:", ost->file_index, ost->index);
+ } else {
+ printf("Dump of complex filter graph #%d:", fg->index);
+ }
+ printf("\n\n%s\n", dump);
+ av_free(dump);
+ fflush(stdout);
+ }
fg->is_meta = graph_is_meta(fg->graph);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index bf1bbcae4c..9b09917bb3 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -167,6 +167,7 @@ char *filter_nbthreads;
int filter_complex_nbthreads = 0;
int vstats_version = 2;
int auto_conversion_filters = 1;
+int dump_filtergraphs = 0;
int64_t stats_period = 500000;
@@ -3670,6 +3671,8 @@ const OptionDef options[] = {
"number of threads for -filter_complex" },
{ "lavfi", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
"create a complex filtergraph", "graph_description" },
+ { "lavfi_dump", OPT_BOOL | OPT_EXPERT, { &dump_filtergraphs },
+ "dump filter graphs to standard output" },
{ "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script },
"read complex filtergraph description from a file", "filename" },
{ "auto_conversion_filters", OPT_BOOL | OPT_EXPERT, { &auto_conversion_filters },
--
2.34.1
More information about the ffmpeg-devel
mailing list