From b1f8d3f91290f206f1753ecf0608260599f67721 Mon Sep 17 00:00:00 2001 From: tux3 Date: Fri, 4 Dec 2015 20:35:50 +0100 Subject: [PATCH] Fix attempt for #2438 --- src/video/cameradevice.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/video/cameradevice.cpp b/src/video/cameradevice.cpp index 5ae972bf9..96c1ec3fa 100644 --- a/src/video/cameradevice.cpp +++ b/src/video/cameradevice.cpp @@ -50,6 +50,7 @@ CameraDevice* CameraDevice::open(QString devName, AVDictionary** options) openDeviceLock.lock(); AVFormatContext* fctx = nullptr; CameraDevice* dev = openDevices.value(devName); + int aduration; if (dev) goto out; @@ -72,12 +73,25 @@ CameraDevice* CameraDevice::open(QString devName, AVDictionary** options) if (avformat_open_input(&fctx, devName.toStdString().c_str(), format, options)<0) goto out; + // Fix avformat_find_stream_info hanging on garbage input +#if FF_API_PROBESIZE_32 + aduration = fctx->max_analyze_duration2 = 0; +#else + aduration = fctx->max_analyze_duration = 0; +#endif + if (avformat_find_stream_info(fctx, NULL) < 0) { avformat_close_input(&fctx); goto out; } +#if FF_API_PROBESIZE_32 + fctx->max_analyze_duration2 = aduration; +#else + fctx->max_analyze_duration = aduration; +#endif + dev = new CameraDevice{devName, fctx}; openDevices[devName] = dev;