Giuseppe
Giuseppe

Reputation: 5348

Converting DTS to AAC with ffmpeg shifts spoken audio to the right

I am using ffmpeg to convert mkv movies to mp4, like so:

$ ffmpeg -i source.mkv -c:v copy -c:a aac destination.mp4

By doing this, the audio stream gets converted from the original DTS:

Stream #0:1: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)

To AAC:

Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 394 kb/s (default)

The resulting file plays just fine, except that the spoken audio (what I am assuming would be sent to the central channel in a 5.1 configuration) sounds clearly shifted to the right, when listening through the MacBook's built-in speakers or my stereo headphones. Note that music and other sound effects appear unaffected, properly balanced. Also note that I have been able to reproduce this behavior with a variety of source files.

Here's ffmpeg's banner:

ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100

Upvotes: 3

Views: 3162

Answers (1)

Gyan
Gyan

Reputation: 93369

An FFmpeg commit, aacenc: support extended channel layouts using PCEs, in Nov 2017 added support for many more channel layouts than specified in the MPEG standard for AAC. Unfortunately, it seems it has broken encoding for layouts that worked fine before.

The 3.4 release series is the last before the said commit and should be used for multichannel AAC encoding if you encounter an error with more recent builds.

There is an open bug report at https://trac.ffmpeg.org/ticket/7273. You may post a comment in there to showcase your example.

Upvotes: 4

Related Questions