audioffmpegaacm4a

How can I produce a 9 channel audio file encoded using AAC from 9 (mono) input files?


I'd like to create an AAC encoded audio file with an MP4 container that has a large number of channels, ideally up to 64.

I'm running something like this (but with 9 files and a larger list at the start of the filter):

ffmpeg -hide_banner -i 0.wav -i 1.wav -filter_complex '[0:a][1:a]amerge=inputs=9[aout]' -map '[aout]' '-c:a' aac 'multichannel.m4a'

Unfortunately the codec complains about 9 being an unsupported number of channels. Is there any way to do this?


Solution

  • With the native AAC encoder, you can only do 1-8 or 16 channels. So, if you are bound by 9 channels, you can use 16 channels and fill the unused channels with zeros. Something like this:

    ffmpeg -y -i 0.wav -i 1.wav \
      -filter_complex \
        'aevalsrc='0|0|0|0|0|0|0'[anull];\
         [0:a][1:a][anull]amerge=inputs=3[aout]' \
      -map [aout] -shortest -c:a aac 'out.m4a'"
    

    I've tested up to 100 channels, so nothing more than 16 (well short of your target 64). Can you just put theses channels in different streams? For example, 4 streams of 16 channels each. You cannot play them back together, but there probably isn't a need to do so maybe?

    According to Wikipedia aac can support up to 48 channels. So you can try to get your hands on Fraunhofer FDK AAC enabled FFmpeg to see if you have a better luck.