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.wav

How the Command Works

  • -i left.wav -i right.wav: Specifies the two mono input files. FFmpeg indexes these inputs starting at zero, so left.wav is input 0 and right.wav is input 1.
  • -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=2 instructs 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 file output.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.wav

Important 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 1 option 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.