fix: Remove NDF timecode scaling for pre-compensated LTC source

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
Chris Frankland-Wright 2025-08-05 21:05:46 +01:00
parent e4c49a1e78
commit 82fbefce0c

View file

@ -45,17 +45,10 @@ pub fn calculate_target_time(frame: &LtcFrame, config: &Config) -> DateTime<Loca
let timecode_secs = let timecode_secs =
frame.hours as i64 * 3600 + frame.minutes as i64 * 60 + frame.seconds as i64; frame.hours as i64 * 3600 + frame.minutes as i64 * 60 + frame.seconds as i64;
// For non-drop-frame fractional rates (23.98, 29.97), timecode runs slower than wall clock. // Timecode is always treated as wall-clock time. NDF scaling is not applied
// We must convert the entire timecode to a frame count using the nominal rate (e.g. 30), // as the LTC source appears to be pre-compensated.
// and then divide by the true fractional rate to get real wall-clock seconds. let total_duration_secs =
// For integer rates or drop-frame, the components can be summed directly as they represent real time. Ratio::new(timecode_secs, 1) + Ratio::new(frame.frames as i64, 1) / frame.frame_rate;
let total_duration_secs = if *frame.frame_rate.denom() == 1001 && !frame.is_drop_frame {
let nominal_rate = if *frame.frame_rate.numer() > 25000 { 30 } else { 24 }; // 30 for 29.97, 24 for 23.98
let total_frames = timecode_secs * nominal_rate + frame.frames as i64;
Ratio::new(total_frames, 1) / frame.frame_rate
} else {
Ratio::new(timecode_secs, 1) + Ratio::new(frame.frames as i64, 1) / frame.frame_rate
};
// Convert to milliseconds // Convert to milliseconds
let total_ms = (total_duration_secs * Ratio::new(1000, 1)) let total_ms = (total_duration_secs * Ratio::new(1000, 1))