Merge Audio Files into Channels Using FFmpeg amerge

This guide explains how to combine separate audio files side-by-side into a single multi-channel audio file using the FFmpeg amerge filter. You will learn the exact command-line syntax required to merge two mono files into a stereo track, as well as how to combine multiple files into multi-channel layouts.

Merging Two Mono Files into a Stereo Track

To combine two separate mono audio files into a single stereo file (where one input becomes the left channel and the other becomes the right channel), use the following filter_complex command:

ffmpeg -i left.wav -i right.wav -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map "[a]" output.wav

How this command works: * -i left.wav -i right.wav: Specifies the two input audio files. * -filter_complex: Calls the filtergraph to handle multiple inputs. * [0:a][1:a]: Selects the first audio stream of the first input (index 0) and the first audio stream of the second input (index 1). * amerge=inputs=2: Merges the two specified audio streams into a single multi-channel stream. * [a]: Labels the output stream of the filter as “a”. * -map "[a]": Tells FFmpeg to write the merged stream to the output file output.wav.

Merging Multiple Files into Multi-Channel Audio

You can scale this command to merge more than two files. For example, to combine four separate mono files into a 4-channel audio file:

ffmpeg -i ch1.wav -i ch2.wav -i ch3.wav -i ch4.wav -filter_complex "[0:a][1:a][2:a][3:a]amerge=inputs=4[a]" -map "[a]" output.wav

Simply update the inputs parameter to match the number of input files, and ensure you list all input labels (e.g., [0:a][1:a][2:a][3:a]) in the filter chain.

Handling Different Input Lengths

By default, the amerge filter will stop merging when the shortest input file ends. If you want the output file to keep playing until the longest input file finishes (filling the missing channels with silence), add the -async 1 option or use the pan filter to specify the channel layout explicitly.