Opened 5 years ago

Closed 5 years ago

#55 closed defect (fixed)

5.1 AAC Output Incorrectly Mapped

Reported by: AlanJames1987 Owned by:
Priority: minor Component: avcodec
Version: git Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no


I am trying to transcode an H.264 video with 5.1 DTS sound to an X264 video with 5.1 AAC sound. The output file's channels were not mapped correctly and the sound that should have been coming from the center speaker was coming out the right front speak. Both libfaac and the built in aac codec have given me the same problem.

I'm on Ubuntu 10.04 using the latest Git version of FFMPEG. Below is the bash script I used and FFPROBE output or the input file.


ffmpeg -i \
  -vcodec libx264 -b 1920k \
  -acodec aac -strict experimental -ab 192k \
  -vpre slow -threads 0 -map_metadata -1 -y 11_output.mp4
qt-faststart 11_output.mp4 11.mp4
rm 11_output.mp4
FFprobe version git-N-29011-g5381823, Copyright (c) 2007-2011 the FFmpeg developers
  built on Apr 10 2011 21:10:33 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
  libavutil    50. 40. 1 / 50. 40. 1
  libavcodec   52.117. 0 / 52.117. 0
  libavformat  52.106. 0 / 52.106. 0
  libavdevice  52.  4. 0 / 52.  4. 0
  libavfilter   1. 78. 0 /  1. 78. 0
  libswscale    0. 13. 0 /  0. 13. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[matroska,webm @ 0x32cd050] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from '11.mkv':
  Duration: 00:01:04.39, start: 0.000000, bitrate: 1536 kb/s
    Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x816 [PAR 1:1 DAR 40:17], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
      title           : Tron.Legacy.2010.BluRay.1080p.x264.DTS-MySiLU
    Stream #0.1(eng): Audio: dca (DTS), 48000 Hz, 5.1, s16, 1536 kb/s (default)

Change History (10)

comment:1 Changed 5 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Priority changed from normal to minor
  • Reproduced by developer set
  • Status changed from new to open

This is certainly reproducible.

Please note that the AAC encoder is marked experimental (and you found one of several problems).

comment:2 Changed 5 years ago by cehoyos

Please test this patch for the native encoder:

comment:3 Changed 5 years ago by AlanJames1987

That patch doesn't seem to work. I am still getting what should be the center speaker sound coming out of the right front speaker.

comment:4 Changed 5 years ago by cehoyos

How did you test? (Source file, command line, playback application)
I encoded wav files with ffmpeg -i source -ab 256k out.aac and played them back with QuickTime?, it works fine for me for the following source channel layouts:
L - R - C
L - R - C - Cs
L - R - C - Ls - Rs
L - R - C - LFE - Ls - Rs

comment:5 Changed 5 years ago by AlanJames1987

I encoded a few different 5.1 files from different sources (Apple trailers, DVDs, etc) using the same script in my bug report. I played the file in VLC and in JW Player. I compiled the current Git version of FFMPEG, with this patch of course, on Kubuntu 11.04.

comment:6 Changed 5 years ago by cehoyos

Sample from

ffmpeg -i ~/\[CCCP\]_Manhole_Test_Your_5.1_\[revamped\].mkv -acodec aac -strict experimental -qscale 5 -ab 192k out.mp4

With current, unpatched ffmpeg, the resulting file has broken channel order with vlc and QuickTime?, after recompiling and re-encoding with the patch, channel order is fine with both applications.

Could you test again (or point me to a failing sample)?

comment:7 Changed 5 years ago by AlanJames1987

I crossed my fingers and I tested again using your script, your patch, the same file as you and I got a file with incorrectly mapped audio. The file is correctly mapped before processing and has the same errors listen above after.

comment:8 Changed 5 years ago by AlanJames1987

It's actually now working for me as well. I don't know what I was doing wrong before. Maybe I mis-copied something from your posted diff file. Thank you for all your help. This is working great now.

comment:10 Changed 5 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed

Both patches applied.

Note: See TracTickets for help on using tickets.