Mix Multiple Audio Tracks with Delay in FFmpeg

This article explains how to mix multiple audio files at specific start times using FFmpeg. While the amix filter combines multiple audio streams into a single output, it starts all inputs simultaneously by default. To introduce custom start times, you must combine amix with the adelay filter. Below, you will find the exact command-line syntax, filter explanations, and configuration options to achieve this.

The Core Concept: Combining adelay and amix

To start different audio tracks at different times, you cannot rely on amix alone. You must first apply the adelay filter to individual input streams to pad them with silence at the beginning. Once delayed, the streams are fed into the amix filter to be merged.

The FFmpeg Command

Here is the template command to mix three audio inputs where the first starts immediately, the second starts at 5 seconds, and the third starts at 10.5 seconds:

ffmpeg -i input1.mp3 -i input2.mp3 -i input3.mp3 -filter_complex \
"[1]adelay=5000:all=1[a2]; \
 [2]adelay=10500:all=1[a3]; \
 [0:a][a2][a3]amix=inputs=3:duration=longest:dropout_transition=0[out]" \
-map "[out]" output.mp3

Command Breakdown

Handling Volume Reductions

By default, the amix filter scales down the volume of the input streams to prevent digital clipping (distortion) when mixing them together. If your output audio is too quiet, you can use the volume filter after mixing to restore the original loudness:

ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex \
"[1]adelay=3000:all=1[a2]; \
 [0:a][a2]amix=inputs=2:duration=longest[mixed]; \
 [mixed]volume=2[out]" \
-map "[out]" output.mp3

In this case, volume=2 doubles the volume of the mixed track. Adjust this multiplier as needed depending on your source files.