VideoHelp Forum




+ Reply to Thread
Results 1 to 21 of 21
  1. Hi guys,

    When converting DTS HD-MA or multichannel FLAC to AAC with the latest ffmpeg 4.1.3 I get channel layout that mismatch source audio file.

    This happens for 5.1 and 7.1 audios.

    The command I use is the simplest one:

    Code:
    ffmpeg -i 7.1.flac 7.1.aac
    Code:
    ffmpeg -i 5.1.dts 5.1.aac

    The source and destination layouts looks like the following:

    Code:
    L R C LFE Lb Rb Ls Rs <-- 7.1.flac
    C L R Ls Rs Lb Rb LFE <-- 7.1.aac
    Code:
    C L R Ls Rs LFE <-- 5.1.dts
    L R C Cb Lb Rb <-- 5.1.aac
    Please kindly assist.
    Quote Quote  
  2. Sounds like serious regression for ffmpeg.
    Try to restore proper order with https://ffmpeg.org/ffmpeg-filters.html#channelmap
    Check channel layout for source and for target.
    Quote Quote  
  3. Any update here? Does anyone know how to fix it?
    I have DTS-HD MA 7.1:

    Code:
    Channel layout                           : C L R LFE Lb Rb Lss Rss
    And after converting to aac:

    Code:
    Channel layout                           : C L R Ls Rs Lw Rw LFE
    Is it fine, is incorrect? By default, if I was not specifying 8 channels in the command line, it was just taking 7 in the output of the aac. Is kind of weird that this is not autodetected by default.
    Last edited by eddy89; 31st Mar 2025 at 12:41.
    Quote Quote  
  4. The channel layout for DTS to aac 8ch is correct with ffmpeg v7.1.1
    Quote Quote  
  5. Thanks for the reply.

    Can you develop on what is the meaning of the Lb Rb Lss Rss as opposed to Ls Rs Lw Rw?

    DTS:
    Code:
    Channel layout                           : C L R LFE Lb Rb Lss Rss
    AAC:
    Code:
    Channel layout                           : C L R Ls Rs Lw Rw LFE

    Apart from that, do you know why unless I add this to the command line:

    Code:
    -ac 8
    to make sure I am outputting 8 channels, it just creates a file with just 7 channels? This was before the previous flag in command line:

    Code:
    Channel(s)                               : 7 channels
    Channel layout                           : C L R Ls Rs Lb Rb
    For me it seems quite concerning, as I guess knowing the number of input/output channels, should be completely automatic (unless you want to explicitly change it so), right?

    Besides that, see the difference in the channels, apart from the lack of one of them, the naming is quite different:
    Code:
    Channel(s)                               : 7 channels
    Channel layout                           : C L R Ls Rs Lb Rb
    Channel(s)                               : 8 channels
    Channel layout                           : C L R Ls Rs Lw Rw LFE
    and the only difference is just the "-ac 8" flag.

    Hope anyone can put some light here.

    Thanks
    Last edited by eddy89; 31st Mar 2025 at 13:58.
    Quote Quote  
  6. Originally Posted by eddy89 View Post
    Can you develop on what is the meaning of the Lb Rb Lss Rss as opposed to Ls Rs Lw Rw?

    DTS:
    Code:
    Channel layout                           : C L R LFE Lb Rb Lss Rss
    AAC:
    Code:
    Channel layout                           : C L R Ls Rs Lw Rw LFE
    Which software gives you these channel names?


    Apart from that, do you know why unless I add this to the command line:

    Code:
    -ac 8
    to make sure I am outputting 8 channels, it just creates a file with just 7 channels?
    Post your full ffmpeg commandline that you use for the DTS to AAC conversion.
    Quote Quote  
  7. Originally Posted by ProWo View Post
    Originally Posted by eddy89 View Post
    Can you develop on what is the meaning of the Lb Rb Lss Rss as opposed to Ls Rs Lw Rw?

    DTS:
    Code:
    Channel layout                           : C L R LFE Lb Rb Lss Rss
    AAC:
    Code:
    Channel layout                           : C L R Ls Rs Lw Rw LFE
    Which software gives you these channel names?
    MediaInfo.

    Originally Posted by ProWo View Post
    Apart from that, do you know why unless I add this to the command line:

    Code:
    -ac 8
    to make sure I am outputting 8 channels, it just creates a file with just 7 channels?
    Post your full ffmpeg commandline that you use for the DTS to AAC conversion.
    Code:
    ffmpeg -i /path/audio DTS-HD\ MA\ 7.1\ @\ 2649\ kbps.ENG.dts -c aac_at -aac_at_quality 0 mynewaudio.m4a
    I was using the flag "-ac 8" to be able to get the 8 channels, otherwise I would get 7.
    Quote Quote  
  8. Originally Posted by eddy89 View Post

    Code:
    ffmpeg -i /path/audio DTS-HD\ MA\ 7.1\ @\ 2649\ kbps.ENG.dts -c aac_at -aac_at_quality 0 mynewaudio.m4a
    I was using the flag "-ac 8" to be able to get the 8 channels, otherwise I would get 7.
    Maybe the audio codec (aac_at, unknown to me and my latest nightly ffmpeg version).
    Quote Quote  
  9. Originally Posted by ProWo View Post
    Maybe the audio codec (aac_at, unknown to me and my latest nightly ffmpeg version).
    I was curious about this & searched it.
    It is an Apple codec.

    https://trac.ffmpeg.org/wiki/Encode/AAC


    At the bottom of this web page under ffmpeg it has some limited information about using with ffmpeg build:
    https://wiki.hydrogenaud.io/index.php?title=Apple_AAC
    Last edited by cholla; 2nd Apr 2025 at 12:19.
    Quote Quote  
  10. I vaguely recall that Apple may use different default channel allocation in their AAC - ffmpeg may fail in autodetection - can't provide you link but im almost sure that this was on hydrogen forum. I would try to use channel remap filter on ffmpeg to restore proper channel allocation - perhaps configuring filter 'channelmap' in ffmpeg in proper way will improve this (signaling proper channel layout) - https://ffmpeg.org/ffmpeg-filters.html#channelmap ; https://trac.ffmpeg.org/wiki/AudioChannelManipulation#Remapchannels .
    Btw ffmpeg recognize four different 7.1 channel layouts - not sure how many of them is supported by 'aac_at' codec - this can be also important.
    Quote Quote  
  11. Originally Posted by pandy View Post
    I vaguely recall that Apple may use different default channel allocation in their AAC - ffmpeg may fail in autodetection - can't provide you link but im almost sure that this was on hydrogen forum. I would try to use channel remap filter on ffmpeg to restore proper channel allocation - perhaps configuring filter 'channelmap' in ffmpeg in proper way will improve this (signaling proper channel layout) - https://ffmpeg.org/ffmpeg-filters.html#channelmap ; https://trac.ffmpeg.org/wiki/AudioChannelManipulation#Remapchannels .
    Btw ffmpeg recognize four different 7.1 channel layouts - not sure how many of them is supported by 'aac_at' codec - this can be also important.
    I tried (before) the same with the default aac before apple (which I use because is supposed to be the one with better quality), and the channel mapping is the same as the ffmpeg default aac encoder.
    Quote Quote  
  12. Originally Posted by eddy89 View Post
    I tried (before) the same with the default aac before apple (which I use because is supposed to be the one with better quality), and the channel mapping is the same as the ffmpeg default aac encoder.
    I have just tried this with the normal aac encoder from ffmpeg.
    I then loaded the dts and the aac file into Audacity at the same time and checked the individual tracks; the channel layout is correct, the individual aac channels are exactly the same as in the dts file.
    Quote Quote  
  13. Originally Posted by eddy89 View Post
    I tried (before) the same with the default aac before apple (which I use because is supposed to be the one with better quality), and the channel mapping is the same as the ffmpeg default aac encoder.
    You need to be sure that you are using proper channel layout - not sure if ffmpeg is able to automatically remap different channel layouts and depends on information source there are at least 3 different 7.1 channel layouts:
    Code:
    7.1            FL+FR+FC+LFE+BL+BR+SL+SR
    7.1(wide)      FL+FR+FC+LFE+BL+BR+FLC+FRC
    7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
    or based on other source 4 layouts:
    Code:
    7.1            FL+FR+FC+LFE+BL+BR+SL+SR
    7.1(wide)      FL+FR+FC+LFE+BL+BR+FLC+FRC
    7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
    7.1(top)       FL+FR+FC+LFE+BL+BR+TFL+TFR
    There must be match between source channel layout and destination supported channel layout - if target channel layout is different than source then perhaps you need to perform some downmixing - channel mixing operation accordingly to standard (unknown to me in case of layouts higher than 5.1).
    Quote Quote  
  14. Thanks pandy, I don't want to do any downmixing at all.
    Wanna preserve all the channels.

    Hope anyone can help me with encode DTS HD-MA 7.1 to AAC 7.1 (without losing any channel), here: https://forum.videohelp.com/threads/417937-Audio-DTS-conversion#post2772491
    Last edited by eddy89; 14th Apr 2025 at 13:54.
    Quote Quote  
  15. Originally Posted by eddy89 View Post
    Hope anyone can help me with encode DTS HD-MA 7.1 to AAC 7.1 (without losing any channel)
    This works for me:
    Code:
    FFmpeg.exe  -i "input_dts_ma_8ch.dts"  -c:a aac -b:a 512k -ar 48000  "output.aac"
    The output is aac 8ch.
    Quote Quote  
  16. Originally Posted by ProWo View Post
    Originally Posted by eddy89 View Post
    Hope anyone can help me with encode DTS HD-MA 7.1 to AAC 7.1 (without losing any channel)
    This works for me:
    Code:
    FFmpeg.exe  -i "input_dts_ma_8ch.dts"  -c:a aac -b:a 512k -ar 48000  "output.aac"
    The output is aac 8ch.
    I am trying to replicate the configuration (with less bitrate cause is insane at almost 900k) of a given release group movie (tigole), which has a AAC 7.1, allegedly properly done.
    Their configuration when I have a look in media info is this:
    Audio
    ID : 2
    Format : AAC LC
    Format/Info : Advanced Audio Codec Low Complexity
    Codec ID : A_AAC-2
    Duration : 1 h 53 min
    Bit rate : 897 kb/s
    Channel(s) : 8 channels
    Channel layout : C L R Ls Rs Lb Rb LFE
    Sampling rate : 48.0 kHz
    Frame rate : 46.875 FPS (1024 SPF)
    Compression mode : Lossy
    Delay relative to video : 20 ms
    Stream size : 728 MiB (5%)
    Language : English
    Default : Yes
    Forced : No
    And mine (with your command line), is this:
    General
    Complete name : /Users/legolas/Downloads/output.aac
    Format : ADTS
    Format/Info : Audio Data Transport Stream
    File size : 418 MiB
    Overall bit rate mode : Variable

    Audio
    Format : AAC LC
    Format/Info : Advanced Audio Codec Low Complexity
    Format version : Version 4
    Codec ID : 2
    Bit rate mode : Variable
    Channel(s) : 8 channels
    Channel layout : C L R Ls Rs Lw Rw LFE
    Sampling rate : 48.0 kHz
    Frame rate : 46.875 FPS (1024 SPF)
    Compression mode : Lossy
    Stream size : 418 MiB (100%)
    See how the channel layout is different! Lb Rb vs Lw Rw?? I don't understand what it means...
    Quote Quote  
  17. @ eddy89 ,
    Can you post a clip of the original audio you are working with ?
    ffmpeg can create clips & so can AviDemux.
    Other software can as well.
    The clip can be up to 500MB for most formats.
    A smaller clip would be better though .
    Just not too small.
    Quote Quote  
  18. I downloaded a file something like eddy89 has.
    This is the MediaInfo on this file with the video removed:
    Code:
    Audio
    ID                                       : 1
    Format                                   : DTS XLL
    Format/Info                              : Digital Theater Systems
    Commercial name                          : DTS-HD Master Audio
    Codec ID                                 : A_DTS
    Duration                                 : 49 s 54 ms
    Bit rate mode                            : Variable
    Channel(s)                               : 8 channels
    Channel layout                           : C L R LFE Lb Rb Lss Rss
    Sampling rate                            : 96.0 kHz
    Frame rate                               : 187.500 FPS (512 SPF)
    Bit depth                                : 24 bits
    Compression mode                         : Lossless
    Language                                 : English
    Default                                  : Yes
    Forced                                   : No
    This is the file using -c:a libfdk_aac in ffmpeg:
    Code:
    Audio
    ID                                       : 1
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : mp4a-40-2
    Duration                                 : 49 s 56 ms
    Source duration                          : 49 s 76 ms
    Bit rate mode                            : Constant
    Bit rate                                 : 1 257 kb/s
    Channel(s)                               : 8 channels
    Channel layout                           : C L R Ls Rs Lb Rb LFE
    Sampling rate                            : 96.0 kHz
    Frame rate                               : 93.750 FPS (1024 SPF)
    Compression mode                         : Lossy
    Stream size                              : 7.35 MiB (100%)
    Source stream size                       : 7.35 MiB (100%)
    Language                                 : English
    Default                                  : Yes
    Alternate group                          : 1
    The acronyms in Channel layout are different but I do not have any that are rw or lw.
    These are the errors I get when I use -c:a aac_at in ffmpeg:
    It appears that the Apple aac_at does not work with DTS-HD MA 7.1
    Code:
    [aac_at @ 006d8940] AudioToolbox init error: 1718449215
    [aost#0:0/aac_at @ 007114c0] [enc:aac_at @ 006d88c0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
    [af#0:0 @ 006d9640] Error sending frames to consumers: Unknown error occurred
    [af#0:0 @ 006d9640] Task finished with error code: -1313558101 (Unknown error occurred)
    [af#0:0 @ 006d9640] Terminating thread with return code -1313558101 (Unknown error occurred)
    [aost#0:0/aac_at @ 007114c0] [enc:aac_at @ 006d88c0] Could not open encoder before EOF
    [aost#0:0/aac_at @ 007114c0] Task finished with error code: -22 (Invalid argument)
    [aost#0:0/aac_at @ 007114c0] Terminating thread with return code -22 (Invalid argument)
    [out#0/ipod @ 006d8340] Nothing was written into output file, because at least one of its streams received no packets.
    Using ProWo's code MediaInfo:
    Code:
    Audio
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Format version                           : Version 4
    Codec ID                                 : 2
    Bit rate mode                            : Variable
    Channel(s)                               : 8 channels
    Channel layout                           : C L R Ls Rs Lw Rw LFE
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 46.875 FPS (1024 SPF)
    Compression mode                         : Lossy
    Stream size                              : 2.76 MiB (100%)
    Prowo's code with extension changed to .m4a:
    Code:
    Audio
    ID                                       : 1
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : mp4a-40-2
    Duration                                 : 49 s 56 ms
    Source duration                          : 49 s 76 ms
    Bit rate mode                            : Variable
    Bit rate                                 : 469 kb/s
    Maximum bit rate                         : 512 kb/s
    Channel(s)                               : 8 channels
    Channel layout                           : C L R Ls Rs Lw Rw LFE
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 46.875 FPS (1024 SPF)
    Compression mode                         : Lossy
    Stream size                              : 2.74 MiB (99%)
    Source stream size                       : 2.74 MiB (99%)
    Language                                 : English
    Default                                  : Yes
    Alternate group                          : 1
    It appears that the ffmpeg Native acc codec uses the lw & rw for the back surround speakers.
    Quote Quote  
  19. Originally Posted by cholla View Post
    @ eddy89 ,
    Can you post a clip of the original audio you are working with ?
    ffmpeg can create clips & so can AviDemux.
    Other software can as well.
    The clip can be up to 500MB for most formats.
    A smaller clip would be better though .
    Just not too small.
    Find it here (sorry, they are the full files, not clips):

    my compression with ProWo's command line.aac:
    https://1fichier.com/?8ibyukvj2yooofcqdjaj

    audio demuxed with mkvtoolnix from tigole group release.aac:
    https://1fichier.com/?cuw2q9o8ih7j01zwfoxc

    alleged original DTS 7.1 from another release.dts:
    https://1fichier.com/?7c8oc5zpqx1ux3w9cd5m

    Please have a look.

    Originally Posted by cholla View Post
    It appears that the ffmpeg Native acc codec uses the lw & rw for the back surround speakers.
    I don't know the meaning of lw and rw... Don't understand the difference. Can you elaborate and explain?

    Originally Posted by cholla View Post
    It appears that the Apple aac_at does not work with DTS-HD MA 7.1
    Weird, mine seems to work, the only problem is that it looses a channel.
    Code:
    Input #0, dts, from '...whatever.dts':
      Duration: N/A, start: 0.000000, bitrate: N/A
      Stream #0:0: Audio: dts (dca) (DTS-HD MA), 48000 Hz, 7.1, s32p (24 bit)
    Stream mapping:
      Stream #0:0 -> #0:0 (dts (dca) -> aac (aac_at))
    Press [q] to stop, [?] for help
    Output #0, adts, to '/Users/blah/Downloads/output2b.aac':
      Metadata:
        encoder         : Lavf61.7.100
      Stream #0:0: Audio: aac, 48000 Hz, 7.0, s16, 512 kb/s
          Metadata:
            encoder         : Lavc61.19.101 aac_at
    [out#0/adts @ 0x7fd3dd906e00] video:0KiB audio:425472KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.512698%
    size=  427653KiB time=01:53:27.48 bitrate= 514.6kbits/s speed=23.4x
    It looses a channel, but at least does not error out... (ProWo's command line, just adding the aac_at codec), although it seems quite dodgy being able to detect 8 channels but outputting 7.

    Originally Posted by cholla View Post
    This is the file using -c:a libfdk_aac in ffmpeg:
    Just installed the libfdk_aac, and when I use it, the channel layout is what you said: it is not the same as the default aac.

    Related with that, when I use the "libfdk_aac" instead of the normal "aac", with ProWo's command line, the bitrate is not variable anymore, maybe the default configuration with the libfdk_aac is different than the standard?

    Thank you very much
    Last edited by eddy89; 17th Apr 2025 at 05:57.
    Quote Quote  
  20. Originally Posted by eddy89 View Post
    I don't know the meaning of lw and rw... Don't understand the difference. Can you elaborate and explain?
    I'm not sure eother.I believe that lw and rw are left wide & right wide.
    I believe this is the same as lb & rb. Left back & Right back.
    I believe on an amp these would come from the same jacks.
    The positioning of the speakers might be a little different for the best listening.
    An object-based format instead of an area based format.
    Maybe a more knowledgeable member can explain this better.


    Originally Posted by eddy89 View Post
    Weird, mine seems to work, the only problem is that it looses a channel.
    It looses a channel, but at least does not error out... (ProWo's command line, just adding the aac_at codec), although it seems quite dodgy being able to detect 8 channels but outputting 7.
    It may be the sample file I'm using. I just got one from the internet.
    I will see how it works when I download the last file you posted.
    The site requires an hour wait between downloads.

    Originally Posted by eddy89 View Post
    Just installed the libfdk_aac, and when I use it, the channel layout is what you said: it is not the same as the default aac.

    Related with that, when I use the "libfdk_aac" instead of the normal "aac", with ProWo's command line, the bitrate is not variable anymore, maybe the default configuration with the libfdk_aac is different than the standard?
    This is a variation of ProWo's code:Give it a try

    Code:
    ffmpeg -i input_dts_ma_8ch.dts -c:a libfdk_aac -vbr 5 output.aac
    OR
    ffmpeg -i input_dts_ma_8ch.dts -c:a libfdk_aac -vbr 5 output.m4a
    I will post the results when I download the last file.
    Quote Quote  
  21. I tried using fmpeg channelmap but it would not change the channel order on a aac_at.

    Original DTS file: Channel layout: C L R LFE Lb Rb Lss Rss
    Without the -ac 8 added to the code it always had 7 channels.
    It left out the LFE channel.
    Channel layout : C L R Ls Rs Lb Rb
    With the -ac 8 added to the code it had the LFE channel
    Channel layout : C L R LFE Lb Rb Lss Rss

    Try this code:
    Code:
    ffmpeg -i input.dts -c:a aac_at -aac_at_quality 0 -aac_at_mode vbr -b:a 512k -ac 8 output.aac
    This is a picture of the speaker locations & the channel acronyms:
    Image
    [Attachment 86640 - Click to enlarge]


    This is a clip cut from the original.dts.
    It is much smaller but MediaInfo reads it the same except for size.
    Image Attached Files
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!