Merge pull request #21561 from cudawarped:ffmpeg_prefer_tcp_default
authorcudawarped <12133430+cudawarped@users.noreply.github.com>
Thu, 10 Feb 2022 16:45:34 +0000 (16:45 +0000)
committerGitHub <noreply@github.com>
Thu, 10 Feb 2022 16:45:34 +0000 (19:45 +0300)
Default FFMPEG VideoCapture backend to rtsp_flags=prefer_tcp

* Make the VideoCapture ffmpeg backends default rtsp connection type prefer_tcp.

* Ensure that the ffmpeg version of avformat is checked.

modules/videoio/src/cap_ffmpeg_impl.hpp

index 2188c25..47dc00a 100644 (file)
@@ -980,7 +980,11 @@ bool CvCapture_FFMPEG::open(const char* _filename, const VideoCaptureParameters&
     char* options = getenv("OPENCV_FFMPEG_CAPTURE_OPTIONS");
     if(options == NULL)
     {
+#if LIBAVFORMAT_VERSION_MICRO >= 100  && LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 48, 100)
+        av_dict_set(&dict, "rtsp_flags", "prefer_tcp", 0);
+#else
         av_dict_set(&dict, "rtsp_transport", "tcp", 0);
+#endif
     }
     else
     {