From f2e3522a9dcf7bd0a7a1f1073e45b4450e3b68f0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 29 Sep 2022 10:17:50 +0200 Subject: Change how video timing is done. This commit changes the approach with video timing. Previously, we would (more-or-less) try to use every video frame from the content in the output, hoping that they come at a constant frame rate. This is not always the case, however. Here we preserve the PTS of video frames, and then when one arrives we output whatever DCP video frames we can (at the regular DCP frame rate). Hopefully this will solve a range of sync problems, but it could also introduce new ones. --- src/lib/ffmpeg_decoder.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/lib/ffmpeg_decoder.cc') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 43b9a1bb3..6a1e0b642 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -144,11 +144,10 @@ FFmpegDecoder::flush () full_length = full_length.ceil (frc.source); if (video) { double const vfr = _ffmpeg_content->video_frame_rate().get(); - auto const f = full_length.frames_round (vfr); - auto v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1; - while (v < f) { - video->emit (film(), make_shared(_black_image), v); - ++v; + auto v = video->position(film()).get_value_or(ContentTime()) + ContentTime::from_frames(1, vfr); + while (v < full_length) { + video->emit(film(), make_shared(_black_image), v); + v += ContentTime::from_frames(1, vfr); } } @@ -591,7 +590,7 @@ FFmpegDecoder::process_video_frame () video->emit ( film(), make_shared(image), - llrint(pts * _ffmpeg_content->active_video_frame_rate(film())) + ContentTime::from_seconds(pts) ); } else { LOG_WARNING_NC ("Dropping frame without PTS"); -- cgit v1.2.3