VideoHelp Forum




+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 40
  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  
  22. First of all, sorry about the delay. The last weeks were tough for personal reasons and I couldn't find the time.

    Originally Posted by cholla View Post
    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.
    That's too much to guess. It would be lovely if someone knowledgeable could reply about it, please!!

    Originally Posted by cholla View Post
    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
    Not very concern about vbr right now, but in this case I would use -vbr 4, as 5 is waaaay too much (vbr 4 is more like 512Kb, which is fine)

    Originally Posted by cholla View Post
    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
    I already figured out the "-ac 8" in the current thread (post number 5) long time ago, so nothing new in that regard.
    My only concern is if it is doing correctly, the 8 channels with the proper information in each of them. Does anyone know about it?
    Is so weird that unless you use the -ac 8 flag, the encoder get rid of a channel without any reason, and I am a little worried that just adding the flag it does not solve the situation entirely for any given reason.

    Originally Posted by cholla View Post
    This is a picture of the speaker locations & the channel acronyms:
    Image
    [Attachment 86640 - Click to enlarge]
    That's very informative!! Would love if someone could explain the differences between the formats that mediainfo read from the produced files from Fraunhofer and Apple AAC encodes.
    Maybe the naming of the channel is not important and is how Apple/Fraunhoffer handles the naming of them, but with no difference in the output.


    As I still not have a 7.1 rig to test, I would love if someone could test the following.
    I created a file with a movie in which I added different audio streams (I am not very concern about VBR vs CBR):
    1) Fraunhofer AAC 7.1 CBR 512K, created encoding the third audio stream with the following command:
    Code:
    ffmpeg -i audio.dts -c:a libfdk_aac -b:a 512k -ar 48000 71fdkcbr512k.aac
    2) Apple AAC 7.1 CBR 512K, created encoding the third audio stream with the following command:
    Code:
    ffmpeg -i audio.dts -c:a aac_at -b:a 512k -ac 8 71applecbr512k.aac
    3) DTS-MA original file from where I encode the previous two files.
    Find it here: https://1fichier.com/?cr31xyuf9mr5mwdttduy

    Questions:
    1) Independently of the quality of each of them, does all of them sound correctly in a 7.1 equipment?
    2) Is there any relevant better quality in the first two?
    3) Are them a fair conversion of the third file?

    Thank you very much for your help and suggestions guys!

    E.
    Last edited by eddy89; 6th May 2025 at 09:05.
    Quote Quote  
  23. The way AAC is supposed to work, if there's not specific channel info (PCEs), it starts encoding with the centre channel, encodes each stereo pair from front to back and finishes with the rear/mono channel, I think (if it exists). The DTS encoding order is different to the standard wave file channel layout, and different to AC3 from memory, but the original audio should be decoded in the standard wave file channel order, encoded in whatever order the codec prefers, and when the encoded version is played it should be decoded using the wave file channel order too.

    For a long time ffmpeg and some other AAC encoders used a "'hack" for encoding and decoding 7.1ch.
    I don't know how much of it's still relevant, but I wrote a mini essay on the topic a while back. There's a ffmpeg option to tell it to decode 7.1ch AAC correctly, but it's not enabled by default, as far as I know.
    https://forum.videohelp.com/threads/377639-7-1ch-AAC-encoding

    Not that I encode much 7.1ch audio.
    5.1ch has 3 channels too many as it is, in my opinion.
    I'll try a couple of the uploaded samples later if they every finish downloading.

    For foobar2000 users, there's an option in preferences/advanced/decoding to tell ffmpeg to decode 7.1ch AAC correctly. You have to set 1 for the -strict level setting.
    As long as the output meters show the same thing for the source and the encoded version. I think everything's fine.

    Maybe ffmpeg needs -ac 8 in order to use PCEs and encode 7.1 rear correctly, and without it, it's assuming a default AAC layout.... maybe....
    Last edited by hello_hello; 6th May 2025 at 05:25.
    Quote Quote  
  24. First of all thanks for your reply and taking your time to read.

    Originally Posted by hello_hello View Post
    The way AAC is supposed to work, if there's not specific channel info (PCEs), it starts encoding with the centre channel, encodes each stereo pair from front to back and finishes with the rear/mono channel, I think (if it exists). The DTS encoding order is different to the standard wave file channel layout, and different to AC3 from memory, but the original audio should be decoded in the standard wave file channel order, encoded in whatever order the codec prefers, and when the encoded version is played it should be decoded using the wave file channel order too.
    Great info. Thanks. Should be great to know if as per today, it still works the same way.

    Originally Posted by hello_hello View Post
    For a long time ffmpeg and some other AAC encoders used a "'hack" for encoding and decoding 7.1ch.
    I don't know how much of it's still relevant, but I wrote a mini essay on the topic a while back. There's a ffmpeg option to tell it to decode 7.1ch AAC correctly, but it's not enabled by default, as far as I know.
    https://forum.videohelp.com/threads/377639-7-1ch-AAC-encoding
    Will read it, thanks.
    EDIT: read it, jeez is exactly what I feared!! These post that I started is just for making sure that what I am encoding is correct and I am not doing it wrong and losing lossless stream for bad encoding.

    Originally Posted by hello_hello View Post
    Not that I encode much 7.1ch audio.
    5.1ch has 3 channels too many as it is, in my opinion.
    I'll try a couple of the uploaded samples later if they every finish downloading.
    Better try just my last file (of my previous post), in which you have everything there that you need (aac fraunhofer, apple and the source dts in the same movie file and already encoded, ffmpeg native aac is out of the scope for its much less quality). It could take some minutes, but you have everything at once and not need to download several things.
    EDIT: after reading your essay, I think it would be REALLY useful if you download this last file and have a look at it. It would HELP a lot with my questions and probably solve all my doubts and fears. You will have ALL THE INFO there and have a look on what I did in a proper example. I could find others afterwards if needed as per your request.

    Originally Posted by hello_hello View Post
    For foobar2000 users, there's an option in preferences/advanced/decoding to tell ffmpeg to decode 7.1ch AAC correctly. You have to set 1 for the -strict level setting.
    Sadly, macOS foobar2000 is not like the Windows one, and is not a complete version of the program -it does not have anything regarding encoding-, so there are no foobar2000 users in macOS. So it does not apply to me.

    Originally Posted by hello_hello View Post
    As long as the output meters show the same thing for the source and the encoded version. I think everything's fine.
    Don't know what you mean of output meters.

    Originally Posted by hello_hello View Post
    Maybe ffmpeg needs -ac 8 in order to use PCEs and encode 7.1 rear correctly, and without it, it's assuming a default AAC layout.... maybe....
    Although I am sure you know about it, let me clarify something just in case was not clear for everyone. From the 3 different aac encoders which can be used with ffmpeg (native -less quality-, fraunhofer -more quality- and apple -best quality-, source), when we are talking about the "-ac 8", is JUST needed for the apple encoder -otherwise it loses a channel-, the native ffmpeg and the fraunhofer ones don't need it. Which is weird and inconsistant.
    Last edited by eddy89; 6th May 2025 at 07:07.
    Quote Quote  
  25. I tried the previously uploaded samples, ADTS and Ex Machina.
    For ffmpeg (no mixdown in the commend line) everything seems fine, so long as -strict 1 is used for decoding, otherwise the surround channels are decoded as front.
    Unexpectedly, QAAC seems to be encoding the surround channels incorrectly. I suppose I should report it to the developer, assuming it's not me doing something silly. Instead of SL and SR being a pair, it seems that BR and SR are a pair, as are BL and SL. Odd.....
    According to the info here, QAAC defaults to 7.1ch rear if there's no PCEs present, so I'm not sure why the surround channels appear to be mixed up.

    I've asked about it in the foobar2000 forum.
    https://hydrogenaudio.org/index.php/topic,127832.msg1062685.html#msg1062685
    Quote Quote  
  26. Originally Posted by eddy89 View Post
    Don't know what you mean of output meters.
    foobar2000's output meters.

    I've no idea what encoder ffmpeg was using when I ran some test encodes. The command line was simply -c:a aac -q:a 3 but it gave me a 7.1ch output. As a side note, according to the info here. 8ch AAC doesn't have an LFE channel. https://github.com/nu774/qaac/wiki/Multichannel--handling
    Using -strict 1 for decoding, the channels are where they should be for the ffmpeg encode. Without it foobar2000/ffmpeg decodes it as 7.1ch front. Maybe that's because ffmpeg isn't using PCEs. I don't know.

    For QAAC there's something amiss. Stuff coming out the wrong holes for some reason.....

    Image
    [Attachment 86850 - Click to enlarge]


    Image
    [Attachment 86851 - Click to enlarge]
    Quote Quote  
  27. Originally Posted by eddy89 View Post
    Sadly, macOS foobar2000 is not like the Windows one, and is not a complete version of the program -it does not have anything regarding encoding-, so there are no foobar2000 users in macOS. So it does not apply to me.
    I haven't tried the Mac version, but the Windows foobar2000 runs fine in Wine on Linux. I haven't tried it in Wine on a MAC though.
    Quote Quote  
  28. Duplicated, sorry.
    Last edited by eddy89; 6th May 2025 at 07:49. Reason: Duplicated, sorry.
    Quote Quote  
  29. This is how foobar2000 decoded the audio. The first AAC track looks okay, but the second one, not so much.

    By the way, you can import the audio with Audacity directly (I assume there's a Mac version) and it'll do the same thing... decode and import in the wave file channel order... so regardless of the codec and the channel order it uses, if they're not the same after they're imported into Audacity, something's wrong.


    DTS
    Image
    [Attachment 86854 - Click to enlarge]


    AAC1
    Image
    [Attachment 86855 - Click to enlarge]


    AAC2
    Image
    [Attachment 86856 - Click to enlarge]
    Last edited by hello_hello; 6th May 2025 at 07:48.
    Quote Quote  
  30. Originally Posted by hello_hello View Post
    I tried the previously uploaded samples, ADTS and Ex Machina.
    For ffmpeg (no mixdown in the commend line) everything seems fine, so long as -strict 1 is used for decoding, otherwise the surround channels are decoded as front.
    For decoding I solely use Plex (as I have all the movies in my NAS server), so I am not sure if I could be able to use strict 1 with it...

    Going for parts, let's narrow things just regarding Ex Machina. I guess you had a look into the 3 audio streams. You have the command line I used for encoding the first 2 streams (as the third one is the original stream from which I encode the previous two), and as you can see I haven't use the -strict 1 flag, if it is needed for encoding (not sure if it is just for decoding or encoding too, as for encoding needs to be decoded first).
    The output info using mediainfo of the 1st stream (fraunhofer) is: C L R Ls Rs Lb Rb LFE
    The output info using mediainfo of the 2nd stream (apple) is: C L R Ls Rs Lw Rw LFE
    The output info using mediainfo of the 3rd stream (native DTS) is: C L R LFE Lb Rb Lss Rss
    As you can see are different.
    I guess the apple is the incorrect one and fraunhofer is correct and could be played properly? Both are correct? None are correct?
    If Fraunhofer is the correct one, maybe the safest bet is just using Fraunhofer and don't use apple anymore?

    Regarding strict 1. Do I have to use it with any aac encoder (fraunhofer/apple/native) being used with ffmpeg? Maybe as per today is not needed anymore, your essay is from 9 years ago.

    Not sure if this charts are referring the Ex machina or other files.

    Wanna mention, although I can manage and I am not using translating services, my native language is not English, so I could have language gaps. I would appreciate if you don't make assumptions when you explain, mostly for what file/stream are you analizing, etc...

    Thank you very much for all your replies, they are very useful and I am sure that I will be able to understand the problems/solutions fully and how to do it properly.
    Last edited by eddy89; 6th May 2025 at 07:57.
    Quote Quote  



Similar Threads

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