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.aacCode: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.aacPlease kindly assist.Code:C L R Ls Rs LFE <-- 5.1.dts L R C Cb Lb Rb <-- 5.1.aac
+ Reply to Thread
Results 1 to 30 of 40
-
-
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. -
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
Code:Channel layout : C L R Ls Rs Lw Rw LFE
Last edited by eddy89; 31st Mar 2025 at 12:41.
-
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
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
Code:Channel(s) : 7 channels Channel layout : C L R Ls Rs Lb Rb
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
Hope anyone can put some light here.
ThanksLast edited by eddy89; 31st Mar 2025 at 13:58.
-
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
-
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_AACLast edited by cholla; 2nd Apr 2025 at 12:19.
-
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 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. -
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
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
-
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#post2772491Last edited by eddy89; 14th Apr 2025 at 13:54.
-
-
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
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%) -
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
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
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.
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%)
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
-
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.
I don't know the meaning of lw and rw... Don't understand the difference. Can you elaborate and explain?
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
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 muchLast edited by eddy89; 17th Apr 2025 at 05:57.
-
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.
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.
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 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
[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. -
First of all, sorry about the delay. The last weeks were tough for personal reasons and I couldn't find the time.
That's too much to guess. It would be lovely if someone knowledgeable could reply about it, please!!
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)
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.
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
Code:ffmpeg -i audio.dts -c:a aac_at -b:a 512k -ac 8 71applecbr512k.aac
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.
-
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.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
First of all thanks for your reply and taking your time to read.
Great info. Thanks. Should be great to know if as per today, it still works the same way.
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.
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.
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.
Don't know what you mean of output meters.
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.
-
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#msg1062685Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
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.....
[Attachment 86850 - Click to enlarge]
[Attachment 86851 - Click to enlarge]Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
Duplicated, sorry.
Last edited by eddy89; 6th May 2025 at 07:49. Reason: Duplicated, sorry.
-
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
[Attachment 86854 - Click to enlarge]
AAC1
[Attachment 86855 - Click to enlarge]
AAC2
[Attachment 86856 - Click to enlarge]Last edited by hello_hello; 6th May 2025 at 07:48.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
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.
Similar Threads
-
Downmixing 6 channel AAC to 2 channel?
By bizzybody in forum Video ConversionReplies: 33Last Post: 12th Nov 2017, 10:19 -
Convert 6 Channel AAC to 6 Channel AC3
By TheRandomOne in forum AudioReplies: 18Last Post: 4th Jul 2017, 10:40 -
Handbrake without FDK-AAC, new FFMPEG AAC encoder viable alternative?
By jaggy in forum Video ConversionReplies: 15Last Post: 27th Apr 2017, 10:31 -
How to see a 5.1 file's channel layout? + Channel layout error with ffmpeg
By HoraceMcMahon in forum AudioReplies: 30Last Post: 10th May 2016, 21:00 -
FFMpeg and channel layout
By alexander121 in forum AudioReplies: 4Last Post: 22nd Mar 2015, 02:27