Skip to content

Commit

Permalink
Fix for pts gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakseis committed Jul 23, 2024
1 parent f2801ec commit 27ccb68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion video/ffmpegdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ bool FFmpegDecoder::openUrls(std::initializer_list<std::string> 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
{
Expand Down
10 changes: 10 additions & 0 deletions video/videoparserunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ bool FFmpegDecoder::handleVideoFrame(
bool inNextFrame = false;
bool continueHandlingPrevTime = false;

for (;;)
{
boost::unique_lock<boost::mutex> locker(m_isPausedMutex);
while (m_isPaused && !m_isVideoSeekingWhilePaused)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 27ccb68

Please sign in to comment.