diff mbox series

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

Message ID 20210512193717.363179-1-iglosiggio@dc.uba.ar
State New
Headers show
Series [FFmpeg-devel,v2] avfilter/src_movie: Expose open options | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Ignacio Losiggio May 12, 2021, 7:37 p.m. UTC
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@gmail.com>
---
 doc/filters.texi        | 5 +++++
 libavfilter/src_movie.c | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index 22d02c38f7..060ecfc093 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -27350,6 +27350,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.
+
+@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;