mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-24 10:10:05 -06:00
Problem: ffmpeg stores the encoder priming as CodecDelay in ns (1024 AAC samples at 48 kHz = 21.333 ms, 256 AC-3 samples at 44.1 kHz = 5.805 ms) and block timestamps in ms. The demuxer subtracts the delay rounded to 1 ms, and fixed-length packets were anchored on that rounded stamp, so the whole track played up to 16 samples late against ffmpeg's decode. Only Opus undid the rounding. Fix: one stamp-to-samples conversion for every Matroska audio codec that undoes the demuxer's rounding and removes the exact CodecDelay (rounded to the nearest sample; the element holds whole ns), with checked math against hostile timebases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>