Transcode 5.1 audio in ffmpeg leads to incorrect audio mapping in output I need to transcode some high res videos (prores or dnxhd files with 5.1 uncompressed 48kHz audio in MOV container) to their low res h264 with AAC keeping the audio still in 5.1 preserving their channel mapping.

In order to do so I tried to use this command:

ffmpeg -y -i input.mov -c:v libx264 -preset ultrafast -b:v 10000k -c:a libfdk_aac -afterburner 1 -cutoff 20000 -filter:v "scale=-1:720" output.mp4


The version I'm using is ffmpeg version N-87584-g47d6b02f6c-Reino a pretty new one.

What happens is that even if video processing is ok, for the audio part my channels are mapped incorrectly.. to better explain what happens I made a screenshot of before and after waveforms in Adobe Audition.

These are the waveform of the input file:



These instead are the waveforms of the transcoded file:



Again let me post the ffprobe parts related to the audio:

input file:

Stream #0:1(eng): Audio: pcm_s24le (lpcm / 0x6D63706C), 48000 Hz, 5.1, s32 (24 bit), 6912 kb/s (default)
Metadata:
  creation_time   : 2018-01-02T09:48:58.000000Z
  handler_name    : Apple Alias Data Handler
  timecode        : 00:00:00:00


transcoded file:

Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 488 kb/s (default)
Metadata:
  handler_name    : SoundHandler


and for finish MediaInfo Lite

original file:

Audio
ID                          : 2
Format                      : PCM
Format settings             : Little / Signed
Format settings, Endianness : Little
Format settings, Sign       : Signed
Codec ID                    : lpcm
Duration                    : 1 h 30 min
Bit rate mode               : Constant
Bit rate                    : 6 912 kb/s
Channel(s)                  : 6 channels
Channel positions           : Front: L C R, Back: L R, LFE
Sampling rate               : 48.0 kHz
Bit depth                   : 24 bits
Stream size                 : 4.35 GiB (5%)
Language                    : English
Encoded date                : UTC 2018-01-02 09:48:58
Tagged date                 : UTC 2018-01-02 10:16:46


transcoded file:

Audio
ID                          : 2
Format                      : AAC
Format/Info                 : Advanced Audio Codec
Format profile              : LC
Codec ID                    : mp4a-40-2
Duration                    : 1 h 30 min
Duration_LastFrame          : -8 ms
Bit rate mode               : Constant
Bit rate                    : 489 kb/s
Channel(s)                  : 2 channels
Channel(s)_Original         : 6 channels
Channel positions           : Front: L C R, Side: L R, LFE
Sampling rate               : 48.0 kHz
Frame rate                  : 46.875 FPS (1024 SPF)
Compression mode            : Lossy
Stream size                 : 315 MiB (5%)
Language                    : English
Default                     : Yes
Alternate group             : 1


If you play the mp4 file with VLC you clearly hear that something is swapped badly.

I'm open to a solution ;)
FFmpeg assumes that the input's 5.1 channel mapping is the same as the one it uses. To correct that, use the channelmap filter to remap, add:

-af "channelmap=4|0|1|2|3|5:5.1"


(I based it off the channel labels on the right in your images)