Skip to content
Snippets Groups Projects
Commit 9fce93c5 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Adrien Béraud
Browse files

player: fix frame time

Handle cases when pts is smaller than start time.
(Usually should not happens).

Change-Id: Ia0687237764cef54d6830ab95169f21f295d041d
parent f03e2f62
Branches
No related tags found
No related merge requests found
...@@ -579,7 +579,8 @@ MediaDecoder::decode(AVPacket& packet) ...@@ -579,7 +579,8 @@ MediaDecoder::decode(AVPacket& packet)
| AV_ROUND_PASS_MINMAX)); | AV_ROUND_PASS_MINMAX));
lastTimestamp_ = frame->pts; lastTimestamp_ = frame->pts;
if (emulateRate_ and packetTimestamp != AV_NOPTS_VALUE) { if (emulateRate_ and packetTimestamp != AV_NOPTS_VALUE) {
auto frame_time = getTimeBase() * (packetTimestamp - avStream_->start_time); auto startTime = avStream_->start_time == AV_NOPTS_VALUE ? 0 : avStream_->start_time;
rational<double> frame_time = rational<double>(getTimeBase()) * (packetTimestamp - startTime);
auto target_relative = static_cast<std::int64_t>(frame_time.real() * 1e6); auto target_relative = static_cast<std::int64_t>(frame_time.real() * 1e6);
auto target_absolute = startTime_ + target_relative; auto target_absolute = startTime_ + target_relative;
if (target_relative < seekTime_) { if (target_relative < seekTime_) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment