[FFmpeg-devel] [PATCH v3] avfilter/src_movie: add format_opts for the opened file

lance.lmwang at gmail.com lance.lmwang at gmail.com
Fri Nov 26 14:48:17 EET 2021


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 doc/filters.texi        | 9 +++++++++
 libavfilter/src_movie.c | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 3731a14..3b70aca 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -28395,6 +28395,15 @@ timestamps.
 
 @item dec_threads
 Specifies the number of threads for decoding
+
+ at item format_opts
+Specify format options for the opened file. Format options can be specified
+as a list of @var{key}=@var{value} pairs separated by ':'. The following example
+shows how to add protocol_whitelist and protocol_blacklist options:
+ at example
+./ffplay -f lavfi
+"movie=filename='1.sdp':format_opts='protocol_whitelist=file,rtp,udp\:protocol_blacklist=http'"
+ at end example
 @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 220a43c..b89a680 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -74,6 +74,7 @@ typedef struct MovieContext {
     int max_stream_index; /**< max stream # actually used for output */
     MovieStream *st; /**< array of all streams, one per output */
     int *out_index; /**< stream number -> output number map, or -1 */
+    AVDictionary *format_opts;
 } MovieContext;
 
 #define OFFSET(x) offsetof(MovieContext, x)
@@ -92,6 +93,7 @@ static const AVOption movie_options[]= {
     { "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 },
     { "dec_threads",  "set the number of threads for decoding", OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 =  0}, 0, INT_MAX, FLAGS },
+    { "format_opts",  "set format options for the opened file", OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
     { NULL },
 };
 
@@ -243,7 +245,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->format_opts)) < 0) {
         av_log(ctx, AV_LOG_ERROR,
                "Failed to avformat_open_input '%s'\n", movie->file_name);
         return ret;
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list