[FFmpeg-devel] [PATCH] avfilter/src_movie: Expose open options

Ignacio Losiggio iglosiggio at dc.uba.ar
Wed May 12 22:03:30 EEST 2021


Add a dict-typed option to movie/amovie called options that gets
forwarded to avformat_open_input. This now allows complex filtergraph
setups that require options on their movie sources (for example, setting
the pixel format of a webcam).

Signed-off-by: Ignacio Losiggio <iglosiggio at gmail.com>
---
 doc/filters.texi        | 5 +++++
 libavfilter/src_movie.c | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index b405cc5dfb..51bc824795 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -27312,6 +27312,11 @@ changed, so it will generate non monotonically increasing timestamps.
 Specifies the time difference between frames above which the point is
 considered a timestamp discontinuity which is removed by adjusting the later
 timestamps.
+
+ at item options
+Specifies the options passed to the movie. Special care needs to be taken when
+passing multiple options, because ":" is an special token it needs to be
+escaped even inside "'" delimiters.
 @end table
 
 It allows overlaying a second video on top of the main input of
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 54f6738f9a..52cc6c6ca5 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -61,6 +61,7 @@ typedef struct MovieContext {
     int64_t seek_point;   ///< seekpoint in microseconds
     double seek_point_d;
     char *format_name;
+    AVDictionary *options;
     char *file_name;
     char *stream_specs; /**< user-provided list of streams, separated by + */
     int stream_index; /**< for compatibility */
@@ -90,6 +91,7 @@ static const AVOption movie_options[]= {
     { "s",            "set streams",             OFFSET(stream_specs), AV_OPT_TYPE_STRING, {.str =  0},  0, 0, FLAGS },
     { "loop",         "set loop count",          OFFSET(loop_count),   AV_OPT_TYPE_INT,    {.i64 =  1},  0,        INT_MAX, FLAGS },
     { "discontinuity", "set discontinuity threshold", OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS },
+    { "options",       "set format options",          OFFSET(options),                 AV_OPT_TYPE_DICT,                      .flags = FLAGS },
     { NULL },
 };
 
@@ -239,7 +241,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
     iformat = movie->format_name ? av_find_input_format(movie->format_name) : NULL;
 
     movie->format_ctx = NULL;
-    if ((ret = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, NULL)) < 0) {
+    if ((ret = avformat_open_input(&movie->format_ctx, movie->file_name, iformat, &movie->options)) < 0) {
         av_log(ctx, AV_LOG_ERROR,
                "Failed to avformat_open_input '%s'\n", movie->file_name);
         return ret;
-- 
2.31.1



More information about the ffmpeg-devel mailing list