I'm trying to merge these two WAVs (L.wav and R.wav) into a single, dual-channel stereo OGG. This is what I'm trying:

ffmpeg -i L.wav -i R.wav -c:a libvorbis -q:a 5 \
-filter_complex "[0:a][1:a]amerge" -f ogg out.ogg

However, ffmpeg says that:

Input channel layouts overlap: output layout will be determined by the number of distinct input channels

And that

4.0 not supported by Vorbis: output stream will have incorrect channel layout.

So I understand I will only get one audio in only one channel of my output file. So the question is, how can I tell ffmpeg to map channel 0 of L.wav and channel 0 of R.wav into channels 0 and 1 of out.ogg (respectively)? something like this:

input #0 [] → [] \
                                > output #0 [1.1] 
input #1 [] → [] /

As you've notices the amerge filter combined both stereo inputs into a 4-channel output. The current 4-channel layout:

  • c0 is the left channel from L.wav
  • c1 is the right channel from L.wav
  • c2 is the left channel from R.wav
  • c3 is the right channel from R.wav

You can add the pan filter to mix the desired channels back into a stereo output. As far as I can tell you want c0 to be the left channel of your output, and c2 to be the right channel:

ffmpeg -i L.wav -i R.wav \
-filter_complex "[0:a][1:a]amerge=inputs=2,pan=stereo|c0=c0|c1=c2[a]" \
-map "[a]" -c:a libvorbis -q:a 5 out.ogg
  • I usually explicitly add the input option to amerge. The default is 2, but I do this in case I use more than 2 inputs; otherwise being forgetful and often lazy I may set it correctly.

  • -f ogg is superfluous in this case since it will detect the proper format using the output file name.

  • See FFmpeg Wiki: Audio Channel Manipulation for more examples.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.