Re: Multichannel AAC on iOS
Reply #21 –
ffmpeg also encodes to Apple Lossless WITHOUT specifying a channel layout in the file header of the resulting .m4a file:
ffmpeg -i infile.wav -c:a alac outfile.m4a
iOS maps to all 5.1 channels, but the channel mapping is changed (same mapping as Apple Lossless files encoded by dBpoweramp, listed in previous post).
We can correct the channel mapping with the pan audio filter:
ffmpeg -i infile.wav -af "pan=5.1|c0=c1|c1=c2|c2=c0|c3=c5|c4=c3|c5=c4" -c:a alac outfile.m4a
Prevent the warning "Guessed Channel Layout for Input Stream #0.0 : 5.1" for input files with no channel layout specified in the file header:
ffmpeg -channel_layout 5.1 -i infile.wav -af "pan=5.1|c0=c1|c1=c2|c2=c0|c3=c5|c4=c3|c5=c4" -c:a alac outfile.m4a
So, all good for Apple Lossless, but how do we do the same with Apple AAC or Fraunhofer FDK AAC?
It seems iOS devices cannot parse standard MPEG channel layouts specified in the file header by these codecs, forcing iOS devices to fallback to mapping all channels to Front Left and Front Right only.
Only files with NO channel layout specified in the file header will map to all 5.1 channels:
- .wav will map in the correct order
- .m4a Apple Lossless need to correct the channel mapping