diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index e573cbc4b2..957b8cf296 100644 --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -225,6 +225,10 @@ int MovieDecoder_FFMpeg::HandleNextPacket() { // total number of frames. This is benign even if we did have an // accurate frame count at the start. total_frames_ = packet_buffer_.size(); + if (total_frames_ < frame_buffer_.size()) { + LOG->Trace("Video shorter than frame buffer, shrinking the buffer."); + frame_buffer_.resize(total_frames_); + } return 1; } lock.unlock(); @@ -575,6 +579,10 @@ RString MovieDecoder_FFMpeg::Open(RString sFile) * (av_stream_->avg_frame_rate.num) / (av_stream_->avg_frame_rate.den) / (1000000); LOG->Trace("Number of frames provided is inaccurate, estimating."); } + if (total_frames_ < frame_buffer_.size()) { + LOG->Trace("Video shorter than frame buffer, shrinking the buffer."); + frame_buffer_.resize(total_frames_); + } LOG->Trace("Number of frames detected: %i", total_frames_); return RString();