From 96a27f4266178bfeb707558b2bba8d1ab3045727 Mon Sep 17 00:00:00 2001 From: Douwe Gelling Date: Fri, 19 Jul 2019 20:33:22 +0200 Subject: [PATCH] allow forcing the input format for ffmpeg backend with env var --- modules/videoio/src/cap_ffmpeg_impl.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index cafa3f8881..baf5a83669 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -891,7 +891,14 @@ bool CvCapture_FFMPEG::open( const char* _filename ) #else av_dict_set(&dict, "rtsp_transport", "tcp", 0); #endif - int err = avformat_open_input(&ic, _filename, NULL, &dict); + AVInputFormat* input_format = NULL; + AVDictionaryEntry* entry = av_dict_get(dict, "input_format", NULL, 0); + if (entry != 0) + { + input_format = av_find_input_format(entry->value); + } + + int err = avformat_open_input(&ic, _filename, input_format, &dict); #else int err = av_open_input_file(&ic, _filename, NULL, 0, NULL); #endif