summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-29 10:17:50 +0200
committerCarl Hetherington <cth@carlh.net>2022-10-12 09:40:37 +0200
commit835dd8938830b615d5b3e66272eb56d60bf7c45f (patch)
treed25af025bf4a33ed02dbce42e5515487a67f4f98 /src/lib/ffmpeg_decoder.cc
parent1ecdc81645686fcc5a8fb2cb55313d2ca5d1d4a8 (diff)
Change how video timing is done.v2.17.3
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.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index d4a5d6c19..765b9fa62 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -143,11 +143,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<const RawImageProxy>(_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<const RawImageProxy>(_black_image), v);
+ v += ContentTime::from_frames(1, vfr);
}
}
@@ -611,7 +610,7 @@ FFmpegDecoder::process_video_frame ()
video->emit (
film(),
make_shared<RawImageProxy>(image),
- llrint(pts * _ffmpeg_content->active_video_frame_rate(film()))
+ ContentTime::from_seconds(pts)
);
} else {
LOG_WARNING_NC ("Dropping frame without PTS");