ffmpeg AAC "Can not resample 6 channels..."

When you try to encode with ffmpeg and you end up with such an error

Resampling with input channels greater than 2 unsupported.
Can not resample 6 channels @ 48000 Hz to 6 channels @ 48000

you are probably trying to encode from AAC with 5.1 audio to less than 6 channels or different audio sampling rate.

There are three solutions:

1、As a solution either do not reduce the audio channels and change the audio sampling rate or do convert the audio with faad first.
2、Apply one of the available ffmpeg patches to fix the AAC 6 channel issue...
6to2channel-resample.patch
FFMPEG 6 to 2 channel patch

gistfile1
6to2channel-resample

patch -p1 < ffmpeg-aacp2.10112010.diff

mkdir ~/src/
cd ~/src/
svn co svn://svn.ffmpeg.org/soc/libavfilter
cd libavfilter/
sh checkout.sh
cd ffmpeg/libavcodec/
wget http://svn.xiph.org/trunk/ffmpeg2theora/patches/6to2channel-resample.patch
patch resample.c < 6to2channel-resample.patch
cd ../
mkdir ~/ffmpeg

3、Split video and audio and convert audio separately.

The third solution can be done as following:

Extract audio with ffmpeg:

ffmpeg -y -i source.avi -acodec copy source.6.aac

Convert audio with faad:

faad -d -o source.2.pcm source.6.aac

Merge video and audio again with ffmpeg:

ffmpeg -y -i source.avi -i source.2.pcm -map 0:0 -map 1:0 -vcodec copy -acodec copy output.avi

Update: As hinted by a fellow commentter the big disadvantage is the quality loss as faad can only convert into PCM 16bit.

点赞