From 27ccb685c788e949101032cc39932bfd20087d88 Mon Sep 17 00:00:00 2001 From: aliakseis Date: Tue, 23 Jul 2024 15:14:59 +0300 Subject: [PATCH] Fix for pts gaps --- video/ffmpegdecoder.cpp | 1 - video/videoparserunnable.cpp | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/video/ffmpegdecoder.cpp b/video/ffmpegdecoder.cpp index 0ceaf61..8b74b3a 100644 --- a/video/ffmpegdecoder.cpp +++ b/video/ffmpegdecoder.cpp @@ -304,7 +304,6 @@ bool FFmpegDecoder::openUrls(std::initializer_list urls, const std: AVDictionary *streamOpts = nullptr; auto avOptionsGuard = MakeGuard(&streamOpts, av_dict_free); - av_dict_set(&streamOpts, "stimeout", "5000000", 0); // 5 seconds rtsp timeout. av_dict_set(&streamOpts, "rw_timeout", "5000000", 0); // 5 seconds I/O timeout. if (boost::starts_with(url, "https://") || boost::starts_with(url, "http://")) // seems to be a bug { diff --git a/video/videoparserunnable.cpp b/video/videoparserunnable.cpp index d25d1cc..d54120e 100644 --- a/video/videoparserunnable.cpp +++ b/video/videoparserunnable.cpp @@ -521,6 +521,7 @@ bool FFmpegDecoder::handleVideoFrame( bool inNextFrame = false; bool continueHandlingPrevTime = false; + for (;;) { boost::unique_lock locker(m_isPausedMutex); while (m_isPaused && !m_isVideoSeekingWhilePaused) @@ -579,12 +580,21 @@ bool FFmpegDecoder::handleVideoFrame( } else { + if (deltaTime > 0.3 && m_formatContexts.size() == 1) + { + locker.unlock(); + boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); + continue; + } + const auto speed = getSpeedRational(); context.numSkipped = 0; td = boost::posix_time::milliseconds( int(deltaTime * 1000. * speed.denominator / speed.numerator) + 1); } } + + break; } context.initialized = true;