Fixed an issue where the video player would not play the last couple of frames for any videos

This commit is contained in:
Leon Styhre 2023-08-13 12:25:43 +02:00
parent fd955d5a6e
commit 89d94bc1b0
2 changed files with 8 additions and 1 deletions

View file

@ -58,6 +58,7 @@ VideoFFmpegComponent::VideoFFmpegComponent()
, mAccumulatedTime {0.0l}
, mStartTimeAccumulation {false}
, mDecodedFrame {false}
, mReadAllFrames {false}
, mEndOfVideo {false}
{
}
@ -761,7 +762,7 @@ void VideoFFmpegComponent::readFrames()
}
if (readFrameReturn < 0)
mEndOfVideo = true;
mReadAllFrames = true;
}
void VideoFFmpegComponent::getProcessedFrames()
@ -974,6 +975,9 @@ void VideoFFmpegComponent::outputFrames()
break;
}
}
if (mReadAllFrames && mVideoFrameQueue.empty())
mEndOfVideo = true;
}
void VideoFFmpegComponent::calculateBlackRectangle()
@ -1341,6 +1345,7 @@ void VideoFFmpegComponent::startVideoStream()
mStartTimeAccumulation = false;
mSWDecoder = true;
mDecodedFrame = false;
mReadAllFrames = false;
mEndOfVideo = false;
mVideoFrameCount = 0;
mAudioFrameCount = 0;
@ -1558,6 +1563,7 @@ void VideoFFmpegComponent::stopVideoPlayer(bool muteAudio)
mIsPlaying = false;
mIsActuallyPlaying = false;
mPaused = false;
mReadAllFrames = false;
mEndOfVideo = false;
mTexture.reset();

View file

@ -176,6 +176,7 @@ private:
std::atomic<double> mAccumulatedTime;
std::atomic<bool> mStartTimeAccumulation;
std::atomic<bool> mDecodedFrame;
std::atomic<bool> mReadAllFrames;
std::atomic<bool> mEndOfVideo;
bool mSWDecoder;
};