Merge Two Mono Audio Files into Stereo with FFmpeg
Combining two separate mono audio tracks into a single stereo file is
a common task in audio post-production. This guide provides a
straightforward, step-by-step tutorial on how to use FFmpeg, a powerful
command-line tool, to merge left and right mono channels into a cohesive
stereo audio file using the amerge filter.
The Standard FFmpeg Command
To merge a left-channel mono file and a right-channel mono file into one stereo file, use the following command in your terminal or command prompt:
ffmpeg -i left.wav -i right.wav -filter_complex amerge=inputs=2 -ac 2 stereo.wavHow the Command Works
-i left.wavand-i right.wav: These define the two input files. The first input file (0) will default to the left channel, and the second input file (1) will default to the right channel.-filter_complex amerge=inputs=2: This tells FFmpeg to use the complex filter graph to merge two audio inputs into a single multi-channel stream.-ac 2: This explicitly sets the output audio channels to 2, ensuring the final output is recognized as a standard stereo track.stereo.wav: This is the name of your final output file. You can change this to other formats, such asstereo.mp3orstereo.m4a, and FFmpeg will automatically handle the conversion.
Alternative Method: Using the Join Filter
If you want to explicitly map which input file goes to which specific
channel (Left or Right), you can use the join filter
instead:
ffmpeg -i left.wav -i right.wav -filter_complex "[0:a][1:a]join=inputs=2:channel_layout=stereo:map=0.0-FL|1.0-FR[a]" -map "[a]" stereo.wavmap=0.0-FL: Maps the first input file (index 0, audio stream 0) to the Front Left (FL) channel.1.0-FR: Maps the second input file (index 1, audio stream 0) to the Front Right (FR) channel.
Handling Different Audio Lengths
By default, the amerge filter will stop encoding when
the shortest input file ends. If your mono files are of different
lengths and you want the output to keep playing until the longer file
finishes, add the -shortest option or pad the audio.
However, for most standard mono-to-stereo conversions where the files
are identical in length, the standard command above will work
perfectly.