Fix for movies shorter than the buffer size.

This commit is contained in:
Brandon W
2024-10-22 16:45:24 -07:00
committed by teejusb
parent a6a60e2e56
commit 1626398244
@@ -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();