mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
* Account for multi-frame Opus packets when computing packet duration parseOpusTocByte only read the config field of the TOC byte and always assumed a single frame per packet. Per RFC 6716 section 3.2, a packet may carry 1, 2 or an arbitrary number of frames, encoded in the two low bits of the TOC byte (plus the frame count byte for code 3), and its duration is the frame duration times the frame count. As a result, the Ogg muxer wrote granule positions that advanced slower than the actual audio. Chromium's MediaRecorder packs three 20 ms frames per Opus packet, so remuxing WebM/Opus to Ogg/Opus produced files declaring a third of their real duration: a 5.7 s recording ended with a final granule position of 99840 (2.08 s). Decoders that trust the container then truncate the audio. * Clean up --------- Co-authored-by: Vanilagy <[email protected]>