fix(video): transcode audio to AAC for MP4 streaming (PCM unsupported in MP4)

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 00:18:41 -04:00
co-authored by Copilot
parent 51322d0e00
commit a3659e8a8c
+5 -4
View File
@@ -150,14 +150,15 @@ def local_video_file():
except FileNotFoundError: except FileNotFoundError:
return jsonify(error=f"Local video not found: {relative_path}"), 404 return jsonify(error=f"Local video not found: {relative_path}"), 404
# Stream via ffmpeg: copy streams into an MP4 container with moov atom first # Stream via ffmpeg: copy video, transcode audio to AAC (PCM not supported
# so browsers can start playback immediately without downloading the whole file. # in MP4), output as fragmented MP4 so browser plays without full download.
def generate_stream(): def generate_stream():
cmd = [ cmd = [
"ffmpeg", "-nostdin", "-loglevel", "error", "ffmpeg", "-nostdin", "-loglevel", "error",
"-i", path, "-i", path,
"-c", "copy", # no re-encode, just remux "-c:v", "copy",
"-movflags", "frag_keyframe+empty_moov+faststart", "-c:a", "aac",
"-movflags", "frag_keyframe+empty_moov",
"-f", "mp4", "-f", "mp4",
"pipe:1", "pipe:1",
] ]