Skip to content

Commit 5dddc32

Browse files
committed
fix: route FLAC clip extraction through temp file to fix corrupted headers
FLAC output to pipe (pipe:1) produces broken STREAMINFO headers because FFmpeg cannot seek back to finalize the total sample count, min/max frame sizes, and MD5 checksum. This caused exported FLAC files to have zeroed metadata fields and corrupted audio on playback. Fix by adding FormatFLAC to requiresSeekableOutput so clip extraction uses a temporary file, same as AAC and ALAC already do.
1 parent 1dc439d commit 5dddc32

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/myaudio/ffmpeg_clip.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ var supportedClipFormats = map[string]bool{
4545

4646
// requiresSeekableOutput lists formats whose muxers cannot write to a pipe.
4747
// MP4-based containers (AAC → mp4, ALAC → ipod) need seekable output to
48-
// write the moov atom, so we route them through a temporary file.
48+
// write the moov atom. FLAC needs seekable output to finalize the STREAMINFO
49+
// header (total sample count, min/max frame sizes, MD5 checksum). Without it,
50+
// these fields are zeroed and players may reject or misinterpret the file.
4951
var requiresSeekableOutput = map[string]bool{
5052
FormatAAC: true,
5153
FormatALAC: true,
54+
FormatFLAC: true,
5255
}
5356

5457
// IsSupportedClipFormat returns true if the format is supported for clip extraction.

0 commit comments

Comments
 (0)