fix: use fragmented MP4 for crash-safe HLS live stream recording

-movflags +faststart requires ffmpeg to write moov atom at the end,
which fails when SIGINT interrupts a live HLS recording — the mp4
file has no moov atom and is unplayable (0 bytes effective).

Switch to -movflags +frag_keyframe+empty_moov+default_base_moof
(fragmented MP4): moov atom written immediately at file start,
each segment is self-contained. Even if ffmpeg is killed mid-recording,
the file remains fully playable with both video and audio intact.

Verified: HLS live stream (CBS News) → 45s 1280x720 h264 + AAC 48kHz,
13MB, SIGINT-safe. Local files unaffected.
This commit is contained in:
yumoqing 2026-06-29 23:58:31 +08:00
parent 7263f2d837
commit 68806e1190

View File

@ -59,7 +59,7 @@ public final class FFmpegRecorder: StreamRecorderEngine {
"-c:v", "copy",
"-c:a", "aac",
"-b:a", "192k",
"-movflags", "+faststart",
"-movflags", "+frag_keyframe+empty_moov+default_base_moof",
outputPath
]
proc.arguments = args