Combine Two Mono Audio Files to Stereo with FFmpeg
This guide explains how to use the FFmpeg amerge audio
filter to combine two separate mono audio files into a single,
two-channel stereo track. You will learn the exact command-line syntax
required, how the stream mapping works, and how to configure the output
to ensure proper stereo channel designation.
To merge two mono files (representing the left and right channels) into a stereo file, use the following FFmpeg command:
ffmpeg -i left.wav -i right.wav -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map "[a]" output.wavHow the Command Works
-i left.wav -i right.wav: Specifies the two mono input files. FFmpeg indexes these inputs starting at zero, soleft.wavis input0andright.wavis input1.-filter_complex: This flag is required because the command processes multiple input streams to produce a new output stream."[0:a][1:a]amerge=inputs=2[a]": This is the core filtergraph.[0:a]and[1:a]select the audio streams from the first and second input files, respectively.amerge=inputs=2instructs FFmpeg to merge the two incoming audio streams into a single multi-channel stream.[a]labels the resulting merged audio stream so it can be referenced in the next step.
-map "[a]": Directs FFmpeg to write the newly created merged stream[a]to the output fileoutput.wav.
Ensuring Proper Stereo Layout
By default, merging two mono streams will create a 2-channel audio
file. However, some media players require explicit channel layout
metadata to recognize the file as stereo. You can force a standard
stereo layout by adding the -ac 2 parameter:
ffmpeg -i left.wav -i right.wav -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map "[a]" -ac 2 output.wavImportant Considerations
- Audio Duration: If the two mono files are of
different lengths, the resulting stereo file will end when the shortest
input ends. To keep the output playing until the longer file finishes,
add the
-async 1option or pad the shorter audio beforehand. - Sample Rates: For the best results, both input files should share the same sample rate (e.g., 44100 Hz or 48000 Hz). If they differ, FFmpeg will automatically resample them, which may slightly increase processing time.