[FFmpeg-devel] [PATCH 3/7] fftools: add -lavfi_dump option
Nicolas George
george at nsup.org
Tue Aug 2 19:54:17 EEST 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(+)
Identical to the one posted months ago.
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 2fb0bc8ffa..1a342846c2 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1902,6 +1902,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 6417db03bd..d2ec8ea257 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -654,6 +654,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 f9ae76f76d..973de34b5f 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 a96bcf9b8a..6404412f5a 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -178,6 +178,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;
@@ -3947,6 +3948,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.35.1
More information about the ffmpeg-devel
mailing list