summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-08-02 22:24:05 +0200
committerCarl Hetherington <cth@carlh.net>2020-08-02 22:24:05 +0200
commitaf680761cf7c3e97660e8e55c68f42e90b026bf9 (patch)
tree3245845f36c214023e936fce104c49b91168685c /src/lib/ffmpeg_content.cc
parenta0545f58b3e90d3c09fa376900eafd6f8fb531cb (diff)
Detect soft 2:3 pulldown (telecine) files and decode them at 23.976.
DVD rips from NTSC DVDs are sometimes (always?) encoded using soft 2:3 pulldown. The video frames are actually 23.976 but FFmpeg detects them as 29.97. With the current approach of the video decoder ignoring most PTSs and assuming a constant frame rate it is vital that the file contains the number of frames per second that the detected frame rate predicts. This fixes large sync errors with NTSC DVD rips (#1790).
Diffstat (limited to 'src/lib/ffmpeg_content.cc')
-rw-r--r--src/lib/ffmpeg_content.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index f3c0d01cb..1fb95535f 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -337,6 +337,14 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
set_default_colour_conversion ();
}
+ if (examiner->has_video() && examiner->pulldown() && video_frame_rate() && fabs(*video_frame_rate() - 29.97) < 0.001) {
+ /* FFmpeg has detected this file as 29.97 and the examiner thinks it is using "soft" 2:3 pulldown (telecine).
+ * This means we can treat it as a 23.976fps file.
+ */
+ set_video_frame_rate (24000.0 / 1001);
+ video->set_length (video->length() * 24.0 / 30);
+ }
+
#ifdef DCPOMATIC_VARIANT_SWAROOP
_id = examiner->id ();
#endif