1

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:

waveforms in my origin video

These instead are the waveforms of the transcoded file:

waveforms changed after transcoding

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 ;)

1

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)

  • I found working for my purposes: -af "channelmap=0|1|4|5|2|3:5.1" – user3450548 Jan 4 '18 at 0:28
  • Just a question, what I wonder is.. Why with ffmpeg I have to specify the channel order manually when instead a player like VLC that is based on libavcodec is able to determine it automatically ? Shouldn't ffmpeg do the same ? I can understand specifying manually the 5.1 channel flavour for the output but not for the input.. – user3450548 Jan 4 '18 at 0:32
  • The channel layout is signaled by the demuxer to the decoder and VLC uses its own. In ffmpeg, the QT demuxer does recognize the layout in your MOV but ffmpeg internally has a single designation for 5.1, so it does not reorder when sending to encoder. – Gyan Jan 4 '18 at 6:08
  • I see, this makes sense. There's no any kind of way to auto assign them so? Or at least a command with ffprobe to read the internal channel layout so that I could make a multi pass script ? – user3450548 Jan 4 '18 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.