Opened 3 years ago

Last modified 3 years ago

#5179 new defect

Native AAC encoder does not respect channelmap assignments

Reported by: mulvya Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Tried to generate a 4-channel AAC stream with quad(side) layout, but the output MP4 reports stream layout as 4.0. WAV is generated with correct layout. Using Zeranoe static binary.


Generation of dummy stereo source.

ffmpeg -f lavfi -i "aevalsrc=0|0:d=5" null0.mp4 -report 2> null0.log

ffmpeg version N-77715-gfc703f5 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 12.100 / 55. 12.100
  libavcodec     57. 21.100 / 57. 21.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, lavfi, from 'aevalsrc=0|0:d=5':
  Duration: N/A, start: 0.000000, bitrate: 5644 kb/s
    Stream #0:0: Audio: pcm_f64le, 44100 Hz, stereo, dbl, 5644 kb/s
Output #0, mp4, to 'null0.mp4':
  Metadata:
    encoder         : Lavf57.21.101
    Stream #0:0: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.21.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_f64le (native) -> aac (native))
Press [q] to stop, [?] for help
size=       3kB time=00:00:05.01 bitrate=   4.7kbits/s speed=79.6x    
video:0kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 122.289612%
[aac @ 00000000003ad8c0] Qavg: 65536.000

Generation of 4 channel AAC in MP4

ffmpeg -i null0.mp4 -lavfi "[0]asplit[a][b];[a][b]amerge[o];[o]channelmap=0|1|2|3:quad(side)[out]" -map "[out]" null1.mp4 2> null1.log

ffmpeg version N-77715-gfc703f5 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 12.100 / 55. 12.100
  libavcodec     57. 21.100 / 57. 21.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'null0.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.21.101
  Duration: 00:00:05.04, start: 0.023220, bitrate: 4 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[Parsed_amerge_1 @ 00000000029a3cc0] No channel layout for input 1
[Parsed_amerge_1 @ 00000000029a3cc0] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, mp4, to 'null1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.21.101
    Stream #0:0: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, quad(side), fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc57.21.100 aac
Stream mapping:
  Stream #0:0 (aac) -> asplit
  channelmap -> Stream #0:0 (aac)
Press [q] to stop, [?] for help
size=       4kB time=00:00:05.03 bitrate=   7.1kbits/s speed=46.7x    
video:0kB audio:3kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 56.716942%
[aac @ 00000000029a22c0] Qavg: 65536.000


ffprobe null1.mp4
=================
ffprobe version N-77715-gfc703f5 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 12.100 / 55. 12.100
  libavcodec     57. 21.100 / 57. 21.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'null1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.21.101
  Duration: 00:00:05.06, start: 0.023220, bitrate: 7 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 4.0, fltp, 4 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

Generation of 4-channel WAV

ffmpeg -i null0.mp4 -lavfi "[0]asplit[a][b];[a][b]amerge[o];[o]channelmap=0|1|2|3:quad(side)[out]" -map [out] null1.wav 2> null1wav.log

ffmpeg version N-77715-gfc703f5 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 12.100 / 55. 12.100
  libavcodec     57. 21.100 / 57. 21.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'null0.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.21.101
  Duration: 00:00:05.04, start: 0.023220, bitrate: 4 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[Parsed_amerge_1 @ 0000000002613c20] No channel layout for input 1
[Parsed_amerge_1 @ 0000000002613c20] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, wav, to 'null1.wav':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    ISFT            : Lavf57.21.101
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, quad(side), s16, 2822 kb/s (default)
    Metadata:
      encoder         : Lavc57.21.100 pcm_s16le
Stream mapping:
  Stream #0:0 (aac) -> asplit
  channelmap -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
size=    1736kB time=00:00:05.03 bitrate=2822.6kbits/s speed= 157x    
video:0kB audio:1736kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005738%




ffprobe null1.wav
=================
ffprobe version N-77715-gfc703f5 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 12.100 / 55. 12.100
  libavcodec     57. 21.100 / 57. 21.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, wav, from 'null1.wav':
  Metadata:
    encoder         : Lavf57.21.101
  Duration: 00:00:05.04, bitrate: 2822 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, quad(side), s16, 2822 kb/s

Change History (2)

comment:1 Changed 3 years ago by atomnuker

The AAC specifications define only the most common channel map per a given number of channels.

From the code:

1 channel - single channel element
2 channels - channel pair
3 channels - center + stereo
4 channels - front center + stereo + back center
5 channels - front center + stereo + back stereo
6 channels - front center + stereo + back stereo + LFE
7 channels - invalid without PCE
8 channels - front center + front stereo + side stereo + back stereo + LFE

So without support for Programmable Channel Elements (PCE) which theoretically allow for custom mapping the encoder cannot output anything outside of those defined presets. Our encoder doesn't support those, and I doubt any other encoder does. I also doubt many decoders support these and correctly do the mapping. So you're out of luck if you still want to use AAC.

comment:2 Changed 3 years ago by mulvya

At least some encoder seems to, according to http://stackoverflow.com/questions/34938715/ffmpeg-mapping-4-audio-channels-to-1-audio-track

specifically

Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '4chan.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2016-01-19 04:11:52
  Duration: 00:19:58.00, start: 0.000000, bitrate: 5118 kb/s
    Stream #1:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte1
70m/smpte170m/bt709), 768x576, 4955 kb/s, 25 fps, 25 tbr, 25k tbn, 50k tbc (defa
ult)
    Metadata:
      creation_time   : 2016-01-19 04:11:52
      handler_name    : Apple Alias Data Handler
      encoder         : H.264
      timecode        : 00:28:33:21
    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, quad, fltp,
 157 kb/s (default)
    Metadata:
      creation_time   : 2016-01-19 04:11:52
      handler_name    : Apple Alias Data Handler
    Stream #1:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    Metadata:
      rotate          : 0
      creation_time   : 2016-01-19 04:11:52
      handler_name    : Apple Alias Data Handler
      timecode        : 00:28:33:21
Note: See TracTickets for help on using tickets.