Skip to content

fix(ffmpeg): keep background music track when original audio is muted (#1579) - #1813

Open
Tarulatapriya wants to merge 1 commit into
reframe-oss:mainfrom
Tarulatapriya:fix/keep-music-when-muted
Open

Tarulatapriya wants to merge 1 commit into
reframe-oss:mainfrom
Tarulatapriya:fix/keep-music-when-muted

Conversation

@Tarulatapriya

Copy link
Copy Markdown
Contributor

Summary of Changes

Fixes #1579.

Currently, hasMusicTrack in the export pipeline was coupled to recipe.keepAudio (!!(request.musicFile && recipe.keepAudio)), and shouldKeepAudio was similarly requiring recipe.keepAudio to be true. As a consequence, if a user muted the original video audio (keepAudio = false), their uploaded background music was completely discarded, and the exported video was silent.

This PR decouples custom background music from the video's original audio mute state:

  1. Worker & Export pipeline:
    • hasMusicTrack now strictly reflects whether a music track was uploaded (!!request.musicFile).
    • shouldKeepAudio is updated to (recipe.keepAudio && hasOriginalAudio) || hasMusicTrack so audio streams and codecs are preserved whenever background music is present.
    • When hasMusicTrack is present:
      • If recipe.keepAudio && hasOriginalAudio is true, mixes both tracks via amix.
      • If recipe.keepAudio is false (original audio muted), routes the custom background music directly to [aout] as the sole audio track.
  2. Unit Tests:
    • Added unit tests in src/lib/tests/ffmpeg.test.ts verifying argument generation when:
      • keepAudio: false + custom background music (music retained as sole track, no -an, audio codec mapped).
      • keepAudio: true + custom background music (mixed).
      • keepAudio: false + no background music (-an used to mute completely).

Testing

  • Ran test suite with npx vitest run src/lib/tests/ffmpeg.test.ts — all 12 tests passed.

@netlify

netlify Bot commented Oct 18, 2026

Copy link
Copy Markdown

👷 Deploy request for reframe-os pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5d624f8

@github-actions github-actions Bot added level:intermediate Intermediate level - 35 pts type:bug Bug fix type:testing Testing labels Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Tarulatapriya!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. ✅ Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Format Check Passed — @Tarulatapriya

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

This branch has not been deployed

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

Labels

level:intermediate Intermediate level - 35 pts type:bug Bug fix type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Muting the video (keepAudio=false) accidentally drops the uploaded background music track

1 participant