The footage is right, the silence is wrong. Music carries a video's energy — but bolting it on means answering three questions: what happens to the original audio, how loud should each track sit, and what are the licensing rules for the music you picked.
The three recipes
1. Replace the original audio entirely
For clips where ambient sound adds nothing (screen recordings, timelapses, B-roll):
```bash ffmpeg -i video.mp4 -i music.mp3 -map 0:v -map 1:a -c:v copy -c:a aac -b:a 192k -shortest out.mp4 ```
`-map 0:v -map 1:a` takes video from file 1, audio from file 2. `-c:v copy` skips video re-encoding (instant, lossless); `-shortest` ends the output when the shorter input finishes — the flag that stops 3 minutes of silence after your 20-second clip.
2. Mix music under existing audio (the standard)
Keep the dialogue, add atmosphere underneath:
```bash ffmpeg -i video.mp4 -i music.mp3 -filter_complex \ "[1:a]volume=0.25[m];[0:a][m]amix=inputs=2:duration=first[a]" \ -map 0:v -map "[a]" -c:v copy -c:a aac out.mp4 ```
`volume=0.25` ducks the music to a quarter — background level for speech-heavy content. `duration=first` ends the mix with the video. The eternal mixing question is balance: voice tracks sit near -6 dB peaks, music beds 15-20 dB below — the 0.2-0.3 volume range approximates that without a mixer.
3. Duck the music automatically when speech plays
The podcast trick, automated:
```bash ffmpeg -i video.mp4 -i music.mp3 -filter_complex \ "[0:a]asplit=2[voice][detect];[detect]pan=mono|c0=c0[side];\ [1:a][side]sidechaincompress=threshold=0.05:ratio=8[duck];\ [voice][duck]amix=inputs=2:duration=first[a]" \ -map 0:v -map "[a]" -c:v copy out.mp4 ```
The voice track sidechain-compresses the music: when you speak, music dips; when you stop, it rises. Tunable via threshold and ratio. This is what live-streamers and podcasters pay plugins for — FFmpeg ships it free.
Volume control: the numbers that matter
- `volume=1.0` original, `0.5` half, `2.0` double - Music beds: 0.2-0.3 under speech, 0.6-0.8 for music-forward montage - Loudness sanity: `-af "loudnorm"` normalizes a mixed track to broadcast-ish level — a good final polish for uploads
Making the music loop or fit
Clip longer than the track? Loop the music first (see our looping guide — the concat trick on the audio file), then mix. Track longer than clip: `-shortest` or trim with `-t`. Fade out at the end: add `afade=t=out:st=<end-2>:d=2` to the music chain — an abrupt music stop is the tell of an unfinished edit.
The licensing question you can't skip
Music you "found" is usually not yours to publish:
- **YouTube/Instagram Content ID** will flag, monetize, or mute your upload for copyrighted tracks - **Safe sources**: the platforms' own audio libraries, CC-licensed music (check the exact license), royalty-free purchases, or original composition - "No copyright intended" in the description is not a legal position — it's a confession
For anything commercial, keep a license record per track. The ten minutes that costs beats the takedown it prevents.
The takeaway
`-map 0:v -map 1:a -c:v copy -shortest` replaces; `amix` with `volume=0.25` mixes under; sidechain ducking does it automatically. Music at a quarter of voice level, fading out at the end, from a licensed source — that's the complete formula.
No comments yet