Skip to content

Commit fb8143d

Browse files
adamrankinvpisarev
authored andcommitted
Using environment variable to store capture options (opencv#9292)
* Using environment variable to store options parsed by av_dict_parse_string(ENV{OPENCV_FFMPEG_CAPTURE_OPTIONS}, ";", "|") * Adding missing mandatory flags parameter * Guarding against missing function via LIBAVUTIL version * Code review fixes Copy/paste error due to coder mistake reverted Proper version checking for LIBAVUTIL_BUILD
1 parent fd20529 commit fb8143d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

modules/videoio/src/cap_ffmpeg_impl.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,23 @@ bool CvCapture_FFMPEG::open( const char* _filename )
781781
#endif
782782

783783
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
784+
#ifndef NO_GETENV
785+
char* options = getenv("OPENCV_FFMPEG_CAPTURE_OPTIONS");
786+
if(options == NULL)
787+
{
788+
av_dict_set(&dict, "rtsp_transport", "tcp", 0);
789+
}
790+
else
791+
{
792+
#if LIBAVUTIL_BUILD >= (LIBAVUTIL_VERSION_MICRO >= 100 ? CALC_FFMPEG_VERSION(52, 17, 100) : CALC_FFMPEG_VERSION(52, 7, 0))
793+
av_dict_parse_string(&dict, options, ";", "|", 0);
794+
#else
795+
av_dict_set(&dict, "rtsp_transport", "tcp", 0);
796+
#endif
797+
}
798+
#else
784799
av_dict_set(&dict, "rtsp_transport", "tcp", 0);
800+
#endif
785801
int err = avformat_open_input(&ic, _filename, NULL, &dict);
786802
#else
787803
int err = av_open_input_file(&ic, _filename, NULL, 0, NULL);

0 commit comments

Comments
 (0)