diff mbox

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

Message ID 20191120145456.20251-1-lance.lmwang@gmail.com
State Superseded
Headers show

Commit Message

Lance Wang Nov. 20, 2019, 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.

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(+)

Comments

Carl Eugen Hoyos Nov. 21, 2019, 9:49 a.m. UTC | #1
Am Mi., 20. Nov. 2019 um 16:03 Uhr schrieb <lance.lmwang@gmail.com>:
>
> From: Limin Wang <lance.lmwang@gmail.com>
>
> It's useful for debugging filter graph purposes, now only lavfi can do that.
>
> 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..7e55f67898 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -668,6 +668,10 @@ Defines how many threads are used to process a filter pipeline. Each pipeline
>  will produce a thread pool with this many threads available for parallel processing.
>  The default is the number of available CPUs.
>
> +@item -filter_dumpgraph (@emph{global})
> +Dump filter graph to stderr. It is off by default, the option is mostly useful
> +for debugging filter graph purposes
> +
>  @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
>  Specify the preset for matching stream(s).
>
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index 7b6f802082..b3133e7e99 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -608,6 +608,7 @@ extern float max_error_rate;
>  extern char *videotoolbox_pixfmt;
>
>  extern int filter_nbthreads;
> +extern int filter_dumpgraph;
>  extern int filter_complex_nbthreads;
>  extern int vstats_version;
>
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index 72838de1e2..35ba3a38db 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 (filter_dumpgraph) {
> +        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..44eb890e86 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -110,6 +110,7 @@ int frame_bits_per_raw_sample = 0;
>  float max_error_rate  = 2.0/3;
>  int filter_nbthreads = 0;
>  int filter_complex_nbthreads = 0;
> +int filter_dumpgraph = 0;
>  int vstats_version = 2;
>
>
> @@ -3523,6 +3524,8 @@ const OptionDef options[] = {
>          "create a complex filtergraph", "graph_description" },
>      { "filter_complex_threads", HAS_ARG | OPT_INT,                   { &filter_complex_nbthreads },
>          "number of threads for -filter_complex" },
> +    { "filter_dumpgraph", OPT_BOOL,                                  { &filter_dumpgraph },
> +        "dump filter graph to stderr" },

dump_filtergraph ?

Carl Eugen
Lance Wang Nov. 21, 2019, 11:28 a.m. UTC | #2
On Thu, Nov 21, 2019 at 10:49:28AM +0100, Carl Eugen Hoyos wrote:
> Am Mi., 20. Nov. 2019 um 16:03 Uhr schrieb <lance.lmwang@gmail.com>:
> >
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > It's useful for debugging filter graph purposes, now only lavfi can do that.
> >
> > 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..7e55f67898 100644
> > --- a/doc/ffmpeg.texi
> > +++ b/doc/ffmpeg.texi
> > @@ -668,6 +668,10 @@ Defines how many threads are used to process a filter pipeline. Each pipeline
> >  will produce a thread pool with this many threads available for parallel processing.
> >  The default is the number of available CPUs.
> >
> > +@item -filter_dumpgraph (@emph{global})
> > +Dump filter graph to stderr. It is off by default, the option is mostly useful
> > +for debugging filter graph purposes
> > +
> >  @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
> >  Specify the preset for matching stream(s).
> >
> > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> > index 7b6f802082..b3133e7e99 100644
> > --- a/fftools/ffmpeg.h
> > +++ b/fftools/ffmpeg.h
> > @@ -608,6 +608,7 @@ extern float max_error_rate;
> >  extern char *videotoolbox_pixfmt;
> >
> >  extern int filter_nbthreads;
> > +extern int filter_dumpgraph;
> >  extern int filter_complex_nbthreads;
> >  extern int vstats_version;
> >
> > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> > index 72838de1e2..35ba3a38db 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 (filter_dumpgraph) {
> > +        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..44eb890e86 100644
> > --- a/fftools/ffmpeg_opt.c
> > +++ b/fftools/ffmpeg_opt.c
> > @@ -110,6 +110,7 @@ int frame_bits_per_raw_sample = 0;
> >  float max_error_rate  = 2.0/3;
> >  int filter_nbthreads = 0;
> >  int filter_complex_nbthreads = 0;
> > +int filter_dumpgraph = 0;
> >  int vstats_version = 2;
> >
> >
> > @@ -3523,6 +3524,8 @@ const OptionDef options[] = {
> >          "create a complex filtergraph", "graph_description" },
> >      { "filter_complex_threads", HAS_ARG | OPT_INT,                   { &filter_complex_nbthreads },
> >          "number of threads for -filter_complex" },
> > +    { "filter_dumpgraph", OPT_BOOL,                                  { &filter_dumpgraph },
> > +        "dump filter graph to stderr" },
> 
> dump_filtergraph ?

Carl, thanks for the feedback, I'm ok with your recomment name and will
update it if no further comments next time.


> 
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Carl Eugen Hoyos Nov. 21, 2019, 12:32 p.m. UTC | #3
Am Do., 21. Nov. 2019 um 12:28 Uhr schrieb Limin Wang <lance.lmwang@gmail.com>:
>
> On Thu, Nov 21, 2019 at 10:49:28AM +0100, Carl Eugen Hoyos wrote:
> > Am Mi., 20. Nov. 2019 um 16:03 Uhr schrieb <lance.lmwang@gmail.com>:
> > >
> > > From: Limin Wang <lance.lmwang@gmail.com>
> > >
> > > It's useful for debugging filter graph purposes, now only lavfi can do that.
> > >
> > > 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..7e55f67898 100644
> > > --- a/doc/ffmpeg.texi
> > > +++ b/doc/ffmpeg.texi
> > > @@ -668,6 +668,10 @@ Defines how many threads are used to process a filter pipeline. Each pipeline
> > >  will produce a thread pool with this many threads available for parallel processing.
> > >  The default is the number of available CPUs.
> > >
> > > +@item -filter_dumpgraph (@emph{global})
> > > +Dump filter graph to stderr. It is off by default, the option is mostly useful
> > > +for debugging filter graph purposes
> > > +
> > >  @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
> > >  Specify the preset for matching stream(s).
> > >
> > > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> > > index 7b6f802082..b3133e7e99 100644
> > > --- a/fftools/ffmpeg.h
> > > +++ b/fftools/ffmpeg.h
> > > @@ -608,6 +608,7 @@ extern float max_error_rate;
> > >  extern char *videotoolbox_pixfmt;
> > >
> > >  extern int filter_nbthreads;
> > > +extern int filter_dumpgraph;
> > >  extern int filter_complex_nbthreads;
> > >  extern int vstats_version;
> > >
> > > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> > > index 72838de1e2..35ba3a38db 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 (filter_dumpgraph) {
> > > +        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..44eb890e86 100644
> > > --- a/fftools/ffmpeg_opt.c
> > > +++ b/fftools/ffmpeg_opt.c
> > > @@ -110,6 +110,7 @@ int frame_bits_per_raw_sample = 0;
> > >  float max_error_rate  = 2.0/3;
> > >  int filter_nbthreads = 0;
> > >  int filter_complex_nbthreads = 0;
> > > +int filter_dumpgraph = 0;
> > >  int vstats_version = 2;
> > >
> > >
> > > @@ -3523,6 +3524,8 @@ const OptionDef options[] = {
> > >          "create a complex filtergraph", "graph_description" },
> > >      { "filter_complex_threads", HAS_ARG | OPT_INT,                   { &filter_complex_nbthreads },
> > >          "number of threads for -filter_complex" },
> > > +    { "filter_dumpgraph", OPT_BOOL,                                  { &filter_dumpgraph },
> > > +        "dump filter graph to stderr" },
> >
> > dump_filtergraph ?
>
> Carl, thanks for the feedback, I'm ok with your recomment name and will
> update it if no further comments next time.

Consider waiting for others' opinions, I am not a native speaker...

Carl Eugen
Lance Wang Dec. 3, 2019, 2:23 p.m. UTC | #4
On Thu, Nov 21, 2019 at 01:32:58PM +0100, Carl Eugen Hoyos wrote:
> Am Do., 21. Nov. 2019 um 12:28 Uhr schrieb Limin Wang <lance.lmwang@gmail.com>:
> >
> > On Thu, Nov 21, 2019 at 10:49:28AM +0100, Carl Eugen Hoyos wrote:
> > > Am Mi., 20. Nov. 2019 um 16:03 Uhr schrieb <lance.lmwang@gmail.com>:
> > > >
> > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > >
> > > > It's useful for debugging filter graph purposes, now only lavfi can do that.
> > > >
> > > > 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..7e55f67898 100644
> > > > --- a/doc/ffmpeg.texi
> > > > +++ b/doc/ffmpeg.texi
> > > > @@ -668,6 +668,10 @@ Defines how many threads are used to process a filter pipeline. Each pipeline
> > > >  will produce a thread pool with this many threads available for parallel processing.
> > > >  The default is the number of available CPUs.
> > > >
> > > > +@item -filter_dumpgraph (@emph{global})
> > > > +Dump filter graph to stderr. It is off by default, the option is mostly useful
> > > > +for debugging filter graph purposes
> > > > +
> > > >  @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
> > > >  Specify the preset for matching stream(s).
> > > >
> > > > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> > > > index 7b6f802082..b3133e7e99 100644
> > > > --- a/fftools/ffmpeg.h
> > > > +++ b/fftools/ffmpeg.h
> > > > @@ -608,6 +608,7 @@ extern float max_error_rate;
> > > >  extern char *videotoolbox_pixfmt;
> > > >
> > > >  extern int filter_nbthreads;
> > > > +extern int filter_dumpgraph;
> > > >  extern int filter_complex_nbthreads;
> > > >  extern int vstats_version;
> > > >
> > > > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> > > > index 72838de1e2..35ba3a38db 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 (filter_dumpgraph) {
> > > > +        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..44eb890e86 100644
> > > > --- a/fftools/ffmpeg_opt.c
> > > > +++ b/fftools/ffmpeg_opt.c
> > > > @@ -110,6 +110,7 @@ int frame_bits_per_raw_sample = 0;
> > > >  float max_error_rate  = 2.0/3;
> > > >  int filter_nbthreads = 0;
> > > >  int filter_complex_nbthreads = 0;
> > > > +int filter_dumpgraph = 0;
> > > >  int vstats_version = 2;
> > > >
> > > >
> > > > @@ -3523,6 +3524,8 @@ const OptionDef options[] = {
> > > >          "create a complex filtergraph", "graph_description" },
> > > >      { "filter_complex_threads", HAS_ARG | OPT_INT,                   { &filter_complex_nbthreads },
> > > >          "number of threads for -filter_complex" },
> > > > +    { "filter_dumpgraph", OPT_BOOL,                                  { &filter_dumpgraph },
> > > > +        "dump filter graph to stderr" },
> > >
> > > dump_filtergraph ?
> >
> > Carl, thanks for the feedback, I'm ok with your recomment name and will
> > update it if no further comments next time.
> 
> Consider waiting for others' opinions, I am not a native speaker...

I have updated the patch for the option name, any other comments?


> 
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 9cccc2337d..7e55f67898 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -668,6 +668,10 @@  Defines how many threads are used to process a filter pipeline. Each pipeline
 will produce a thread pool with this many threads available for parallel processing.
 The default is the number of available CPUs.
 
+@item -filter_dumpgraph (@emph{global})
+Dump filter graph to stderr. It is off by default, the option is mostly useful
+for debugging filter graph purposes
+
 @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
 Specify the preset for matching stream(s).
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7b6f802082..b3133e7e99 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -608,6 +608,7 @@  extern float max_error_rate;
 extern char *videotoolbox_pixfmt;
 
 extern int filter_nbthreads;
+extern int filter_dumpgraph;
 extern int filter_complex_nbthreads;
 extern int vstats_version;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 72838de1e2..35ba3a38db 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 (filter_dumpgraph) {
+        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..44eb890e86 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -110,6 +110,7 @@  int frame_bits_per_raw_sample = 0;
 float max_error_rate  = 2.0/3;
 int filter_nbthreads = 0;
 int filter_complex_nbthreads = 0;
+int filter_dumpgraph = 0;
 int vstats_version = 2;
 
 
@@ -3523,6 +3524,8 @@  const OptionDef options[] = {
         "create a complex filtergraph", "graph_description" },
     { "filter_complex_threads", HAS_ARG | OPT_INT,                   { &filter_complex_nbthreads },
         "number of threads for -filter_complex" },
+    { "filter_dumpgraph", OPT_BOOL,                                  { &filter_dumpgraph },
+        "dump filter graph to stderr" },
     { "lavfi",          HAS_ARG | OPT_EXPERT,                        { .func_arg = opt_filter_complex },
         "create a complex filtergraph", "graph_description" },
     { "filter_complex_script", HAS_ARG | OPT_EXPERT,                 { .func_arg = opt_filter_complex_script },