Skip to content

Commit

Permalink
Fix for movies shorter than the buffer size.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaggone committed Oct 22, 2024
1 parent 59e6e94 commit 2dce012
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/arch/MovieTexture/MovieTexture_FFMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2dce012

Please sign in to comment.