diff mbox series

[FFmpeg-devel,v3,1/2] fftools: add global option to dump filter graph to stderr

Message ID 1589900073-4183-1-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,v3,1/2] fftools: add global option to dump filter graph to stderr | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Lance Wang May 19, 2020, 2:54 p.m. UTC
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 mbox series

Patch

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index ed437bb..b50fd7f 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 38205a1..a6025d0 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -606,6 +606,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 8b5b157..46dfb25 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1106,6 +1106,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 60bb437..9179fd3 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -161,6 +161,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;
@@ -3548,6 +3549,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 },