Commits
Commits on
978e6857d64772912559c8d8a4e6ee7cd309bdccFiltered to crates/engine/examples/seek_dump.rsClear filter2026-08-12
🐛 fix(audio): a seek into a Matroska lands on the second it asked forAhmet Kaan Gümüş · 702501a
🐛 fix(audio): a seek into a Matroska lands on the second it asked for A film played 1.47 s further in than the timeline said after a scrub to 600 s, 3.39 s after one to 610 s -- sound against picture, the oldest complaint in this project, and the Matroska half of the mp4 fps truncation that was fixed once and never swept. One symphonia mkv seek does not land where it is asked to. It goes through the cue table and stops at the first frame at or *past* the cue's cluster: asking for 599.83 s on a 2h+ AV1/Opus 5.1 mkv landed the reader at 601.487 s, asking for 609.83 s at 613.407 s, and on the new 30 s fixture asking for 25 s lands at 29.987 s. Samples that far behind a reader cannot be reached by any window rule downstream, so `emit` had nothing to trim and the film simply played from the landing while the clock counted from the request. So the landing is read back and an overshoot is asked again from far enough before it to swallow the overshoot, and every attempt gets a *new reader* -- symphonia's mkv seek is reliable exactly once per reader: it hands out the frames it had already queued (they arrive carrying the old block's timestamp) and its element iterator does not recover, so a second seek on one reader landed back at the file's first cluster, 0.094 s, whatever it was asked for. That is a *clip* of a film, and at HEAD the second clip of a two-clip timeline came out with no audio at all. Opening again costs 2 ms on a 5 GB film. Seeking to the beginning is now not seeking: that seek is how the first 167 ms of the same film went missing at open, and 2.35 s more of it at 27 s, where the iterator left inside a cue's cluster ran on into the wrong one. Two smaller things the trimming needed to be right at all. A packet's own timestamp cannot carry the decode position: the frames of one laced block all share the block's, so the position accumulates from the decoder's count between blocks, which is what both mp4 readers here already do. And the pre-skip comes off a landing timestamp, because an Opus track's blocks are timestamped for the audible stream while the decoder hands its samples back with the pre-skip still in front of them -- 6.5 ms, measured. Measured against an ffmpeg decode of the same window, envelope correlation, real files. A 2h+ AV1/Opus 5.1 mkv at 600/610/1200/5400/6000 s: +1.474/+3.393/+0.094/+0.073/+0.094 s before, ≤1 ms after. An HEVC/AAC 5.1 mkv at 610 and 1200 s: +2.054/+1.856 before, 0.000 after. An H.264/AAC mkv and an AC-3 mp4 were already exact and stay exact -- the mp4 tables never had this to get wrong. A/V skew after a seek on the AV1 mkv: -0.007 s at 600 s, -0.005 s at 5400 s. The video path was measured at the same four positions and lands on the requested frame.