Message ID | 20191126014130.15052-1-lance.lmwang@gmail.com |
---|---|
State | New |
Headers | show |
ping, please help to review it and push it. It's useful to check the auto insert filters for debug. On Tue, Nov 26, 2019 at 09:41:30AM +0800, lance.lmwang@gmail.com wrote: > From: Limin Wang <lance.lmwang@gmail.com> > > It's useful for debugging filter graph purposes, now only lavfi can do that. > > Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > --- > doc/ffmpeg.texi | 4 ++++ > fftools/ffmpeg.h | 1 + > fftools/ffmpeg_filter.c | 7 +++++++ > fftools/ffmpeg_opt.c | 3 +++ > 4 files changed, 15 insertions(+) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 9cccc2337d..f822a1025e 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -735,6 +735,10 @@ Technical note -- attachments are implemented as codec extradata, so this > option can actually be used to extract extradata from any stream, not just > attachments. > > +@item -dump_filtergraph (@emph{global}) > +Dump filter graph to stderr. It is off by default, the option is mostly useful > +for debugging filter graph purposes > + > @item -noautorotate > Disable automatically rotating video based on file metadata. > > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h > index 7b6f802082..5b8319da07 100644 > --- a/fftools/ffmpeg.h > +++ b/fftools/ffmpeg.h > @@ -607,6 +607,7 @@ extern AVIOContext *progress_avio; > extern float max_error_rate; > extern char *videotoolbox_pixfmt; > > +extern int dump_filtergraph; > extern int filter_nbthreads; > extern int filter_complex_nbthreads; > extern int vstats_version; > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c > index 72838de1e2..edc15cff61 100644 > --- a/fftools/ffmpeg_filter.c > +++ b/fftools/ffmpeg_filter.c > @@ -1109,6 +1109,13 @@ int configure_filtergraph(FilterGraph *fg) > if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0) > goto fail; > > + if (dump_filtergraph) { > + char *dump = avfilter_graph_dump(fg->graph, NULL); > + fputs(dump, stderr); > + fflush(stderr); > + av_free(dump); > + } > + > /* limit the lists of allowed formats to the ones selected, to > * make sure they stay the same if the filtergraph is reconfigured later */ > for (i = 0; i < fg->nb_outputs; i++) { > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index 71063cc443..7616209a43 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -101,6 +101,7 @@ int copy_ts = 0; > int start_at_zero = 0; > int copy_tb = -1; > int debug_ts = 0; > +int dump_filtergraph = 0; > int exit_on_error = 0; > int abort_on_flags = 0; > int print_stats = -1; > @@ -3535,6 +3536,8 @@ const OptionDef options[] = { > { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC | > OPT_EXPERT | OPT_INPUT, { .off = OFFSET(dump_attachment) }, > "extract an attachment into a file", "filename" }, > + { "dump_filtergraph", OPT_BOOL, { &dump_filtergraph }, > + "dump filter graph to stderr" }, > { "stream_loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT | > OPT_OFFSET, { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" }, > { "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts }, > -- > 2.21.0 >
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 9cccc2337d..f822a1025e 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -735,6 +735,10 @@ Technical note -- attachments are implemented as codec extradata, so this option can actually be used to extract extradata from any stream, not just attachments. +@item -dump_filtergraph (@emph{global}) +Dump filter graph to stderr. It is off by default, the option is mostly useful +for debugging filter graph purposes + @item -noautorotate Disable automatically rotating video based on file metadata. diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7b6f802082..5b8319da07 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -607,6 +607,7 @@ extern AVIOContext *progress_avio; extern float max_error_rate; extern char *videotoolbox_pixfmt; +extern int dump_filtergraph; extern int filter_nbthreads; extern int filter_complex_nbthreads; extern int vstats_version; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 72838de1e2..edc15cff61 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1109,6 +1109,13 @@ int configure_filtergraph(FilterGraph *fg) if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0) goto fail; + if (dump_filtergraph) { + char *dump = avfilter_graph_dump(fg->graph, NULL); + fputs(dump, stderr); + fflush(stderr); + av_free(dump); + } + /* limit the lists of allowed formats to the ones selected, to * make sure they stay the same if the filtergraph is reconfigured later */ for (i = 0; i < fg->nb_outputs; i++) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 71063cc443..7616209a43 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -101,6 +101,7 @@ int copy_ts = 0; int start_at_zero = 0; int copy_tb = -1; int debug_ts = 0; +int dump_filtergraph = 0; int exit_on_error = 0; int abort_on_flags = 0; int print_stats = -1; @@ -3535,6 +3536,8 @@ const OptionDef options[] = { { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(dump_attachment) }, "extract an attachment into a file", "filename" }, + { "dump_filtergraph", OPT_BOOL, { &dump_filtergraph }, + "dump filter graph to stderr" }, { "stream_loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT | OPT_OFFSET, { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" }, { "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts },