Software Engineer's Blog

How to Merge Two Mono Audio Files into Stereo with FFmpeg on Ubuntu

How to Merge Two Mono Audio Files into Stereo with FFmpeg on Ubuntu

If you have two separate audio recordings — one for Speaker A and one for Speaker B — and both speakers were recorded at the same time, you might want to combine them into a single stereo audio file.

This is useful in many scenarios:

  • Dual-microphone recordings
  • Interview capture
  • Podcast editing
  • Voice separation testing
  • Audio analysis workflows

The key idea is to place one speaker’s voice in the Left channel and the other speaker’s voice in the Right channel. This way, both voices are preserved in a synchronized and clean format, perfect for further processing or listening.

Here is how you can use FFmpeg on Ubuntu to merge two mono audio files into a single stereo track.

1. Install FFmpeg (Ubuntu/Linux)

If you haven’t installed FFmpeg yet, run the following commands in your terminal:

$ sudo apt update
$ sudo apt install ffmpeg

2. The Command

Run the following command in the directory where your audio files are located.

$ ffmpeg -i speakerA.wav -i speakerB.wav -filter_complex "[0:a][1:a]amerge=inputs=2[stereo]" -map "[stereo]" -ac 2 merged_stereo.wav

3. Understanding the Options

OptionDescription
-i speakerA.wavThe first input file (Mapped to Left Channel).
-i speakerB.wavThe second input file (Mapped to Right Channel).
-filter_complexEnables complex filter graphs for manipulating streams.
[0:a][1:a]Selects the audio stream from input 0 (speakerA) and input 1 (speakerB).
amerge=inputs=2Merges the two selected mono streams into a single multi-channel stream.
-ac 2Forces the output to be 2 channels (Stereo).
merged_stereo.wavThe final output filename.

4. Execution Result (Terminal Output)

Here is what the output looks like on a Linux system. Notice how the two mono inputs (Stream #0:0 and Stream #1:0) are merged into one stereo output.

$ ffmpeg -i speakerA.wav -i speakerB.wav -filter_complex "[0:a][1:a]amerge=inputs=2[stereo]" -map "[stereo]" -ac 2 merged_stereo.wav

Input #0, wav, from 'speakerA.wav':
  Duration: 00:07:37.86, bitrate: 256 kb/s
  Stream #0:0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
Input #1, wav, from 'speakerB.wav':
  Duration: 00:07:37.92, bitrate: 256 kb/s
  Stream #1:0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s

Stream mapping:
  Stream #0:0 (pcm_s16le) -> amerge
  Stream #1:0 (pcm_s16le) -> amerge
  amerge:default -> Stream #0:0 (pcm_s16le)

Output #0, wav, to 'merged_stereo.wav':
  Stream #0:0: Audio: pcm_s16le, 16000 Hz, stereo, s16, 512 kb/s
size=   28616kB time=00:07:37.86 bitrate= 512.0kbits/s speed=634x

Tip: File Duration

The amerge filter terminates the output when the shortest input stream ends. If speakerA.wav is 5 minutes and speakerB.wav is 6 minutes, the final file will be 5 minutes long. Ensure your recordings are synchronized and roughly the same length before merging.