Bug: Infinite export when looping background music on videos without original audio
Description
If a user uploads a video that has no audio track (or mutes the original audio so hasOriginalAudio === false) and adds a background music track with “Loop Music” enabled, the export process never finishes.
The FFmpeg process continues indefinitely, eventually:
- crashing the browser tab, or
- generating an extremely large/unplayable output file.
Steps to Reproduce
- Upload a video with no audio track
OR mute the original audio so hasOriginalAudio evaluates to false
- Add a background music track
- Enable “Loop Music”
- Export the video
Expected Behavior
The export should stop when the video duration ends and produce a valid output file.
Actual Behavior
The export runs indefinitely because the looped audio stream never terminates.
Root Cause
In src/lib/ffmpeg.ts inside buildArguments:
- When
loopMusic is enabled, the background music input is prefixed with:
Bug: Infinite export when looping background music on videos without original audio
Description
If a user uploads a video that has no audio track (or mutes the original audio so
hasOriginalAudio === false) and adds a background music track with “Loop Music” enabled, the export process never finishes.The FFmpeg process continues indefinitely, eventually:
Steps to Reproduce
OR mute the original audio so
hasOriginalAudioevaluates tofalseExpected Behavior
The export should stop when the video duration ends and produce a valid output file.
Actual Behavior
The export runs indefinitely because the looped audio stream never terminates.
Root Cause
In
src/lib/ffmpeg.tsinsidebuildArguments:loopMusicis enabled, the background music input is prefixed with: