Video is only half the edit. Whether you are adding background music under a voiceover, layering sound effects, or combining several microphones, FFmpeg's amix filter mixes any number of audio streams into one — and it lives in the same filter_complex graph as your video effects.
Key takeaways
amixsums multiple audio inputs into a single track.- Set
inputs=Nand balance withweightsor per-inputvolume. amergecombines tracks into multi-channel audio (not a level mix).sidechaincompressducks music under a voiceover automatically.- Use
acrossfadeto blend between two songs.
The simplest mix
Mix a video's original audio with a music file. amix normalizes by the number of inputs, so quieter is expected — we fix levels next:
ffmpeg -i video.mp4 -i music.mp3 -filter_complex " [0:a][1:a]amix=inputs=2:duration=longest[a] " -map 0:v -map "[a]" -c:v copy out.mp4
Balancing levels with volume and weights
To keep dialog up front and music underneath, drop the music's volume before mixing, or use amix's weights:
# music at 25% under full-volume voice [1:a]volume=0.25[bg]; [0:a][bg]amix=inputs=2:duration=first[a] # or weight the mix directly [0:a][1:a]amix=inputs=2:weights=1 0.3[a]
Use duration=first so the render ends with your narration, not a trailing music tail.
Automatic ducking with sidechaincompress
The professional move: have the music duck automatically whenever the voice is talking. sidechaincompress uses the voice track as a trigger to compress the music:
[1:a][0:a]sidechaincompress= threshold=0.03:ratio=8:attack=20:release=300[duck]; [0:a][duck]amix=inputs=2[a]
amix vs amerge
They are easy to confuse. amix sums signals into one track at the same channel layout — a true level mix. amerge stacks inputs into a multi-channel stream (e.g. two mono mics into a stereo file). Reach for amerge when you want to preserve separate channels, and amix when you want them blended.
Crossfading between songs
To transition from one track to another, use acrossfade — the audio counterpart to the video xfade transition:
ffmpeg -i song_a.mp3 -i song_b.mp3 -filter_complex " [0:a][1:a]acrossfade=d=4:c1=tri:c2=tri[a] " -map "[a]" mix.mp3
Unlimited channels, visually
FFmpegLab exposes unlimited audio channels in a real timeline and mixes them with amix under the hood — drop in music, narration, and effects, set levels, and read the exact generated command. It runs offline and private in your browser and is self-hostable with Docker.