mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
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:
parent
e4c49a1e78
commit
82fbefce0c
1 changed files with 4 additions and 11 deletions
|
|
@ -45,17 +45,10 @@ pub fn calculate_target_time(frame: &LtcFrame, config: &Config) -> DateTime<Loca
|
|||
let timecode_secs =
|
||||
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.
|
||||
// We must convert the entire timecode to a frame count using the nominal rate (e.g. 30),
|
||||
// and then divide by the true fractional rate to get real wall-clock seconds.
|
||||
// For integer rates or drop-frame, the components can be summed directly as they represent real time.
|
||||
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
|
||||
};
|
||||
// Timecode is always treated as wall-clock time. NDF scaling is not applied
|
||||
// as the LTC source appears to be pre-compensated.
|
||||
let total_duration_secs =
|
||||
Ratio::new(timecode_secs, 1) + Ratio::new(frame.frames as i64, 1) / frame.frame_rate;
|
||||
|
||||
// Convert to milliseconds
|
||||
let total_ms = (total_duration_secs * Ratio::new(1000, 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue