Skip to content

Commit

Permalink
fix: last frame or two of clips not being played #1365 #1393 #1497
Browse files Browse the repository at this point in the history
Reverts the fix #1260 for #874
  • Loading branch information
Julusian committed Jan 25, 2025
1 parent 23c0ec6 commit d7b6e90
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/modules/ffmpeg/producer/av_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,14 +832,11 @@ struct AVProducer::Impl
auto start = start_.load();
auto duration = duration_.load();

start = start != AV_NOPTS_VALUE ? start : 0;
// duration is inclusive, end must be set one frame duration earlier
auto end = duration != AV_NOPTS_VALUE ? start + duration - frame.duration : INT64_MAX;
auto next_pts = frame.pts != AV_NOPTS_VALUE ? frame.pts + frame.duration : 0;
// check whether the next frame will last beyond the end time
auto time = next_pts ? next_pts + frame.duration : 0;

buffer_eof_ = (video_filter_.eof && audio_filter_.eof) || time > end;
start = start != AV_NOPTS_VALUE ? start : 0;
auto end = duration != AV_NOPTS_VALUE ? start + duration : INT64_MAX;
auto time = frame.pts != AV_NOPTS_VALUE ? frame.pts + frame.duration : 0;
buffer_eof_ = (video_filter_.eof && audio_filter_.eof) ||
av_rescale_q(time, TIME_BASE_Q, format_tb_) >= av_rescale_q(end, TIME_BASE_Q, format_tb_);

if (buffer_eof_) {
if (loop_ && frame_count_ > 2) {
Expand Down

0 comments on commit d7b6e90

Please sign in to comment.