Skip to content
Permalink
Browse files

Video playback: Fix issue where jump back loses audio

The code that skips audio from before the first frame, sometimes
skips audio after a jump back, if some frames are processed
out of sequyence. Bypass this check when using frame timing.

Fixes #13330
  • Loading branch information...
bennettpeter committed Oct 11, 2018
1 parent 1f66a73 commit 4651002fc0c96c760bd243f9f5ac4df185cc1eab
Showing with 18 additions and 13 deletions.
  1. +18 −13 mythtv/libs/libmythtv/avformatdecoder.cpp
@@ -4984,21 +4984,26 @@ bool AvFormatDecoder::ProcessAudioPacket(AVStream *curstream, AVPacket *pkt,
if (firstloop && pkt->pts != (int64_t)AV_NOPTS_VALUE)
lastapts = (long long)(av_q2d(curstream->time_base) * pkt->pts * 1000);

if (skipaudio && selectedTrack[kTrackTypeVideo].av_stream_index > -1)
if (!use_frame_timing)
{
if ((lastapts < lastvpts - (10.0 / fps)) || lastvpts == 0)
break;
else
skipaudio = false;
}
// This code under certain conditions causes jump backwards to lose
// audio.
if (skipaudio && selectedTrack[kTrackTypeVideo].av_stream_index > -1)
{
if ((lastapts < lastvpts - (10.0 / fps)) || lastvpts == 0)
break;
else
skipaudio = false;
}

// skip any audio frames preceding first video frame
if (firstvptsinuse && firstvpts && (lastapts < firstvpts))
{
LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC +
QString("discarding early audio timecode %1 %2 %3")
.arg(pkt->pts).arg(pkt->dts).arg(lastapts));
break;
// skip any audio frames preceding first video frame
if (firstvptsinuse && firstvpts && (lastapts < firstvpts))
{
LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC +
QString("discarding early audio timecode %1 %2 %3")
.arg(pkt->pts).arg(pkt->dts).arg(lastapts));
break;
}
}
firstvptsinuse = false;

0 comments on commit 4651002

Please sign in to comment.
You can’t perform that action at this time.