FFmpeg amix vs amerge Difference

When working with audio in FFmpeg, combining multiple audio tracks is a common task, but the method you choose depends on your desired output. This article explains the difference between the amix and amerge filters, helping you understand when to mix audio signals together and when to merge them into a single multi-channel stream.

What is the amix Filter?

The amix filter mixes multiple audio inputs into a single audio output. It overlays the audio signals on top of each other within the same channels. For example, if you input two stereo tracks, amix will blend them together into a single stereo track where you can hear both sounds playing simultaneously.

Key Characteristics of amix

Example Command

To mix a voiceover (voice.mp3) and background music (music.mp3) into one output:

ffmpeg -i voice.mp3 -i music.mp3 -filter_complex amix=inputs=2:duration=first output.mp3

What is the amerge Filter?

The amerge filter merges two or more audio streams into a single multi-channel audio stream. Instead of blending the sounds together into the same channels, it places each input stream into its own dedicated channel. For example, merging two separate mono streams will create a single stereo stream where one input becomes the Left channel and the other becomes the Right channel.

Key Characteristics of amerge

Example Command

To merge two mono audio files into a single stereo file:

ffmpeg -i left.wav -i right.wav -filter_complex amerge=inputs=2 output.wav

Summary of Key Differences

Feature amix (Mixing) amerge (Merging)
Primary Function Blends multiple audio tracks into the same channels. Groups separate audio tracks into new, distinct channels.
Output Channels Keeps the channel layout of the primary/widest input. Sums the input channels (e.g., 1 + 1 = 2 channels).
Common Use Case Adding background music to a voiceover. Combining two mono mics into a single stereo track.
Input Requirements Flexible; handles different sample rates and durations. Strict; requires identical sample rates.
Default Duration Matches the longest input. Matches the shortest input.