amix=inputs=2:duration=first:weights=1 0.25:normalize=0 lays music under a voice at a quarter level and stops when the voice does. On ReelSDK that mix costs under a fifth of a cent, billed at $0.02 per compute minute.

Mix two audio tracks with ffmpeg

Three amix defaults ruin a voice-over: an 11-second voice plus a 2.5-minute song comes out 2.5 minutes long, both tracks turned down. ReelSDK's API delivers the fixed mix in under 4 seconds.

GuidesUpdated

mix
ffmpeg -i in.mp4 -i music.mp3 -filter_complex \
  "[0:a][1:a]amix=inputs=2:duration=first:weights=1 0.25:normalize=0[a]" \
  -map 0:v -map "[a]" -c:v copy -c:a aac -b:a 192k mixed.mp4

Ends with the voice, keeps both at their real level, and plays the music at 0.25, about 12 dB down. The video is copied.

Variations

The other commands you will need

  1. The same with volume

    Turning the music down before the mix measures exactly the same loudness, and works with any filter that follows.

    volume first
    ffmpeg -i in.mp4 -i music.mp3 -filter_complex \
      "[1:a]volume=0.25[m];[0:a][m]amix=inputs=2:duration=first:normalize=0[a]" \
      -map "[a]" -c:a aac volume.m4a
  2. Channels side by side with amerge

    amerge does not mix; it stacks channels. Two stereo inputs give one 4-channel stream, and pan folds that back to stereo.

    amerge
    ffmpeg -i in.mp4 -i music.mp3 -filter_complex \
      "[0:a][1:a]amerge=inputs=2,pan=stereo|c0=c0+c2|c1=c1+c3[a]" \
      -map "[a]" -t 10 -c:a aac stereo.m4a

The flags

The options in these commands

The options in these commands
FlagWhat it doesUsed here
inputs=2Number of tracks to mix; 2 is the defaultMix
duration=firstEnds with the first input; the default is the longestMix, volume
weights=1 0.25Level of each input, in order; the default is 1 for allMix
normalize=0Adds the inputs as they are instead of scaling them downMix, volume
volume=0.25Scales one track before the mixVolume
amerge=inputs=2Puts the channels of both inputs into one streamamerge
pan=stereo|c0=c0+c2|c1=c1+c3Builds stereo: left from channels 0 and 2, right from 1 and 3amerge

Sources: ffmpeg filters: amix, ffmpeg filters: amerge, ffmpeg filters: pan, checked November 2026.

Default 1: the mix runs as long as the song

duration defaults to longest. With our 11-second voice and a song of about 2.5 minutes, plain amix wrote the whole 2.5 minutes. Set duration=first and put the track that sets the length first. For a video, that is usually the voice.

Default 2: everything gets quieter

With normalize on, which is the default, amix scales the inputs down so the sum cannot clip. With two tracks, each is halved. Turning it off with normalize=0 made our mix about 6 LU louder, which is what the voice alone should sound like with music added.

The ffmpeg docs warn that turning it off can clip if the inputs are already loud. Keep the music down and check the true peak: ours ended just under 0 dB, inside the limit. For a fixed target, finish with loudnorm.

Default 3: every track at the same level

weights sets a level per input, in order, and the last weight is used for any inputs left over. weights=1 0.25 keeps the voice and puts the music at a quarter, about 12 dB down. A volume=0.25 on the music before the mix measured exactly the same loudness.

If the music should drop only while someone speaks, a fixed level is not enough. Use a sidechain compressor: see audio ducking.

amerge is not a mix

amerge keeps every channel. Two stereo files become one 4-channel stream that most players will not handle well, so follow it with pan to decide which channels go left and right. Use it for things like turning two mono recordings into one stereo file.

amerge is also strict about formats. With aresample on both inputs it failed with "The following filters could not choose their formats: Parsed_amerge_2". Adding aformat=channel_layouts=stereo to each input gave it a fixed layout and the error went away.

Without installing ffmpeg

The same command as one API call

Send the same args to POST /v1/ffmpeg with both URLs in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished in under 4 seconds and cost under a fifth of a cent.

terminalTry it
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
  -H "Authorization: Bearer $REELSDK_KEY" \
  --json '{
    "inputs": {
      "in.mp4": "https://api.reelsdk.com/f/lib/demo/clip.mp4",
      "music.mp3": "https://api.reelsdk.com/f/lib/music/chill/calm-currents.mp3"
    },
    "args": [
      "-i", "in.mp4", "-i", "music.mp3", "-filter_complex",
      "[0:a][1:a]amix=inputs=2:duration=first:weights=1 0.25:normalize=0[a]",
      "-map", "0:v", "-map", "[a]", "-c:v", "copy", "-c:a", "aac", "-b:a",
      "192k", "mixed.mp4"
    ],
    "outputs": ["mixed.mp4"]
  }'
Voice at full level, music at 0.25, cut to the length of the voice.Input: 10.7-second clipmusic.mp3 (147.6 s)

FAQ

Questions, answered

How do I mix two audio files with ffmpeg?

Use ffmpeg -i a.mp3 -i b.mp3 -filter_complex "[0:a][1:a]amix=inputs=2:duration=first:normalize=0[a]" -map "[a]" out.m4a. Set weights to change the balance.

Why is my amix output so quiet?

amix normalizes by default and halves each of two inputs. Add normalize=0; in our test that made the mix about 6 LU louder.

Why is my mixed file as long as the music?

duration defaults to longest. Put the voice first and add duration=first.

Can I mix audio with an API?

Yes. POST the same args to https://api.reelsdk.com/v1/ffmpeg with both file URLs in inputs. It runs ffmpeg 8.1 for $0.02 per compute minute, billed per second.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains