// Timebase convention (FROZEN CONTRACT) — the JS mirror of backend/festival4d/config.py // (`t_video_from_global` / `t_global_from_video`). Keep these identical to the Python side. // // t_global is the master timeline in seconds. For a video v: // t_video = (t_global - offset_ms/1000) * (1 + drift_ppm * 1e-6) // The reference video has offset_ms == 0 (and drift_ppm == 0). A positive offset_ms means // the video started recording later than the master zero, so at a given t_global its local // playhead is earlier. Never re-derive this algebra inline — call these helpers everywhere. /** Master-timeline seconds -> a video's local playhead seconds (FROZEN). */ export function tVideoFromGlobal(tGlobal, offsetMs, driftPpm = 0) { return (tGlobal - offsetMs / 1000) * (1 + driftPpm * 1e-6); } /** Inverse of tVideoFromGlobal (FROZEN). */ export function tGlobalFromVideo(tVideo, offsetMs, driftPpm = 0) { return tVideo / (1 + driftPpm * 1e-6) + offsetMs / 1000; }