Skip to content

[BUG] Export Can Hang Indefinitely When Video Has No Audio and Background Music Is Looped #1493

Open

Description

@Krishnx21

When exporting a video that contains no original audio track, the export pipeline falls back to a music-only audio path.

If a background music track is longer than the video duration, or if "Loop Music" is enabled, the generated FFmpeg command may continue encoding indefinitely because the output is not constrained by the video duration.

This can result in:

  • Infinite export operations
  • Browser tab freezes
  • Excessive memory consumption
  • Potential Out-of-Memory (OOM) crashes
  • Output videos significantly longer than the source video

Steps to Reproduce

  1. Import a video file that contains no audio stream.
  2. Add a background music track.
  3. Enable Loop Music OR use a music track longer than the video.
  4. Export the video.
  5. Observe the export process.

Expected Behavior

The exported video should end when the video stream ends.

Examples:

  • 10-second video + 3-minute music track → 10-second export.
  • 10-second video + looped music → 10-second export.

Actual Behavior

When the fallback music-only path is used:

  • FFmpeg maps the music stream directly.
  • The output duration becomes controlled by the audio stream.
  • Looped music can cause export to continue indefinitely.
  • Long music tracks can extend the final output far beyond the video duration.
  • The final frame may remain frozen while audio continues playing.

Root Cause

The fallback branch used when the source video has no audio bypasses the audio-mixing path.

Generated commands resemble:

ffmpeg -i input.mp4 \
-stream_loop -1 \
-i music.mp3 \
-filter_complex "[0:v]...[vout];[1:a]volume=0.70[aout]" \
-map "[vout]" \
-map "[aout]" \
output.mp4

Because the command does not include:

-shortest

FFmpeg continues processing until the audio stream finishes.

For looped audio (-stream_loop -1) this can become effectively infinite.

Impact

Severity: High

Potential consequences:

  • Infinite export jobs
  • Browser crashes
  • Memory exhaustion
  • Corrupted user experience
  • Unexpected output durations

Suggested Fix

Append:

-shortest

to the final FFmpeg output arguments so encoding terminates when the video stream ends.

Example:

args.push("-shortest");

before the output filename is appended.

Environment

  • Browser: Any
  • Platform: Web
  • FFmpeg WASM Export Pipeline
  • File: src/lib/ffmpeg.ts

ASSIGN TO ME UNDER GSSOC2026

Activity

  1. added
    bugSomething isn't working correctly
    on Jun 2, 2026
  2. github-actions commented on Jun 2, 2026

    @github-actions
    Contributor

    👋 Thanks for opening an issue, @Krishnx21!

    Our maintainers will review this shortly 🚀

    Before you start working

    • 📖 Read the CONTRIBUTING.md guide
    • 💬 Wait for a maintainer to assign you the issue before starting work
    • 🔍 Search for existing issues to avoid duplicates

    For GSSoC'26 contributors

    If you're contributing under GirlScript Summer of Code 2026, please mention it in your comment when requesting assignment:

    "I'd like to work on this — contributing under GSSoC'26"

    Architecture notes

    Reframe is a static Next.js app with output: "export". Key points:

    • All video processing uses FFmpeg.wasm (client-side, no server)
    • headers() in next.config.ts won't work — use vercel.json instead
    • not-found.tsx requires public/404.html + vercel.json routes config

    Happy contributing! ⭐ Star the repo if you find it useful!

  3. Krishnx21 commented on Jun 2, 2026

    @Krishnx21
    Author

    /ASSIGN/GSSOC2026

  4. github-actions commented on Jun 2, 2026

    @github-actions
    Contributor

    Hey @Krishnx21, this issue has been assigned to you! 🎉 Please make progress within 5 days or it will be automatically unassigned due to inactivity.

  5. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    Hey @Krishnx21, just a friendly reminder that this issue has had no activity for 2 days. Please leave an update or let us know if you need help! ⏰

  6. github-actions commented on Jun 8, 2026

    @github-actions
    Contributor

    Hey @Krishnx21, final warning! ⚠️ This issue has had no activity for 4 days and will be automatically unassigned in 24 hours if there is no update.

  7. github-actions commented on Jun 13, 2026

    @github-actions
    Contributor

    This issue has been unassigned from @Krishnx21 due to 5 days of inactivity and is open for anyone to pick up — comment /assign to claim it!

  8. Saylee12R commented on Jun 20, 2026

    @Saylee12R

    /assign

    I'd like to work on this issue under GSSoC'26.

  9. github-actions commented on Jun 20, 2026

    @github-actions
    Contributor

    Hey @Saylee12R, this issue has been assigned to you! 🎉 Please make progress within 5 days or it will be automatically unassigned due to inactivity.

  10. github-actions commented on Jun 25, 2026

    @github-actions
    Contributor

    This issue has been unassigned from @Saylee12R due to 5 days of inactivity and is open for anyone to pick up — comment /assign to claim it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlytype:bugBug fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions