4

I have 4 audio streams in my video file. They are from 4 microphones placed at 4 different people speaking. I want to transcode to a preview file that can be listened to on headphones where everybody's voice can be heard.

I have seen the -ac 2 option, but I can't tell if this will merge all the audio streams or just select the 1st two. I've also seen the amerge filter, but the docs say this will produce 4 audio channels in the output file. So I'm wondering how headphones will deal with the additional 2 channels

swami
  • 673
  • 1
  • 9
  • 18
  • by definition headphones can only render at most 2 channels (stereo) so any extra channel must get added into one of those channels before getting sent to headphones ... give it a go using ffmpeg and show us what you have – Scott Stensland Jan 06 '19 at 21:06

2 Answers2

5

You have several options. This assumes each individual audio stream in in.mp4 is mono.

Mono

Using the amerge filter and -ac 1:

ffmpeg -i in.mp4 -filter_complex "[0:a]amerge=inputs=4[a]" -ac 1 -map 0:v -map "[a]" -c:v copy out.mp4

With amix:

ffmpeg -i in.mp4 -filter_complex "[0:a]amix=inputs=4[a]" -map 0:v -map "[a]" -c:v copy out.mp4

Stereo

With amerge and -ac 2:

ffmpeg -i in.mp4 -filter_complex "[0:a]amerge=inputs=4[a]" -ac 2 -map 0:v -map "[a]" -c:v copy out.mp4

Manually mixed stereo

Using amerge and pan with custom downmix:

  • Channel 0 will be 100% in FL
  • Channel 1 will be 75% in FL & 25% in FR
  • Channel 2 will be 25% in FL & 75% in FR
  • Channel 3 will be 100% in FR


ffmpeg -i in.mp4 -filter_complex "[0:a]amerge=inputs=4,pan=stereo|FL<c0+0.75*c1+0.25*c2|FR<0.25*c1+0.75*c2+c3[a]" -map 0:v -map "[a]" -c:v copy out.mp4
llogan
  • 121,796
  • 28
  • 232
  • 243
2

Try the amerge audio filter, used to solve this similar question: How do I use ffmpeg to merge all audio streams (in a video file) into one audio channel?

amix should even better should fit your purpose.

micha137
  • 1,195
  • 8
  • 22