View Full Version : AAC in matroska
ChristianHJW
18th May 2003, 08:46
Hi people,
title says it all. I was asking in the AAC forums on hydrogenaudio.org already (http://www.hydrogenaudio.org/index.php?act=ST&f=14&t=9528&st=0&#entry95448), as Ivan and Menno are reading there often, but didnt get any sensible reply yet.
Background is, Mosu can mux AAC into matroska on mkvmerger ( yes, there will be a win32 binary of this and a GUI :D ) and we have to care about correct mapping of all the different AAC profiles to the correct GUIDs from our DShow parser, so people can start using AAC in matroska ;) ...
DSPguru
18th May 2003, 09:05
i believe nic used the wFormat tag of 255.
ChristianHJW
18th May 2003, 13:08
Toff has AAC from matroska working :) .. he was using the funny DShow filter from Borgtech, the one they did for their proprietary MPX container, and mapped the wFormat tag they use ( 0xAAC0 ) from the matroska DShow parser :) ....
ChristianHJW
18th May 2003, 17:44
After more than 2 years hanging out here i actually dont know if this should be posted in the 'New A/V formats' forum or here .. LOL. If the mods here feel it doesnt belong here, feel free to move it ;) !
Toff and Mosu got it working :) !
Since yesterday mkvmerger can mux AAC audio into matroska audio and video files, and mplayer can play these files on Linux, almost same time !
Now, the good news for all Windows users is, mkvmerger will compile fine on cygwin, so we have a win32 version of it also :) ! Jcsston is already working on the GUI for it, but until then you guys will have to use CLI :D ....
Toff on the other hand fixed our DShow parser, he mapped the matroska codec IDs for AAC to call borgtech's fancy AAC Dshow filter ( its using a very unusual and unoffical wFormat tag, '0xAAC0' ), and it plays just fine :) .
Give us some time to make a nice package for you to upload, and you guys can start playing with it ...
Christian
Animaniac
19th May 2003, 04:31
Originally posted by ChristianHJW
After more than 2 years hanging out here i actually dont know if this should be posted in the 'New A/V formats' forum or here .. LOL. If the mods here feel it doesnt belong here, feel free to move it ;) !
Toff and Mosu got it working :) !
Since yesterday mkvmerger can mux AAC audio into matroska audio and video files, and mplayer can play these files on Linux, almost same time !
Now, the good news for all Windows users is, mkvmerger will compile fine on cygwin, so we have a win32 version of it also :) ! Jcsston is already working on the GUI for it, but until then you guys will have to use CLI :D ....
Toff on the other hand fixed our DShow parser, he mapped the matroska codec IDs for AAC to call borgtech's fancy AAC Dshow filter ( its using a very unusual and unoffical wFormat tag, '0xAAC0' ), and it plays just fine :) .
Give us some time to make a nice package for you to upload, and you guys can start playing with it ...
Christian
It would be nice if it could map to the 3ivx audio DS decoder (which I believe is independent from the MP4 paser DS filter which comes with 3ivx), since that seems to be more standard, i.e. it works with AAC in MP4 (and M4A). Borg's decoder usese a made wFormat tag (as the commenting in the code indicates). I'm not certain how 3ivx does it (since there may not be an official wFormat tag in Windows for AAC yet), but it seems to be more universal. Plus, most people who want AAC have 3ivx installed, rather than Borg which works with a nonstandard MPX container. Just my 2 cents.
killingspree
19th May 2003, 12:28
nice i'm really looking forward to matroska with aac (:
btw: does anybody know something about the channel cupling status? is it working already?
regards
steVe
ChristianHJW
19th May 2003, 12:37
Currently we cant use the 3ivX filter from matroska, as it cant play AAC files but only AAC from MP4, and if you look at the way we are muxing AAC into matroska, we do this including AAC headers, so the 3ivX filter doesnt want to play our stuff ....
Things may change soon though, as we were convinced yesterday from the AAC experts on hydrogenaudio.org ( mainly rjamorim ) that it would be better to store AAC audio as elementary streams inside matroska, just like what MP4 does. This way we can easily transmux a complete MP4 file including AAC audio into matroska, e.g. to edit it in VdubMod, and transmux the file to MP4 container afterwards.
Our concerns about leaving the headers with the AAC stream were related to be able to use external hardware decoders, like what many people are doing with AC3 now, but we had to learn that there are no proper specs yet of what such AAC hardware decoders have to be able to accept on their input, and after all they must be able to play AAC coming from MP4 in any case, so there must be a way somehow.
Toff found out that the 3ivX AAC filter expects some 'private data' to be transmitted to it for initialization, its transferred to it from the 3ivX splitter/parser filter using DirectShow means, at the end of the 'WAVEFORMATEX' structure. We dont know yet what kind of data 3ivX are transferring there, but its obviously something called 'Decoder Config Descriptor' that FAAD2 needs to be able to start decoding.
We dont know how the Borgtech filter is handling these things, but it seems to get this type of info from the AAC header, being a good indication that they store the AAC including headers inside their MPX container ....
tiki4
19th May 2003, 15:29
So, that's the reason why it libfaad always crashed on me, when I changed wFormatTag last week. Obviously the 3ivx splitter filter doesn't provide the necessary data for FAAD2. Thumbs up, get it going!
tiki4
shitowax
20th May 2003, 00:45
I just looked at the borgsoft decoder. It doesn't use any decoderSpecific initialization, it doesn't support audio chunks (only frames), and finally doesn't check errors properly...
No chance it could work as is connected to the 3ivx splitter. Anyway, it wasn't written with this goal in mind ...
The minimum requirements would be to call
/* Init the library using a DecoderSpecificInfo */
char FAADAPI faacDecInit2(faacDecHandle hDecoder, unsigned char *pBuffer, unsigned long SizeOfDecoderSpecificInfo, unsigned long *samplerate, unsigned char *channels);
with the end of the WAVEFORMATEX structure before calling the first faacDecDecode ...
ChristianHJW
20th May 2003, 07:08
Mosu has AAC finally working, including muxing from mkvmerger ( also win32 binaries ). This is what he wrote on the ML :
Hi guys.
I've got it working now: all ADTS headers are stripped from the AAC
stream. Win32 binaries can be found at
http://www.bunkus.org/videotools/mkvtoolnix/win32/mkvtoolnix-20030519-1.zip
This is how the demuxer works: First it gathers all relevant Matroska
elements. Then the private data for AAC (libfaad2 in this case) is
reconstructed in the same way it is stored in MP4 which looks like this:
// Recreate the 'private data' which faad2 uses in its
initialization.
// A_AAC/MPEG2/MAIN
// 0123456789012345
if (!strcmp(&track->codec_id[12], "MAIN"))
profile = 0;
else if (!strcmp(&track->codec_id[12], "LC"))
profile = 1;
else if (!strcmp(&track->codec_id[12], "SSR"))
profile = 2;
else
profile = 3;
if (92017 <= sh_a->samplerate)
srate_idx = 0;
else if (75132 <= sh_a->samplerate)
srate_idx = 1;
else if (55426 <= sh_a->samplerate)
srate_idx = 2;
else if (46009 <= sh_a->samplerate)
srate_idx = 3;
else if (37566 <= sh_a->samplerate)
srate_idx = 4;
else if (27713 <= sh_a->samplerate)
srate_idx = 5;
else if (23004 <= sh_a->samplerate)
srate_idx = 6;
else if (18783 <= sh_a->samplerate)
srate_idx = 7;
else if (13856 <= sh_a->samplerate)
srate_idx = 8;
else if (11502 <= sh_a->samplerate)
srate_idx = 9;
else if (9391 <= sh_a->samplerate)
srate_idx = 10;
else
srate_idx = 11;
sh_a->codecdata = (unsigned char *)calloc(1, 2);
sh_a->codecdata_len = 2;
sh_a->codecdata[0] = ((profile + 1) << 3) | ((srate_idx & 0xe) >> 1);
sh_a->codecdata[1] = ((srate_idx & 0x1) << 7) | (track->a_channels << 3);
(Simply copied from the MPlayer demuxer.)
My guess is that you'll need something similar for the DS filters.
-- ==> Ciao, Mosu (Moritz Bunkus)
ChristianHJW
21st May 2003, 00:05
Ok guys, this is an unofficial release, only for the true matroska and AAC fans :
http://www.bunkus.org/videotools/mkvtoolnix/win32/mkvtoolnix-20030519-1.zip
A Typical command line for Mosu's win32 binaries of mkvmerge was something like
x:\mkvmerge\mkvmerge.exe -o y:\movies\movie.mkv -A y:\movies\movie.avi y:\soundtracks\movie.aac
Here is the alpha matroska DShow parser filter for that ( with mapping to 0xAAC1 still ) , inlcuding a compiled version of the borgtech AAC DShow filter with some special mods made by Toff.
http://matroska.org/downloads/mkxds_aac_borgtech(included)_20030520.rar
These binaries will only be up for a very short time, so you better hurry up ;) ...
ChristianHJW
21st May 2003, 20:31
ok, as posted elsewhere already, there is a new version of the modified Borgtech filter from Toff in the 'CoreAAC' CVS now .... but we took the link to the binaries down, as said before.
Here is the link to the latest matroska parser filter including official AAC DS support :
http://matroska.sourceforge.net/downloads/mkxds_aac_multichannel_20030521-2.rar
It should work fine with 3ivX AAC decoder filter, or with latest compiles of CoreAAC, and this will include 5.1 AAC playback support ;) ...
Atamido
21st May 2003, 20:43
I was able to confirm correct playback of all 5 channels on my surround system.
I used the 5.1 AC3 test that was converted to AAC, placed in MKA, and played with the CoreAAC filter.
(The only difference between MKA and MKV is the lack of any video track)
Ramirez
21st May 2003, 21:52
I couldn't get it to work here, Mkvmerge app terminates it self with the following error:
Using AVI demultiplexer for xvid.avi. Opening file. This may take some time depending on the file's size.
+-> Using video output module for video stream.
Die @ r_avi.cpp/186: in safemalloc: malloc == NULL
The source files where plain xvid avi and aac 128 vbr.
Originally posted by Ramirez
I couldn't get it to work here, Mkvmerge app terminates it self with the following error:
Using AVI demultiplexer for xvid.avi. Opening file. This may take some time depending on the file's size.
+-> Using video output module for video stream.
Die @ r_avi.cpp/186: in safemalloc: malloc == NULL
The source files where plain xvid avi and aac 128 vbr.
Looks like an AVI that cannot be handled correctly at the moment. This is a typical problem that I cannot debug without having a sample file, so please try to make a short sample from that AVI and upload it somewhere. Make sure that the short sample shows the same behaviour.
Also make sure you've included '-A' as a parameter on the command line directly before the AVI.
Ramirez: jcsston just told me that he had the same problem, and in his case it was solved be removing any old cygwin1.dll and cygiconv-2.dll he had lying around somewhere else, e.g. c:\windows\system32. Maybe you can try to see if you have older versions and temporarily move them out of harm's way.
Ramirez
21st May 2003, 23:47
Nope,there is no other dlls; they all located in c:\mkvtool dir.
I used the following command line argument (All source files located in the same dir)
mkvmerge.exe -o output.mkv -A video.avi audio.aac
Here (http://www.geocities.com/ramirez4good/sample.avi) is the sample clip (Only 2 transfers per hour allowed, geocities sux!
If you won't be able to D/L this file, I'll send it directly to your email later on)
BoNz1
22nd May 2003, 01:02
I get a similar problem as ramirez is getting. Here is what it says:
C:\Program Files\Matroska>mkvmerge -o "c:\signs.mkv" -A "C:\Signs\Video_TS\Signstest.avi" "C:\Signs\Video_TS\Signs.aac"
Using AVI demultiplexer for C:\Signs\Video_TS\Signstest.avi. Opening file. This may take some time depending on the file's size.
+-> Using video output module for video stream.
Using AAC demultiplexer for C:\Signs\Video_TS\Signs.aac.
+-> Using AAC output module for audio stream.
I have cut a small part of the avi like you suggested to ramirez, if you would like me to cut some of the aac I can do that as well. The aac was created in Nero, I think this may also be a problem. What have you guys been using to test this? I think the headers are a little different in Nero as opposed to PysTEL so this may cause problems, anyhow let me know if you want a sample of the audio. The video you can download here, http://www.geocities.com/bonzi5252/Signstest.avi I am going to try to mux it into a mp4 and play it to see if that works latter today. Please people don't download the file since geocities sucks so much and then the people who might be able to fix this will not be able to get the file. And thank you all for making this aac directshow filter a possibility, everyone around here knows I have been bugging people about making this for a while now, thanks for listening. :)
EDIT: Oh I saw that mosu posted the version that they want to be spread not the one I got, http://article.gmane.org/gmane.comp.multimedia.matroska.general/394 so I can try that and post back for that too. Oh yeah, I forgot to say what the actual problem was :rolleyes: when it outputs these messages it just hangs, and uses 100% cpu, but does nothing. It isn't that I am impatient I left it doing this all last night, ;)
Ramirez
22nd May 2003, 01:42
I just tried that new build (0.4.0) nothing changed.
@Bonz1
How exactly you're cutting AAC stream?
BoNz1
22nd May 2003, 01:50
Easy, besplit, http://besweet.notrace.dk/ read the docs that come with it for more info, ;).
EDIT: Ok, a cut some of the aac encoded in Nero, it is definitely causing the problem with mkvmerge, I used PysTEL with the same switches etc and it works. So here is the audio encoded with Nero. Nero outputs a mp4 file so you have to extract it too so this could be what is causing the problem as well, but anyhow here it is, http://www.geocities.com/bonzi5252/track01.zip
ChristianHJW
22nd May 2003, 07:50
Guys, try this new release of mkvmerger :
http://www.bunkus.org/videotools/mkvtoolnix/win32/mkvtoolnix-0.4.0.zip
Originally posted by BoNz1
EDIT: Ok, a cut some of the aac encoded in Nero, it is definitely causing the problem with mkvmerge, I used PysTEL with the same switches etc and it works. So here is the audio encoded with Nero. Nero outputs a mp4 file so you have to extract it too so this could be what is causing the problem as well, but anyhow here it is, http://www.geocities.com/bonzi5252/track01.zip
I don't support MP4 at the moment. I should probably add a check if it's MP4 and output an error message then.
BoNz1
22nd May 2003, 17:40
Originally posted by Mosu
I don't support MP4 at the moment. I should probably add a check if it's MP4 and output an error message then.
No, sorry, you misunderstood, my fault though I should have been a little clearer. I extracted a .aac file from the mp4 using mp4creator and a commandline something like this, mp4creator -extract=1 "c:\audio.mp4" "c:\audio.aac" and this was the file which wouldn't mux in mkvmerger. I am pretty sure this is the right commandline, if it isn't maybe someone will help me get the correct one. I then cut part of this file with besplit and uploaded it, unfortunately, something is screwed up with the zip file so it won't even open, (just checked right now) so I will try getting a better sample for you. Sorry for the misunderstanding. :)
Ah, I see. Ok I'll wait for feedback from you then. You can also send the file via email if you don't trust geocities (I usually don't): moritz@bunkus.org
ChristianHJW
22nd May 2003, 18:00
Hmmm ... is it possible that the MP4 demuxer forgets to add AAC headers to the AAC stream, thus leaving it as a raw AAC stream ? Just guessing, sorry ...
BoNz1
22nd May 2003, 20:55
Ok, I think I found the problem, I found a hacked version of mp4creator on rarewares that will put the proper adts mpeg2 header on the aac. This seems to work, however with a mpeg4 header (which is not spec compliant) it will crash mkvmerge and just hang like before, I guess the official version puts a mpeg4 header by default. Probably you guys have been testing with PysTEL, this will give files with mpeg2 headers, which is spec compliant now, check out this thread, http://www.hydrogenaudio.org/index.php?act=ST&f=14&t=5035& I think I said in my previous post that PysTEL will put mpeg4 headers, this isn't correct, however there is a demo version that does, IIRC. If I use the -mpeg-version 2 switch in the hacked mp4creator it works in mkvmerge. I uploaded a small sample of the file with the mpeg4 header, for you mosu, http://www.geocities.com/bonzi5252/track01.zip I think for now though Nero users should use this hacked mpeg4creator and use this commandline:
mp4creator60 -extract=1 "c:\test.mp4" "c:\test.aac" -mpeg-version 2
I think Nero also has an option to output aac too, you can try this as well but I can't seem to get it to work, maybe I should get the latest version of Nero, ;)
EDIT: Got the aac directshow to work too, it works very nicely. :)
tiki4
23rd May 2003, 08:04
Yes, get latest version of NERO. By default NERO will produce an MP4 containing AAC audio with MPEG4 ADTS header. If you choose the option export ISO-AAC... you also get an AAC file with MPEG2 ADTS header. Works here without any problems.
tiki4
Originally posted by tiki4
Yes, get latest version of NERO. By default NERO will produce an MP4 containing AAC audio with MPEG4 ADTS header.
You mean it keeps the ADTS headers for all packets, even in the MP4 container? Now that would be ridiculous...
tiki4
23rd May 2003, 14:33
@Mosu:
No! I just said, that if you run mp4info over the Nero MP4 file it displays 'MPEG 4 audio'. If you take aacinfo and run it over the exported AAC track you get 'MPEG 2 audio'. All right?
tiki4
Ramirez
1st June 2003, 00:22
Hey there,I've notice that when playing WMV9+AAC the audio gets totally out of sync, can you guys check where is the problem might be.(no problems with XVID+AAC)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.