From 84e5a47f240ff73eea0435adf912bb54d11afe4b Mon Sep 17 00:00:00 2001 From: martii Date: Fri, 2 May 2014 14:52:10 +0200 Subject: [PATCH] libeplayer3: skip video until first audio frame was found --- libeplayer3/input.cpp | 5 ++++- libeplayer3/writer/pcm.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libeplayer3/input.cpp b/libeplayer3/input.cpp index e270f73..2f81a1d 100644 --- a/libeplayer3/input.cpp +++ b/libeplayer3/input.cpp @@ -88,6 +88,8 @@ bool Input::Play() int warnAudioWrite = 0; int warnVideoWrite = 0; + bool audioSeen = !audioTrack; // HACK: Drop all video frames until the first audio frame was seen to keep player2 from stuttering. + while (player->isPlaying && !player->abortRequested) { //IF MOVIE IS PAUSED, WAIT @@ -178,7 +180,7 @@ bool Input::Play() if (_videoTrack && (_videoTrack->stream == stream)) { int64_t pts = calcPts(stream, packet.pts); - if (!player->output.Write(stream, &packet, pts)) { + if (audioSeen && !player->output.Write(stream, &packet, pts)) { if (warnVideoWrite) warnVideoWrite--; else { @@ -202,6 +204,7 @@ bool Input::Play() } } } + audioSeen = true; } else if (_subtitleTrack && (_subtitleTrack->stream == stream)) { if (stream->codec->codec) { AVSubtitle sub; diff --git a/libeplayer3/writer/pcm.cpp b/libeplayer3/writer/pcm.cpp index 9e92031..12872e7 100644 --- a/libeplayer3/writer/pcm.cpp +++ b/libeplayer3/writer/pcm.cpp @@ -129,7 +129,7 @@ bool WriterPCM::prepareClipPlay() SubFrameLen *= uBitsPerSample / 8; //rewrite PES size to have as many complete subframes per PES as we can - SubFramesPerPES = ((sizeof(injectBuffer) - 18) - sizeof(lpcm_prv)) / SubFrameLen; + SubFramesPerPES = ((sizeof(injectBuffer) - 14) - sizeof(lpcm_prv)) / SubFrameLen; SubFrameLen *= SubFramesPerPES; //set number of channels