From af6210082cb3bd93ce69039522e7dbcaaeb64968 Mon Sep 17 00:00:00 2001 From: gramps Date: Thu, 12 Nov 2026 14:09:55 -0800 Subject: [PATCH] fix(tools): a negative lip-sync offset shortens the audio track by design MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The length check called -74 ms of audio a clock problem on a clip recorded with the global offset at -100. Trimming the stream head to advance the mix removes exactly that much track, so the mismatch is the feature working. The verdict now says so instead of sending the next hour after a clock that is fine. Same clip: correlation +30 ms (two windows above 0.55), clap contact +34 ms — the two methods agree, so the offset needs -130 rather than -100. --- scripts/avsync.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/avsync.py b/scripts/avsync.py index 32189da..d453194 100644 --- a/scripts/avsync.py +++ b/scripts/avsync.py @@ -219,8 +219,11 @@ def main() -> int: print(f"video {video:8.3f} s") print(f"audio {audio:8.3f} s") print(f"delta {diff:+8.3f} s ({pct:+.2f}% of the video length)") - verdict = "lengths match" if abs(diff) < 0.05 else "LENGTH MISMATCH — a clock problem" - print(f" {verdict}") + if abs(diff) < 0.05: + print(" lengths match") + else: + print(" LENGTH MISMATCH — a clock problem, UNLESS a negative lip-sync offset is set:") + print(f" trimming the stream head by N ms makes the audio track N ms shorter by design") for start, wlag, wcorr in windows: mark = "*" if wcorr >= 0.35 else " " print(f" {start:5.1f}s {wlag:+7.0f} ms corr {wcorr:.2f} {mark}")