Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated
@ 2024-01-17  9:22 Anton Khirnov
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 2/6] fftools/ffplay: " Anton Khirnov
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17  9:22 UTC (permalink / raw)
  To: ffmpeg-devel

Do not store the supplied arg pointer directly. While that is valid for
now, arg will become ephemeral in the future commits.
---
 fftools/ffprobe.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index f00ba48620..3a7aae3572 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3827,8 +3827,10 @@ static int opt_input_file(void *optctx, const char *arg)
         return AVERROR(EINVAL);
     }
     if (!strcmp(arg, "-"))
-        arg = "fd:";
-    input_filename = arg;
+        arg = "pipe:";
+    input_filename = av_strdup(arg);
+    if (!input_filename)
+        return AVERROR(ENOMEM);
 
     return 0;
 }
@@ -3849,15 +3851,18 @@ static int opt_output_file_o(void *optctx, const char *opt, const char *arg)
     }
     if (!strcmp(arg, "-"))
         arg = "fd:";
-    output_filename = arg;
+    output_filename = av_strdup(arg);
+    if (!output_filename)
+        return AVERROR(ENOMEM);
 
     return 0;
 }
 
 static int opt_print_filename(void *optctx, const char *opt, const char *arg)
 {
-    print_input_filename = arg;
-    return 0;
+    av_freep(&print_input_filename);
+    print_input_filename = av_strdup(arg);
+    return print_input_filename ? 0 : AVERROR(ENOMEM);
 }
 
 void show_help_default(const char *opt, const char *arg)
@@ -4287,6 +4292,9 @@ int main(int argc, char **argv)
 
 end:
     av_freep(&output_format);
+    av_freep(&output_filename);
+    av_freep(&input_filename);
+    av_freep(&print_input_filename);
     av_freep(&read_intervals);
     av_hash_freep(&hash);
 
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 2/6] fftools/ffplay: make option strings dynamically allocated
  2024-01-17  9:22 [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Anton Khirnov
@ 2024-01-17  9:22 ` Anton Khirnov
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 3/6] fftools/ffmpeg: make attachment filenames " Anton Khirnov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17  9:22 UTC (permalink / raw)
  To: ffmpeg-devel

Do not store the supplied arg pointer directly. While that is valid for
now, it will become ephemeral in the future commits.
---
 fftools/ffplay.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 3c378bca2c..356d061dee 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -400,7 +400,10 @@ static int opt_add_vfilter(void *optctx, const char *opt, const char *arg)
     if (ret < 0)
         return ret;
 
-    vfilters_list[nb_vfilters - 1] = arg;
+    vfilters_list[nb_vfilters - 1] = av_strdup(arg);
+    if (!vfilters_list[nb_vfilters - 1])
+        return AVERROR(ENOMEM);
+
     return 0;
 }
 
@@ -1305,7 +1308,13 @@ static void do_exit(VideoState *is)
     if (window)
         SDL_DestroyWindow(window);
     uninit_opts();
+    for (int i = 0; i < nb_vfilters; i++)
+        av_freep(&vfilters_list[i]);
     av_freep(&vfilters_list);
+    av_freep(&video_codec_name);
+    av_freep(&audio_codec_name);
+    av_freep(&subtitle_codec_name);
+    av_freep(&input_filename);
     avformat_network_deinit();
     if (show_status)
         printf("\n");
@@ -3594,8 +3603,10 @@ static int opt_input_file(void *optctx, const char *filename)
         return AVERROR(EINVAL);
     }
     if (!strcmp(filename, "-"))
-        filename = "fd:";
-    input_filename = filename;
+        filename = "pipe:";
+    input_filename = av_strdup(filename);
+    if (!input_filename)
+        return AVERROR(ENOMEM);
 
     return 0;
 }
@@ -3603,6 +3614,7 @@ static int opt_input_file(void *optctx, const char *filename)
 static int opt_codec(void *optctx, const char *opt, const char *arg)
 {
    const char *spec = strchr(opt, ':');
+   const char **name;
    if (!spec) {
        av_log(NULL, AV_LOG_ERROR,
               "No media specifier was specified in '%s' in option '%s'\n",
@@ -3610,16 +3622,20 @@ static int opt_codec(void *optctx, const char *opt, const char *arg)
        return AVERROR(EINVAL);
    }
    spec++;
+
    switch (spec[0]) {
-   case 'a' :    audio_codec_name = arg; break;
-   case 's' : subtitle_codec_name = arg; break;
-   case 'v' :    video_codec_name = arg; break;
+   case 'a' : name = &audio_codec_name;    break;
+   case 's' : name = &subtitle_codec_name; break;
+   case 'v' : name = &video_codec_name;    break;
    default:
        av_log(NULL, AV_LOG_ERROR,
               "Invalid media specifier '%s' in option '%s'\n", spec, opt);
        return AVERROR(EINVAL);
    }
-   return 0;
+
+   av_freep(name);
+   *name = av_strdup(arg);
+   return *name ? 0 : AVERROR(ENOMEM);
 }
 
 static int dummy;
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 3/6] fftools/ffmpeg: make attachment filenames dynamically allocated
  2024-01-17  9:22 [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Anton Khirnov
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 2/6] fftools/ffplay: " Anton Khirnov
@ 2024-01-17  9:22 ` Anton Khirnov
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 4/6] fftools/cmdutils: add option syntax for loading arbitrary arguments from a file Anton Khirnov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17  9:22 UTC (permalink / raw)
  To: ffmpeg-devel

Do not store the supplied arg pointer directly. While that is valid for
now, it will become ephemeral in the future commits.
---
 fftools/ffmpeg_opt.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ea995f2b5f..563f443bd8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -124,6 +124,9 @@ static void uninit_options(OptionsContext *o)
 #if FFMPEG_OPT_MAP_CHANNEL
     av_freep(&o->audio_channel_maps);
 #endif
+
+    for (i = 0; i < o->nb_attachments; i++)
+        av_freep(&o->attachments[i]);
     av_freep(&o->attachments);
 
     av_dict_free(&o->streamid);
@@ -494,7 +497,10 @@ static int opt_attach(void *optctx, const char *opt, const char *arg)
     if (ret < 0)
         return ret;
 
-    o->attachments[o->nb_attachments - 1] = arg;
+    o->attachments[o->nb_attachments - 1] = av_strdup(arg);
+    if (!o->attachments[o->nb_attachments - 1])
+        return AVERROR(ENOMEM);
+
     return 0;
 }
 
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 4/6] fftools/cmdutils: add option syntax for loading arbitrary arguments from a file
  2024-01-17  9:22 [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Anton Khirnov
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 2/6] fftools/ffplay: " Anton Khirnov
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 3/6] fftools/ffmpeg: make attachment filenames " Anton Khirnov
@ 2024-01-17  9:22 ` Anton Khirnov
  2024-01-17 13:08   ` Michael Niedermayer
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: deprecate -filter_complex_script Anton Khirnov
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17  9:22 UTC (permalink / raw)
  To: ffmpeg-devel

Aligned with analogous feature for filter options in ffmpeg CLI.
---
 Changelog                    |  2 +
 doc/fftools-common-opts.texi |  9 ++++
 fftools/cmdutils.c           | 99 ++++++++++++++++++++++++++++++------
 fftools/cmdutils.h           |  3 ++
 fftools/ffmpeg.h             |  1 -
 fftools/ffmpeg_opt.c         | 26 ----------
 6 files changed, 97 insertions(+), 43 deletions(-)

diff --git a/Changelog b/Changelog
index 6b7c1439cd..c40b6d08fd 100644
--- a/Changelog
+++ b/Changelog
@@ -20,6 +20,8 @@ version <next>:
 - fsync filter
 - Raw Captions with Time (RCWT) closed caption muxer
 - ffmpeg CLI -bsf option may now be used for input as well as output
+- ffmpeg CLI options may now be used as -/opt <path>, which is equivalent
+  to -opt <contents of file <path>>
 
 version 6.1:
 - libaribcaption decoder
diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index f459bfdc1d..1974d79a4c 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -13,6 +13,15 @@ corresponding value to true. They can be set to false by prefixing
 the option name with "no". For example using "-nofoo"
 will set the boolean option with name "foo" to false.
 
+Options that take arguments support a special syntax where the argument given on
+the command line is interpreted as a path to the file from which the actual
+argument value is loaded. To use this feature, add a forward slash '/'
+immediately before the option name (after the leading dash). E.g.
+@example
+ffmpeg -i INPUT -/filter:v filter.script OUTPUT
+@end example
+will load a filtergraph description from the file named @file{filter.script}.
+
 @anchor{Stream specifiers}
 @section Stream specifiers
 Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 44228ea637..d7d5ddee45 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -37,6 +37,7 @@
 #include "libswresample/swresample.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
+#include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/display.h"
 #include "libavutil/getenv_utf8.h"
@@ -150,6 +151,9 @@ void show_help_children(const AVClass *class, int flags)
 
 static const OptionDef *find_option(const OptionDef *po, const char *name)
 {
+    if (*name == '/')
+        name++;
+
     while (po->name) {
         const char *end;
         if (av_strstart(name, po->name, &end) && (!*end || *end == ':'))
@@ -239,9 +243,32 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
      * a global var*/
     void *dst = po->flags & OPT_FLAG_OFFSET ?
                 (uint8_t *)optctx + po->u.off : po->u.dst_ptr;
+    char *arg_allocated = NULL;
+
     SpecifierOptList *sol = NULL;
     double num;
-    int ret;
+    int ret = 0;
+
+    if (*opt == '/') {
+        opt++;
+
+        if (po->type == OPT_TYPE_BOOL) {
+            av_log(NULL, AV_LOG_FATAL,
+                   "Requested to load an argument from file for a bool option '%s'\n",
+                   po->name);
+            return AVERROR(EINVAL);
+        }
+
+        arg_allocated = file_read(arg);
+        if (!arg_allocated) {
+            av_log(NULL, AV_LOG_FATAL,
+                   "Error reading the value for option '%s' from file: %s\n",
+                   opt, arg);
+            return AVERROR(EINVAL);
+        }
+
+        arg = arg_allocated;
+    }
 
     if (po->flags & OPT_FLAG_SPEC) {
         char *p = strchr(opt, ':');
@@ -250,32 +277,42 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
         sol = dst;
         ret = GROW_ARRAY(sol->opt, sol->nb_opt);
         if (ret < 0)
-            return ret;
+            goto finish;
 
         str = av_strdup(p ? p + 1 : "");
-        if (!str)
-            return AVERROR(ENOMEM);
+        if (!str) {
+            ret = AVERROR(ENOMEM);
+            goto finish;
+        }
         sol->opt[sol->nb_opt - 1].specifier = str;
         dst = &sol->opt[sol->nb_opt - 1].u;
     }
 
     if (po->type == OPT_TYPE_STRING) {
         char *str;
-        str = av_strdup(arg);
+        if (arg_allocated) {
+            str           = arg_allocated;
+            arg_allocated = NULL;
+        } else
+            str = av_strdup(arg);
         av_freep(dst);
-        if (!str)
-            return AVERROR(ENOMEM);
+
+        if (!str) {
+            ret = AVERROR(ENOMEM);
+            goto finish;
+        }
+
         *(char **)dst = str;
     } else if (po->type == OPT_TYPE_BOOL || po->type == OPT_TYPE_INT) {
         ret = parse_number(opt, arg, OPT_TYPE_INT64, INT_MIN, INT_MAX, &num);
         if (ret < 0)
-            return ret;
+            goto finish;
 
         *(int *)dst = num;
     } else if (po->type == OPT_TYPE_INT64) {
         ret = parse_number(opt, arg, OPT_TYPE_INT64, INT64_MIN, INT64_MAX, &num);
         if (ret < 0)
-            return ret;
+            goto finish;
 
         *(int64_t *)dst = num;
     } else if (po->type == OPT_TYPE_TIME) {
@@ -283,18 +320,18 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
         if (ret < 0) {
             av_log(NULL, AV_LOG_ERROR, "Invalid duration for option %s: %s\n",
                    opt, arg);
-            return ret;
+            goto finish;
         }
     } else if (po->type == OPT_TYPE_FLOAT) {
         ret = parse_number(opt, arg, OPT_TYPE_FLOAT, -INFINITY, INFINITY, &num);
         if (ret < 0)
-            return ret;
+            goto finish;
 
         *(float *)dst = num;
     } else if (po->type == OPT_TYPE_DOUBLE) {
         ret = parse_number(opt, arg, OPT_TYPE_DOUBLE, -INFINITY, INFINITY, &num);
         if (ret < 0)
-            return ret;
+            goto finish;
 
         *(double *)dst = num;
     } else {
@@ -307,11 +344,13 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
             av_log(NULL, AV_LOG_ERROR,
                    "Failed to set value '%s' for option '%s': %s\n",
                    arg, opt, av_err2str(ret));
-            return ret;
+            goto finish;
         }
     }
-    if (po->flags & OPT_EXIT)
-        return AVERROR_EXIT;
+    if (po->flags & OPT_EXIT) {
+        ret = AVERROR_EXIT;
+        goto finish;
+    }
 
     if (sol) {
         sol->type = po->type;
@@ -319,7 +358,9 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
                          find_option(defs, po->u1.name_canon) : po;
     }
 
-    return 0;
+finish:
+    av_freep(&arg_allocated);
+    return ret;
 }
 
 int parse_option(void *optctx, const char *opt, const char *arg,
@@ -1088,3 +1129,29 @@ double get_rotation(const int32_t *displaymatrix)
 
     return theta;
 }
+
+/* read file contents into a string */
+char *file_read(const char *filename)
+{
+    AVIOContext *pb      = NULL;
+    int ret = avio_open(&pb, filename, AVIO_FLAG_READ);
+    AVBPrint bprint;
+    char *str;
+
+    if (ret < 0) {
+        av_log(NULL, AV_LOG_ERROR, "Error opening file %s.\n", filename);
+        return NULL;
+    }
+
+    av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
+    ret = avio_read_to_bprint(pb, &bprint, SIZE_MAX);
+    avio_closep(&pb);
+    if (ret < 0) {
+        av_bprint_finalize(&bprint, NULL);
+        return NULL;
+    }
+    ret = av_bprint_finalize(&bprint, &str);
+    if (ret < 0)
+        return NULL;
+    return str;
+}
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 53227abb47..8fa5ad4fc7 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -470,4 +470,7 @@ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
 
 double get_rotation(const int32_t *displaymatrix);
 
+/* read file contents into a string */
+char *file_read(const char *filename);
+
 #endif /* FFTOOLS_CMDUTILS_H */
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6137ac991e..cdde3c2c03 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -652,7 +652,6 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b);
 int check_avoptions(AVDictionary *m);
 
 int assert_file_overwrite(const char *filename);
-char *file_read(const char *filename);
 AVDictionary *strip_specifiers(const AVDictionary *dict);
 int find_codec(void *logctx, const char *name,
                enum AVMediaType type, int encoder, const AVCodec **codec);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 563f443bd8..ffb2c42421 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -765,32 +765,6 @@ int assert_file_overwrite(const char *filename)
     return 0;
 }
 
-/* read file contents into a string */
-char *file_read(const char *filename)
-{
-    AVIOContext *pb      = NULL;
-    int ret = avio_open(&pb, filename, AVIO_FLAG_READ);
-    AVBPrint bprint;
-    char *str;
-
-    if (ret < 0) {
-        av_log(NULL, AV_LOG_ERROR, "Error opening file %s.\n", filename);
-        return NULL;
-    }
-
-    av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
-    ret = avio_read_to_bprint(pb, &bprint, SIZE_MAX);
-    avio_closep(&pb);
-    if (ret < 0) {
-        av_bprint_finalize(&bprint, NULL);
-        return NULL;
-    }
-    ret = av_bprint_finalize(&bprint, &str);
-    if (ret < 0)
-        return NULL;
-    return str;
-}
-
 /* arg format is "output-stream-index:streamid-value". */
 static int opt_streamid(void *optctx, const char *opt, const char *arg)
 {
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: deprecate -filter_complex_script
  2024-01-17  9:22 [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Anton Khirnov
                   ` (2 preceding siblings ...)
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 4/6] fftools/cmdutils: add option syntax for loading arbitrary arguments from a file Anton Khirnov
@ 2024-01-17  9:22 ` Anton Khirnov
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 6/6] fftools/ffmpeg: deprecate -filter_script Anton Khirnov
  2024-01-17 11:22 ` [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Zhao Zhili
  5 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17  9:22 UTC (permalink / raw)
  To: ffmpeg-devel

It is equivalent to -/filter_complex.
---
 doc/ffmpeg.texi             |  9 +--------
 doc/filters.texi            |  3 +--
 fftools/ffmpeg.h            |  1 +
 fftools/ffmpeg_opt.c        |  9 ++++++++-
 tests/fate/ffmpeg.mak       |  2 +-
 tests/fate/filter-audio.mak |  8 ++++----
 tests/fate/filter-video.mak | 26 +++++++++++++-------------
 tests/fate/mov.mak          |  4 ++--
 8 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index e7d026ebf5..31a2b90b34 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1675,8 +1675,7 @@ Set the size of the canvas used to render subtitles.
 Create one or more streams in the output file. This option has two forms for
 specifying the data source(s): the first selects one or more streams from some
 input file (specified with @code{-i}), the second takes an output from some
-complex filtergraph (specified with @code{-filter_complex} or
-@code{-filter_complex_script}).
+complex filtergraph (specified with @code{-filter_complex}).
 
 In the first form, an output stream is created for every stream from the input
 file with the index @var{input_file_id}. If @var{stream_specifier} is given,
@@ -2207,12 +2206,6 @@ 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{filter_complex_script option}
-@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
-description is to be read.
-
 @item -accurate_seek (@emph{input})
 This option enables or disables accurate seeking in input files with the
 @option{-ss} option. It is enabled by default, so seeking is accurate when
diff --git a/doc/filters.texi b/doc/filters.texi
index 20c91bab3a..6ec7d54b5f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -308,8 +308,7 @@ use the @option{textfile} option in place of @option{text} to specify the text
 to render.
 
 When using the @command{ffmpeg} tool, you might consider to use the
-@ref{filter_script option,,-filter_script option,ffmpeg} or
-@ref{filter_complex_script option,,-filter_complex_script option,ffmpeg}.
+@ref{filter_script option,,-filter_script option,ffmpeg}.
 
 @chapter Timeline editing
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index cdde3c2c03..c73fb91c14 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -62,6 +62,7 @@
 #define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1
 #define FFMPEG_OPT_VSYNC_DROP 1
 #define FFMPEG_OPT_VSYNC 1
+#define FFMPEG_OPT_FILTER_SCRIPT 1
 
 #define FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D')
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ffb2c42421..d5bc7e9c8b 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1158,6 +1158,7 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
     return fg_create(NULL, graph_desc, sch);
 }
 
+#if FFMPEG_OPT_FILTER_SCRIPT
 static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
 {
     Scheduler *sch = optctx;
@@ -1165,8 +1166,12 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
     if (!graph_desc)
         return AVERROR(EINVAL);
 
+    av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
+           opt, arg);
+
     return fg_create(NULL, graph_desc, sch);
 }
+#endif
 
 void show_help_default(const char *opt, const char *arg)
 {
@@ -1635,9 +1640,11 @@ const OptionDef options[] = {
     { "lavfi",               OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_filter_complex },
         "create a complex filtergraph", "graph_description" },
+#if FFMPEG_OPT_FILTER_SCRIPT
     { "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_filter_complex_script },
-        "read complex filtergraph description from a file", "filename" },
+        "deprecated, use -/filter_complex instead", "filename" },
+#endif
     { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
         { &auto_conversion_filters },
         "enable automatic conversion filters globally" },
diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index df955df4d0..84489e9fea 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -36,7 +36,7 @@ fate-ffmpeg-attached_pics: CMD = threads=2 framecrc -i $(TARGET_SAMPLES)/lossles
 
 FATE_SAMPLES_FFMPEG-$(call FILTERDEMDEC, COLORKEY OVERLAY SCALE, MPEGPS IMAGE_PPM_PIPE, CAVS PPM, CAVSVIDEO_PARSER) += fate-ffmpeg-filter_colorkey
 fate-ffmpeg-filter_colorkey: tests/data/filtergraphs/colorkey
-fate-ffmpeg-filter_colorkey: CMD = framecrc -auto_conversion_filters -idct simple -fflags +bitexact -flags +bitexact  -sws_flags +accurate_rnd+bitexact -i $(TARGET_SAMPLES)/cavs/cavs.mpg -fflags +bitexact -flags +bitexact -sws_flags +accurate_rnd+bitexact -i $(TARGET_SAMPLES)/lena.pnm -an -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/colorkey -sws_flags +accurate_rnd+bitexact -fflags +bitexact -flags +bitexact -qscale 2 -frames:v 10
+fate-ffmpeg-filter_colorkey: CMD = framecrc -auto_conversion_filters -idct simple -fflags +bitexact -flags +bitexact  -sws_flags +accurate_rnd+bitexact -i $(TARGET_SAMPLES)/cavs/cavs.mpg -fflags +bitexact -flags +bitexact -sws_flags +accurate_rnd+bitexact -i $(TARGET_SAMPLES)/lena.pnm -an -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/colorkey -sws_flags +accurate_rnd+bitexact -fflags +bitexact -flags +bitexact -qscale 2 -frames:v 10
 
 FATE_FFMPEG-$(call FILTERFRAMECRC, COLOR) += fate-ffmpeg-lavfi
 fate-ffmpeg-lavfi: CMD = framecrc -lavfi color=d=1:r=5 -fflags +bitexact
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index adf61cf074..1d6f7c7f4e 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -82,7 +82,7 @@ FATE_AFILTER-$(call FILTERDEMDECENCMUX, ANEQUALIZER, WAV, PCM_S16LE, PCM_S16LE,
 fate-filter-anequalizer: tests/data/asynth-44100-2.wav
 fate-filter-anequalizer: tests/data/filtergraphs/anequalizer
 fate-filter-anequalizer: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-anequalizer: CMD = framecrc -auto_conversion_filters -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/anequalizer
+fate-filter-anequalizer: CMD = framecrc -auto_conversion_filters -i $(SRC) -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/anequalizer
 
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, ASETNSAMPLES, WAV, PCM_S16LE, PCM_S16LE, WAV) += fate-filter-asetnsamples-pad
 fate-filter-asetnsamples-pad: tests/data/asynth-44100-2.wav
@@ -202,7 +202,7 @@ FATE_AFILTER-$(call FILTERDEMDECENCMUX, COMPAND, WAV, PCM_S16LE, PCM_S16LE, WAV)
 fate-filter-compand: tests/data/asynth-44100-2.wav
 fate-filter-compand: tests/data/filtergraphs/compand
 fate-filter-compand: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-compand: CMD = framecrc -auto_conversion_filters -i $(SRC) -frames:a 20 -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/compand
+fate-filter-compand: CMD = framecrc -auto_conversion_filters -i $(SRC) -frames:a 20 -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/compand
 
 tests/data/hls-list.m3u8: TAG = GEN
 tests/data/hls-list.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
@@ -292,7 +292,7 @@ FATE_FILTER_CHANNELMAP += fate-filter-channelmap-one-int
 fate-filter-channelmap-one-int: tests/data/filtergraphs/channelmap_one_int
 fate-filter-channelmap-one-int: SRC = $(TARGET_PATH)/tests/data/asynth-44100-6.wav
 fate-filter-channelmap-one-int: tests/data/asynth-44100-6.wav
-fate-filter-channelmap-one-int: CMD = md5 -auto_conversion_filters -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/channelmap_one_int -f wav -fflags +bitexact
+fate-filter-channelmap-one-int: CMD = md5 -auto_conversion_filters -i $(SRC) -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/channelmap_one_int -f wav -fflags +bitexact
 fate-filter-channelmap-one-int: CMP = oneline
 fate-filter-channelmap-one-int: REF = 8cfe553d65ed4696756d8c1b824fcdd3
 
@@ -300,7 +300,7 @@ FATE_FILTER_CHANNELMAP += fate-filter-channelmap-one-str
 fate-filter-channelmap-one-str: tests/data/filtergraphs/channelmap_one_str
 fate-filter-channelmap-one-str: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
 fate-filter-channelmap-one-str: tests/data/asynth-44100-2.wav
-fate-filter-channelmap-one-str: CMD = md5 -auto_conversion_filters -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/channelmap_one_str -f wav -fflags +bitexact
+fate-filter-channelmap-one-str: CMD = md5 -auto_conversion_filters -i $(SRC) -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/channelmap_one_str -f wav -fflags +bitexact
 fate-filter-channelmap-one-str: CMP = oneline
 fate-filter-channelmap-one-str: REF = 0ea3052e482c95d5d3bd9da6dac1b5fa
 
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index c8bd8c2e1f..576f5a7dd0 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -200,28 +200,28 @@ fate-filter-vectorscope_xy: CMD = framecrc -auto_conversion_filters -c:v pgmyuv
 
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_MERGEPLANES_FILTER) += fate-filter-mergeplanes
 fate-filter-mergeplanes: tests/data/filtergraphs/mergeplanes
-fate-filter-mergeplanes: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/mergeplanes
+fate-filter-mergeplanes: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/mergeplanes
 
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_HSTACK_FILTER) += fate-filter-hstack
 fate-filter-hstack: tests/data/filtergraphs/hstack
-fate-filter-hstack: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/hstack
+fate-filter-hstack: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/hstack
 
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_VSTACK_FILTER) += fate-filter-vstack
 fate-filter-vstack: tests/data/filtergraphs/vstack
-fate-filter-vstack: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/vstack
+fate-filter-vstack: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/vstack
 
 FATE_FILTER_OVERLAY-$(call FILTERDEMDEC, SCALE OVERLAY, IMAGE2, PGMYUV) += fate-filter-overlay
-fate-filter-overlay: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -filter_complex_script $(FILTERGRAPH)
+fate-filter-overlay: CMD = framecrc -c:v pgmyuv -i $(SRC) -c:v pgmyuv -i $(SRC) -/filter_complex $(FILTERGRAPH)
 
 FATE_FILTER_OVERLAY-$(call FILTERDEMDEC, SPLIT SCALE PAD OVERLAY, IMAGE2, PGMYUV) += $(addprefix fate-filter-overlay_, rgb yuv420 yuv420p10 nv12 nv21 yuv422 yuv422p10 yuv444 yuv444p10)
-fate-filter-overlay_%: CMD = framecrc -auto_conversion_filters -c:v pgmyuv -i $(SRC) -filter_complex_script $(FILTERGRAPH)
-fate-filter-overlay_yuv420: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(FILTERGRAPH)
-fate-filter-overlay_%p10: CMD = framecrc -auto_conversion_filters -c:v pgmyuv -i $(SRC) -filter_complex_script $(FILTERGRAPH) -pix_fmt $(@:fate-filter-overlay_%=%)le -frames:v 3
+fate-filter-overlay_%: CMD = framecrc -auto_conversion_filters -c:v pgmyuv -i $(SRC) -/filter_complex $(FILTERGRAPH)
+fate-filter-overlay_yuv420: CMD = framecrc -c:v pgmyuv -i $(SRC) -/filter_complex $(FILTERGRAPH)
+fate-filter-overlay_%p10: CMD = framecrc -auto_conversion_filters -c:v pgmyuv -i $(SRC) -/filter_complex $(FILTERGRAPH) -pix_fmt $(@:fate-filter-overlay_%=%)le -frames:v 3
 
 $(addprefix fate-filter-overlay_, nv12 nv21): REF = $(SRC_PATH)/tests/ref/fate/filter-overlay_yuv420
 
 FATE_FILTER_OVERLAY_SAMPLES-$(call FILTERDEMDEC, SCALE OVERLAY, MATROSKA, H264 DVDSUB) += fate-filter-overlay-dvdsub-2397
-fate-filter-overlay-dvdsub-2397: CMD = framecrc -auto_conversion_filters -flags bitexact -i $(TARGET_SAMPLES)/filter/242_4.mkv -filter_complex_script $(FILTERGRAPH) -c:a copy
+fate-filter-overlay-dvdsub-2397: CMD = framecrc -auto_conversion_filters -flags bitexact -i $(TARGET_SAMPLES)/filter/242_4.mkv -/filter_complex $(FILTERGRAPH) -c:a copy
 
 FATE_FILTER_OVERLAY := $(FATE_FILTER_OVERLAY-yes) $(FATE_FILTER_OVERLAY_SAMPLES-yes)
 $(FATE_FILTER_OVERLAY): FILTERGRAPH = $(TARGET_PATH)/tests/data/filtergraphs/$(@:fate-filter-%=%)
@@ -335,7 +335,7 @@ fate-filter-unsharp-yuv420p10: CMD = framecrc -lavfi testsrc2=r=2:d=10,scale,for
 
 FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, PERMS HQDN3D, SMJPEG, MJPEG) += fate-filter-hqdn3d-sample
 fate-filter-hqdn3d-sample: tests/data/filtergraphs/hqdn3d
-fate-filter-hqdn3d-sample: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/hqdn3d -an
+fate-filter-hqdn3d-sample: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/hqdn3d -an
 
 FATE_FILTER_EPX-$(call FILTERDEMDEC, SCALE EPX, IMAGE2, PNG) = fate-filter-ep2x fate-filter-ep3x
 FATE_FILTER_SAMPLES-yes += $(FATE_FILTER_EPX-yes)
@@ -366,9 +366,9 @@ fate-filter-gradfun-sample: CMD = framecrc -auto_conversion_filters -i $(TARGET_
 
 FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC SINE CONCAT, FILE_PROTOCOL) += fate-filter-concat fate-filter-concat-vfr
 fate-filter-concat: tests/data/filtergraphs/concat
-fate-filter-concat: CMD = framecrc -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/concat
+fate-filter-concat: CMD = framecrc -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/concat
 fate-filter-concat-vfr: tests/data/filtergraphs/concat-vfr
-fate-filter-concat-vfr: CMD = framecrc -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/concat-vfr
+fate-filter-concat-vfr: CMD = framecrc -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/concat-vfr
 
 FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 CHROMASHIFT) += fate-filter-chromashift-smear fate-filter-chromashift-wrap
 fate-filter-chromashift-smear: CMD = framecrc -lavfi testsrc2=r=5:d=1,chromashift=cbh=-1:cbv=1:crh=2:crv=-2:edge=smear -pix_fmt yuv420p
@@ -404,7 +404,7 @@ fate-filter-fsync-down: CMD = framecrc -lavfi testsrc2=r=25:d=1,fsync=f=tests/da
 FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE := $(addprefix fate-filter-alphaextract_alphamerge_, rgb yuv)
 FATE_FILTER_VSYNTH_PGMYUV-$(call ALLYES, SCALE_FILTER FORMAT_FILTER SPLIT_FILTER ALPHAEXTRACT_FILTER ALPHAMERGE_FILTER) += $(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE)
 $(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE): fate-filter-alphaextract_alphamerge_%: tests/data/filtergraphs/alphamerge_alphaextract_%
-$(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE): CMD = framecrc -auto_conversion_filters -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/alphamerge_alphaextract$(@:fate-filter-alphaextract_alphamerge%=%)
+$(FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE): CMD = framecrc -auto_conversion_filters -c:v pgmyuv -i $(SRC) -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/alphamerge_alphaextract$(@:fate-filter-alphaextract_alphamerge%=%)
 
 FATE_FILTER_VSYNTH_VIDEO_FILTER-$(CONFIG_CROP_FILTER) += fate-filter-crop
 fate-filter-crop: CMD = video_filter "crop=iw-100:ih-100:100:100"
@@ -429,7 +429,7 @@ fate-filter-scale500: CMD = video_filter "scale=w=500:h=500"
 
 FATE_FILTER_VSYNTH-$(call ALLYES, TESTSRC_FILTER SCALE2REF_FILTER NULLSINK_FILTER FRAMEMD5_MUXER FILE_PROTOCOL PIPE_PROTOCOL) += fate-filter-scale2ref_keep_aspect
 fate-filter-scale2ref_keep_aspect: tests/data/filtergraphs/scale2ref_keep_aspect
-fate-filter-scale2ref_keep_aspect: CMD = framemd5 -frames:v 5 -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/scale2ref_keep_aspect -map "[main]"
+fate-filter-scale2ref_keep_aspect: CMD = framemd5 -frames:v 5 -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/scale2ref_keep_aspect -map "[main]"
 
 FATE_FILTER_VSYNTH-$(call FILTERDEMDEC, SCALE, RAWVIDEO, RAWVIDEO) += fate-filter-scalechroma
 fate-filter-scalechroma: tests/data/vsynth1.yuv
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 3dae929014..f202f36d96 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -170,13 +170,13 @@ FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MOV_FFMPEG_FFPROBE-yes)
 FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER PAN_FILTER) \
                           += fate-mov-channel-description
 fate-mov-channel-description: tests/data/asynth-44100-1.wav tests/data/filtergraphs/mov-channel-description
-fate-mov-channel-description: CMD = transcode wav $(TARGET_PATH)/tests/data/asynth-44100-1.wav mov "-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/mov-channel-description -map [outFL] -map [outFR] -map [outFC] -map [outLFE] -map [outBL] -map [outBR] -map [outDL] -map [outDR] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
+fate-mov-channel-description: CMD = transcode wav $(TARGET_PATH)/tests/data/asynth-44100-1.wav mov "-/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/mov-channel-description -map [outFL] -map [outFR] -map [outFC] -map [outLFE] -map [outBL] -map [outBR] -map [outDL] -map [outDR] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
 
 # Test PCM in mp4 and channel layout
 FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER PAN_FILTER) \
                           += fate-mov-mp4-pcm
 fate-mov-mp4-pcm: tests/data/asynth-44100-1.wav tests/data/filtergraphs/mov-mp4-pcm
-fate-mov-mp4-pcm: CMD = transcode wav $(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/mov-mp4-pcm -map [mono] -map [stereo] -map [2.1] -map [5.1] -map [7.1] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
+fate-mov-mp4-pcm: CMD = transcode wav $(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/mov-mp4-pcm -map [mono] -map [stereo] -map [2.1] -map [5.1] -map [7.1] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
 
 # Test floating sample format PCM in mp4 and unusual channel layout
 FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER PAN_FILTER) \
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [FFmpeg-devel] [PATCH 6/6] fftools/ffmpeg: deprecate -filter_script
  2024-01-17  9:22 [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Anton Khirnov
                   ` (3 preceding siblings ...)
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: deprecate -filter_complex_script Anton Khirnov
@ 2024-01-17  9:22 ` Anton Khirnov
  2024-01-17 11:22 ` [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Zhao Zhili
  5 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17  9:22 UTC (permalink / raw)
  To: ffmpeg-devel

It is equivalent to -/filter.
---
 doc/ffmpeg.texi             |  6 ------
 doc/filters.texi            |  3 ---
 fftools/ffmpeg.h            |  2 ++
 fftools/ffmpeg_mux_init.c   | 36 ++++++++++++++++++++++++++++++------
 fftools/ffmpeg_opt.c        |  4 +++-
 tests/fate/filter-audio.mak |  2 +-
 tests/fate/filter-video.mak |  6 +++---
 7 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 31a2b90b34..f58103810a 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -977,12 +977,6 @@ syntax.
 See the @ref{filter_complex_option,,-filter_complex option} if you
 want to create filtergraphs with multiple inputs and/or outputs.
 
-@anchor{filter_script option}
-@item -filter_script[:@var{stream_specifier}] @var{filename} (@emph{output,per-stream})
-This option is similar to @option{-filter}, the only difference is that its
-argument is the name of the file from which a filtergraph description is to be
-read.
-
 @item -reinit_filter[:@var{stream_specifier}] @var{integer} (@emph{input,per-stream})
 This boolean option determines if the filtergraph(s) to which this stream is fed gets
 reinitialized when input frame parameters change mid-stream. This option is enabled by
diff --git a/doc/filters.texi b/doc/filters.texi
index 6ec7d54b5f..1d70f4d934 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -307,9 +307,6 @@ For example, in case of the @ref{drawtext,,drawtext filter}, you might prefer to
 use the @option{textfile} option in place of @option{text} to specify the text
 to render.
 
-When using the @command{ffmpeg} tool, you might consider to use the
-@ref{filter_script option,,-filter_script option,ffmpeg}.
-
 @chapter Timeline editing
 
 Some filters support a generic @option{enable} option. For the filters
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index c73fb91c14..3014a626b4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -221,7 +221,9 @@ typedef struct OptionsContext {
     SpecifierOptList copy_initial_nonkeyframes;
     SpecifierOptList copy_prior_start;
     SpecifierOptList filters;
+#if FFMPEG_OPT_FILTER_SCRIPT
     SpecifierOptList filter_scripts;
+#endif
     SpecifierOptList reinit_filters;
     SpecifierOptList fix_sub_duration;
     SpecifierOptList fix_sub_duration_heartbeat;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 80109df0ae..5422a64cbc 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -415,36 +415,58 @@ static MuxStream *mux_stream_alloc(Muxer *mux, enum AVMediaType type)
 static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
                            OutputStream *ost, char **dst)
 {
-    const char *filters = NULL, *filters_script = NULL;
+    const char *filters = NULL;
+#if FFMPEG_OPT_FILTER_SCRIPT
+    const char *filters_script = NULL;
 
     MATCH_PER_STREAM_OPT(filter_scripts, str, filters_script, oc, ost->st);
+#endif
     MATCH_PER_STREAM_OPT(filters,        str, filters,        oc, ost->st);
 
     if (!ost->enc) {
-        if (filters_script || filters) {
+        if (
+#if FFMPEG_OPT_FILTER_SCRIPT
+            filters_script ||
+#endif
+            filters) {
             av_log(ost, AV_LOG_ERROR,
                    "%s '%s' was specified, but codec copy was selected. "
                    "Filtering and streamcopy cannot be used together.\n",
+#if FFMPEG_OPT_FILTER_SCRIPT
                    filters ? "Filtergraph" : "Filtergraph script",
-                   filters ? filters : filters_script);
+                   filters ? filters : filters_script
+#else
+                   "Filtergraph", filters
+#endif
+                   );
             return AVERROR(ENOSYS);
         }
         return 0;
     }
 
     if (!ost->ist) {
-        if (filters_script || filters) {
+        if (
+#if FFMPEG_OPT_FILTER_SCRIPT
+            filters_script ||
+#endif
+            filters) {
             av_log(ost, AV_LOG_ERROR,
                    "%s '%s' was specified for a stream fed from a complex "
                    "filtergraph. Simple and complex filtering cannot be used "
                    "together for the same stream.\n",
+#if FFMPEG_OPT_FILTER_SCRIPT
                    filters ? "Filtergraph" : "Filtergraph script",
-                   filters ? filters : filters_script);
+                   filters ? filters : filters_script
+#else
+                   "Filtergraph", filters
+#endif
+                   );
             return AVERROR(EINVAL);
         }
         return 0;
     }
 
+#if FFMPEG_OPT_FILTER_SCRIPT
     if (filters_script && filters) {
         av_log(ost, AV_LOG_ERROR, "Both -filter and -filter_script set\n");
         return AVERROR(EINVAL);
@@ -452,7 +474,9 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
 
     if (filters_script)
         *dst = file_read(filters_script);
-    else if (filters)
+    else
+#endif
+    if (filters)
         *dst = av_strdup(filters);
     else
         *dst = av_strdup(ost->type == AVMEDIA_TYPE_VIDEO ? "null" : "anull");
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index d5bc7e9c8b..1978f438fe 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1625,9 +1625,11 @@ const OptionDef options[] = {
     { "filter_threads",         OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
         { .func_arg = opt_filter_threads },
         "number of non-complex filter threads" },
+#if FFMPEG_OPT_FILTER_SCRIPT
     { "filter_script",          OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
         { .off = OFFSET(filter_scripts) },
-        "read stream filtergraph description from a file", "filename" },
+        "deprecated, use -/filter", "filename" },
+#endif
     { "reinit_filter",          OPT_TYPE_INT, OPT_SPEC | OPT_INPUT | OPT_EXPERT,
         { .off = OFFSET(reinit_filters) },
         "reinit filtergraph on input parameter changes", "" },
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 1d6f7c7f4e..05df1bb213 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -128,7 +128,7 @@ FATE_AFILTER-$(call FILTERDEMDECENCMUX, FIREQUALIZER ATRIM VOLUME, WAV, PCM_S16L
 fate-filter-firequalizer: tests/data/asynth-44100-2.wav
 fate-filter-firequalizer: tests/data/filtergraphs/firequalizer
 fate-filter-firequalizer: REF = tests/data/asynth-44100-2.wav
-fate-filter-firequalizer: CMD = ffmpeg -auto_conversion_filters -i $(TARGET_PATH)/tests/data/asynth-44100-2.wav -filter_script $(TARGET_PATH)/tests/data/filtergraphs/firequalizer -f wav -c:a pcm_s16le -
+fate-filter-firequalizer: CMD = ffmpeg -auto_conversion_filters -i $(TARGET_PATH)/tests/data/asynth-44100-2.wav -/filter $(TARGET_PATH)/tests/data/filtergraphs/firequalizer -f wav -c:a pcm_s16le -
 fate-filter-firequalizer: CMP = oneoff
 fate-filter-firequalizer: CMP_UNIT = s16
 fate-filter-firequalizer: SIZE_TOLERANCE = 1058400 - 1097208
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 576f5a7dd0..ee9f0f5e40 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -269,11 +269,11 @@ fate-filter-weave: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf weave=bottom
 
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_SELECT_FILTER) += fate-filter-select-alternate
 fate-filter-select-alternate: tests/data/filtergraphs/select-alternate
-fate-filter-select-alternate: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_script $(TARGET_PATH)/tests/data/filtergraphs/select-alternate
+fate-filter-select-alternate: CMD = framecrc -c:v pgmyuv -i $(SRC) -/filter $(TARGET_PATH)/tests/data/filtergraphs/select-alternate
 
 FATE_FILTER_VSYNTH_PGMYUV-$(call ALLYES, SETPTS_FILTER  SETTB_FILTER) += fate-filter-setpts
 fate-filter-setpts: tests/data/filtergraphs/setpts
-fate-filter-setpts: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_script $(TARGET_PATH)/tests/data/filtergraphs/setpts
+fate-filter-setpts: CMD = framecrc -c:v pgmyuv -i $(SRC) -/filter $(TARGET_PATH)/tests/data/filtergraphs/setpts
 
 FATE_SHUFFLEFRAMES += fate-filter-shuffleframes
 fate-filter-shuffleframes: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf shuffleframes="2|1|0"
@@ -362,7 +362,7 @@ fate-filter-curves: CMD = framecrc -i $(TARGET_SAMPLES)/utvideo/utvideo_rgb_medi
 
 FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FORMAT PERMS GRADFUN SCALE, VMD, VMDVIDEO) += fate-filter-gradfun-sample
 fate-filter-gradfun-sample: tests/data/filtergraphs/gradfun
-fate-filter-gradfun-sample: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/vmd/12.vmd -filter_script $(TARGET_PATH)/tests/data/filtergraphs/gradfun -an -frames:v 20
+fate-filter-gradfun-sample: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/vmd/12.vmd -/filter $(TARGET_PATH)/tests/data/filtergraphs/gradfun -an -frames:v 20
 
 FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC SINE CONCAT, FILE_PROTOCOL) += fate-filter-concat fate-filter-concat-vfr
 fate-filter-concat: tests/data/filtergraphs/concat
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated
  2024-01-17  9:22 [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Anton Khirnov
                   ` (4 preceding siblings ...)
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 6/6] fftools/ffmpeg: deprecate -filter_script Anton Khirnov
@ 2024-01-17 11:22 ` Zhao Zhili
  2024-01-17 12:32   ` Anton Khirnov
  5 siblings, 1 reply; 10+ messages in thread
From: Zhao Zhili @ 2024-01-17 11:22 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Jan 17, 2024, at 17:22, Anton Khirnov <anton@khirnov.net> wrote:
> 
> Do not store the supplied arg pointer directly. While that is valid for
> now, arg will become ephemeral in the future commits.
> ---
> fftools/ffprobe.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index f00ba48620..3a7aae3572 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -3827,8 +3827,10 @@ static int opt_input_file(void *optctx, const char *arg)
>         return AVERROR(EINVAL);
>     }
>     if (!strcmp(arg, "-"))
> -        arg = "fd:";
> -    input_filename = arg;
> +        arg = "pipe:";

Does the change of protocol on purpose, and why?

> +    input_filename = av_strdup(arg);
> +    if (!input_filename)
> +        return AVERROR(ENOMEM);
> 
>     return 0;
> }
> @@ -3849,15 +3851,18 @@ static int opt_output_file_o(void *optctx, const char *opt, const char *arg)
>     }
>     if (!strcmp(arg, "-"))
>         arg = "fd:";
> -    output_filename = arg;
> +    output_filename = av_strdup(arg);
> +    if (!output_filename)
> +        return AVERROR(ENOMEM);
> 
>     return 0;
> }
> 
> static int opt_print_filename(void *optctx, const char *opt, const char *arg)
> {
> -    print_input_filename = arg;
> -    return 0;
> +    av_freep(&print_input_filename);
> +    print_input_filename = av_strdup(arg);
> +    return print_input_filename ? 0 : AVERROR(ENOMEM);
> }
> 
> void show_help_default(const char *opt, const char *arg)
> @@ -4287,6 +4292,9 @@ int main(int argc, char **argv)
> 
> end:
>     av_freep(&output_format);
> +    av_freep(&output_filename);
> +    av_freep(&input_filename);
> +    av_freep(&print_input_filename);
>     av_freep(&read_intervals);
>     av_hash_freep(&hash);
> 
> -- 
> 2.42.0
> 
> _______________________________________________
> 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".

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated
  2024-01-17 11:22 ` [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Zhao Zhili
@ 2024-01-17 12:32   ` Anton Khirnov
  0 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17 12:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Zhao Zhili (2024-01-17 12:22:10)
> 
> 
> > On Jan 17, 2024, at 17:22, Anton Khirnov <anton@khirnov.net> wrote:
> > 
> > Do not store the supplied arg pointer directly. While that is valid for
> > now, arg will become ephemeral in the future commits.
> > ---
> > fftools/ffprobe.c | 18 +++++++++++++-----
> > 1 file changed, 13 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> > index f00ba48620..3a7aae3572 100644
> > --- a/fftools/ffprobe.c
> > +++ b/fftools/ffprobe.c
> > @@ -3827,8 +3827,10 @@ static int opt_input_file(void *optctx, const char *arg)
> >         return AVERROR(EINVAL);
> >     }
> >     if (!strcmp(arg, "-"))
> > -        arg = "fd:";
> > -    input_filename = arg;
> > +        arg = "pipe:";
> 
> Does the change of protocol on purpose, and why?

Good catch, it was a rebase fail.

Fixed locally.

Thanks,
-- 
Anton Khirnov
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/6] fftools/cmdutils: add option syntax for loading arbitrary arguments from a file
  2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 4/6] fftools/cmdutils: add option syntax for loading arbitrary arguments from a file Anton Khirnov
@ 2024-01-17 13:08   ` Michael Niedermayer
  2024-01-17 14:48     ` Anton Khirnov
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Niedermayer @ 2024-01-17 13:08 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1303 bytes --]

On Wed, Jan 17, 2024 at 10:22:31AM +0100, Anton Khirnov wrote:
> Aligned with analogous feature for filter options in ffmpeg CLI.
> ---
>  Changelog                    |  2 +
>  doc/fftools-common-opts.texi |  9 ++++
>  fftools/cmdutils.c           | 99 ++++++++++++++++++++++++++++++------
>  fftools/cmdutils.h           |  3 ++
>  fftools/ffmpeg.h             |  1 -
>  fftools/ffmpeg_opt.c         | 26 ----------
>  6 files changed, 97 insertions(+), 43 deletions(-)

git is unsable to apply this as well

Applying: fftools/cmdutils: add option syntax for loading arbitrary arguments from a file
error: sha1 information is lacking or useless (Changelog).
error: could not build fake ancestor
Patch failed at 0001 fftools/cmdutils: add option syntax for loading arbitrary arguments from a file
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/6] fftools/cmdutils: add option syntax for loading arbitrary arguments from a file
  2024-01-17 13:08   ` Michael Niedermayer
@ 2024-01-17 14:48     ` Anton Khirnov
  0 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2024-01-17 14:48 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Michael Niedermayer (2024-01-17 14:08:29)
> On Wed, Jan 17, 2024 at 10:22:31AM +0100, Anton Khirnov wrote:
> > Aligned with analogous feature for filter options in ffmpeg CLI.
> > ---
> >  Changelog                    |  2 +
> >  doc/fftools-common-opts.texi |  9 ++++
> >  fftools/cmdutils.c           | 99 ++++++++++++++++++++++++++++++------
> >  fftools/cmdutils.h           |  3 ++
> >  fftools/ffmpeg.h             |  1 -
> >  fftools/ffmpeg_opt.c         | 26 ----------
> >  6 files changed, 97 insertions(+), 43 deletions(-)
> 
> git is unsable to apply this as well

Sorry, forgot to mention that this is on top of my pending BSF set.
You can also look at the branch ffmpeg_opt_file in my tree.

-- 
Anton Khirnov
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-17 14:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17  9:22 [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Anton Khirnov
2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 2/6] fftools/ffplay: " Anton Khirnov
2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 3/6] fftools/ffmpeg: make attachment filenames " Anton Khirnov
2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 4/6] fftools/cmdutils: add option syntax for loading arbitrary arguments from a file Anton Khirnov
2024-01-17 13:08   ` Michael Niedermayer
2024-01-17 14:48     ` Anton Khirnov
2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: deprecate -filter_complex_script Anton Khirnov
2024-01-17  9:22 ` [FFmpeg-devel] [PATCH 6/6] fftools/ffmpeg: deprecate -filter_script Anton Khirnov
2024-01-17 11:22 ` [FFmpeg-devel] [PATCH 1/6] fftools/ffprobe: make option strings dynamically allocated Zhao Zhili
2024-01-17 12:32   ` Anton Khirnov

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git