>FFmpegLab Start free
FFmpeg Guide

Mixing audio in FFmpeg with amix

Layer background music under a voiceover, blend sound effects, and balance levels — all from the command line. This guide covers amix, amerge, per-track volume, sidechain ducking, and audio crossfades.

Mix audio without the command-line guesswork.

Free in your browser — nothing to install, nothing uploaded.

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

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:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
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:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
# 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:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
[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:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
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.

✦  Fresh from the render queue

Better FFmpeg workflows, delivered.

Get practical commands, new templates, and deep-dive guides for the edits that are usually hardest to get right.

✓  Copy-pasteable commands    ✓  Editor templates    ✓  No noise
One useful email at a time.

Mix audio without the command-line guesswork.

Free in your browser — nothing to install, nothing uploaded.