navidrome/core/ffmpeg
Deluan c05fbd0edb fix(transcoding): declare the duration of a piped mp3 transcode
The mp3 muxer writes the Xing frame that carries the frame count only after
rewinding to the start of the stream, which it cannot do on a pipe (-f mp3 -).
An uncached transcode therefore declares its length nowhere: no Xing frame, and
no Content-Length unless the client asks for the estimate. A decoder has to
guess the duration from the bytes it has so far, and an offline copy stays
unseekable, the same defect #6105 fixed for FLAC.

Transcode now inserts a Xing frame ahead of the first audio frame, carrying the
frame count derived from the track duration. Only the frame count is declared:
a piped encode cannot know its own byte size, and a wrong size is worse than an
absent one. Decoded audio is unchanged, since decoders skip the tag frame.

Measured on a 20s 128kbps transcode: ffprobe reports 20.010s instead of
20.036s, and Firefox reports 19.998s at loadedmetadata instead of 2.04s
climbing over nine durationchange events. This does not make an uncached
transcode resumable; that needs range support, which only the cache path has.

Reported in #6170.
2026-09-24 17:16:04 -04:00
..
ffmpeg.go fix(transcoding): declare the duration of a piped mp3 transcode 2026-09-24 17:16:04 -04:00
ffmpeg_test.go fix(transcoding): declare the duration of a piped mp3 transcode 2026-09-24 17:16:04 -04:00
flac_streaminfo.go fix(transcoding): make piped FLAC transcodes seekable 2026-09-07 16:47:42 -04:00
flac_streaminfo_test.go fix(transcoding): make piped FLAC transcodes seekable 2026-09-07 16:47:42 -04:00
mp3_xing.go fix(transcoding): declare the duration of a piped mp3 transcode 2026-09-24 17:16:04 -04:00
mp3_xing_test.go fix(transcoding): declare the duration of a piped mp3 transcode 2026-09-24 17:16:04 -04:00