libeplayer3: skip video until first audio frame was found

This commit is contained in:
martii
2014-05-02 14:52:10 +02:00
parent dff15731cb
commit 84e5a47f24
2 changed files with 5 additions and 2 deletions

View File

@@ -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;

View File

@@ -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