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

View file

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