audioffmpegavconv

Multichannel AAC mp4 encoding using libav (avconv) or ffmpeg


I am trying to create a four-channel mp4 file with AAC encoding for ambisonics use. I am trying to encode a 4-channel first-order ambisonic wav file into AAC like so:

avconv -i four_channel_input.wav -c:a libfaac -ac 4 four_channel_output.mp4

This gives me the error

[libfaac @ 0x7f938885a000] Specified channel_layout is not supported
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Removing the -ac 4 option gives me a 5 channel file

Duration: 00:01:21.09, start: 0.021333, bitrate: 218 kb/s
Stream #0:0(und): Audio: aac (LC) [mp4a / 0x6134706D]
  48000 Hz, 5.0, fltp, 215 kb/s (default)

with a blank first channel, which is obviously suboptimal. In order to create compressed ambisonics files, should I be using a separate format like AmbiX (even though I believe this is uncompressed)?


Solution

  • With ffmpeg, you can run

    ffmpeg -i input.wav -c:a aac -ac 4 -channel_layout 4.0 four_channel_output.mp4