diff mbox series

[FFmpeg-devel,1/2] ffmpeg: add disable_all_auto_conversion_filters option.

Message ID 20200814171453.778664-1-george@nsup.org
State Superseded
Headers show
Series [FFmpeg-devel,1/2] ffmpeg: add disable_all_auto_conversion_filters option. | expand

Checks

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

Commit Message

Nicolas George Aug. 14, 2020, 5:14 p.m. UTC
Signed-off-by: Nicolas George <george@nsup.org>
---
 doc/ffmpeg.texi         | 5 +++++
 fftools/ffmpeg.h        | 1 +
 fftools/ffmpeg_filter.c | 2 ++
 fftools/ffmpeg_opt.c    | 3 +++
 4 files changed, 11 insertions(+)

Comments

Mark Thompson Aug. 14, 2020, 6:58 p.m. UTC | #1
On 14/08/2020 18:14, Nicolas George wrote:
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>   doc/ffmpeg.texi         | 5 +++++
>   fftools/ffmpeg.h        | 1 +
>   fftools/ffmpeg_filter.c | 2 ++
>   fftools/ffmpeg_opt.c    | 3 +++
>   4 files changed, 11 insertions(+)
> 
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index 267ddfe8b5..1603431d56 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -1746,6 +1746,11 @@ this buffer, in packets, for the matching output stream.
>   The default value of this option should be high enough for most uses, so only
>   touch this option if you are sure that you need it.
>   
> +@item -disable_all_auto_conversion_filters (@emph{global})
> +Disable automatically inserting conversion filters in all filter graphs,
> +including those defined by @option{-vf}, @option{-af},
> +@option{-filter_complex} and @option{-lavfi}.

The relation to the existing -autorotate and -autoscale options is confusing - those aren't disabled by this (because they are applied differently), but it sounds like they would be.

I'm not sure how to make this better.  Maybe it should be called "-autoconvert" to match and then override the others?

> +
>   @end table
>   
>   As a special exception, you can use a bitmap subtitle stream as input: it
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index 6e3f2545c7..acd297c8e8 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -613,6 +613,7 @@ extern char *videotoolbox_pixfmt;
>   extern int filter_nbthreads;
>   extern int filter_complex_nbthreads;
>   extern int vstats_version;
> +extern int disable_all_auto_conversion_filters;
>   
>   extern const AVIOInterruptCB int_cb;
>   
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index 4784e8a575..8721403d7a 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -1104,6 +1104,8 @@ int configure_filtergraph(FilterGraph *fg)
>           configure_output_filter(fg, fg->outputs[i], cur);
>       avfilter_inout_free(&outputs);
>   
> +    if (disable_all_auto_conversion_filters)
> +        avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);
>       if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
>           goto fail;
>   
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index 853550a142..e6131dac97 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -172,6 +172,7 @@ float max_error_rate  = 2.0/3;
>   int filter_nbthreads = 0;
>   int filter_complex_nbthreads = 0;
>   int vstats_version = 2;
> +int disable_all_auto_conversion_filters = 0;
>   
>   
>   static int intra_only         = 0;
> @@ -3545,6 +3546,8 @@ const OptionDef options[] = {
>           "create a complex filtergraph", "graph_description" },
>       { "filter_complex_script", HAS_ARG | OPT_EXPERT,                 { .func_arg = opt_filter_complex_script },
>           "read complex filtergraph description from a file", "filename" },
> +    { "disable_all_auto_conversion_filters", OPT_BOOL | OPT_EXPERT,  { &disable_all_auto_conversion_filters },
> +        "create a complex filtergraph", "graph_description" },

The help strings here looks suspiciously similar to the -filter_complex ones...

>       { "stats",          OPT_BOOL,                                    { &print_stats },
>           "print progress report during encoding", },
>       { "attach",         HAS_ARG | OPT_PERFILE | OPT_EXPERT |
> 

- Mark
Nicolas George Aug. 15, 2020, 3:03 p.m. UTC | #2
Mark Thompson (12020-08-14):
> The relation to the existing -autorotate and -autoscale options is
> confusing - those aren't disabled by this (because they are applied
> differently), but it sounds like they would be.

I updated the doc to:

Disable automatically inserting format conversion filters in all filter 
graphs, including those defined by @option{-vf}, @option{-af},
@option{-filter_complex} and @option{-lavfi}. If filter format negotiation 
requires a conversion, the initialization of the filters will fail.
Conversions can still be performed by inserting the relevant conversion
filter (scale, aresample) in the graph.

> I'm not sure how to make this better.  Maybe it should be called "-autoconvert" to match and then override the others?

I disagree: auto rotation and auto scaling are options for normal users,
to control the output. This is for very advanced users, only for
technical use by somebody who knows the inner workings of lavfi. They
should not be merged, and also this is why I chose a very long and
explicit name.

> The help strings here looks suspiciously similar to the -filter_complex ones...

Oops. Locally changed to:

        "disable all automatic conversion filters" },

Thanks.

Regards,
Mark Thompson Aug. 15, 2020, 9:40 p.m. UTC | #3
On 15/08/2020 16:03, Nicolas George wrote:
> Mark Thompson (12020-08-14):
>> The relation to the existing -autorotate and -autoscale options is
>> confusing - those aren't disabled by this (because they are applied
>> differently), but it sounds like they would be.
> 
> I updated the doc to:
> 
> Disable automatically inserting format conversion filters in all filter
> graphs, including those defined by @option{-vf}, @option{-af},
> @option{-filter_complex} and @option{-lavfi}. If filter format negotiation
> requires a conversion, the initialization of the filters will fail.
> Conversions can still be performed by inserting the relevant conversion
> filter (scale, aresample) in the graph.
> 
>> I'm not sure how to make this better.  Maybe it should be called "-autoconvert" to match and then override the others?
> 
> I disagree: auto rotation and auto scaling are options for normal users,
> to control the output. This is for very advanced users, only for
> technical use by somebody who knows the inner workings of lavfi. They
> should not be merged, and also this is why I chose a very long and
> explicit name.

Thank you for the clarification; I'm happy with that answer.

>> The help strings here looks suspiciously similar to the -filter_complex ones...
> 
> Oops. Locally changed to:
> 
>          "disable all automatic conversion filters" },

Sounds good to me with those changes.

Thanks,

- Mark
diff mbox series

Patch

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 267ddfe8b5..1603431d56 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1746,6 +1746,11 @@  this buffer, in packets, for the matching output stream.
 The default value of this option should be high enough for most uses, so only
 touch this option if you are sure that you need it.
 
+@item -disable_all_auto_conversion_filters (@emph{global})
+Disable automatically inserting conversion filters in all filter graphs,
+including those defined by @option{-vf}, @option{-af},
+@option{-filter_complex} and @option{-lavfi}.
+
 @end table
 
 As a special exception, you can use a bitmap subtitle stream as input: it
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6e3f2545c7..acd297c8e8 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -613,6 +613,7 @@  extern char *videotoolbox_pixfmt;
 extern int filter_nbthreads;
 extern int filter_complex_nbthreads;
 extern int vstats_version;
+extern int disable_all_auto_conversion_filters;
 
 extern const AVIOInterruptCB int_cb;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 4784e8a575..8721403d7a 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1104,6 +1104,8 @@  int configure_filtergraph(FilterGraph *fg)
         configure_output_filter(fg, fg->outputs[i], cur);
     avfilter_inout_free(&outputs);
 
+    if (disable_all_auto_conversion_filters)
+        avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);
     if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
         goto fail;
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 853550a142..e6131dac97 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -172,6 +172,7 @@  float max_error_rate  = 2.0/3;
 int filter_nbthreads = 0;
 int filter_complex_nbthreads = 0;
 int vstats_version = 2;
+int disable_all_auto_conversion_filters = 0;
 
 
 static int intra_only         = 0;
@@ -3545,6 +3546,8 @@  const OptionDef options[] = {
         "create a complex filtergraph", "graph_description" },
     { "filter_complex_script", HAS_ARG | OPT_EXPERT,                 { .func_arg = opt_filter_complex_script },
         "read complex filtergraph description from a file", "filename" },
+    { "disable_all_auto_conversion_filters", OPT_BOOL | OPT_EXPERT,  { &disable_all_auto_conversion_filters },
+        "create a complex filtergraph", "graph_description" },
     { "stats",          OPT_BOOL,                                    { &print_stats },
         "print progress report during encoding", },
     { "attach",         HAS_ARG | OPT_PERFILE | OPT_EXPERT |