Message ID | 20210823094504.100789-2-george@nsup.org |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,1/2] lavfi/graphdump: add plain listing output | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Nicolas > George > Sent: Monday, 23 August 2021 11:45 > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH 2/2] fftools: add -lavfi_dump option > > Signed-off-by: Nicolas George <george@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(+) > > > This will be useful for tests covering suble cases of the format > negotiation. I do not like to depend on libavdevice's lavfi, it is > clumsy. Hi Nicolas, being able to output the actually negotiated formats between all filter connections is extremely useful and has helped me quite a number of times to solve issues in filtering. I had implemented something very similar few years ago already and last year, I had offered to post it: http://ffmpeg.org/pipermail/ffmpeg-devel/2020-May/263187.html ..but there wasn't too much interest, so I didn't submit the code. I'm outputting some more details, output can be formatted as JSON and optionally saved as separate file (instead of stdout). Would you mind me posting my code for comparison and discussion? PS: I've been short on time but I'll reply on the subtitle filtering subject shortly. Kind regards, softworkz
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index c896aede3b..e7341dda1d 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1834,6 +1834,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}. +@anchor{lavfi_dump option} +@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 d2dd7ca092..42bf06e224 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -637,6 +637,7 @@ extern int 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 49076f13ee..a35c93f587 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1056,6 +1056,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); + } /* limit the lists of allowed formats to the ones selected, to * make sure they stay the same if the filtergraph is reconfigured later */ diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 428934a3d8..7855ea8a32 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -173,6 +173,7 @@ int filter_nbthreads = 0; int filter_complex_nbthreads = 0; int vstats_version = 2; int auto_conversion_filters = 1; +int dump_filtergraphs = 0; int64_t stats_period = 500000; @@ -3632,6 +3633,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 },
Signed-off-by: Nicolas George <george@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(+) This will be useful for tests covering suble cases of the format negotiation. I do not like to depend on libavdevice's lavfi, it is clumsy.