View Full Version : DTS in an AVI file
maormini
2nd December 2002, 12:39
I searched the forum up and down, went through alot of posts but there is still no answer whether it's possible to extract and then mux a DTS sound stream with a DivX encoded avi file!
Is it possible at all, and if so PLEASE give me the method!
rjamorim
2nd December 2002, 14:03
Well, I guess possible to mux it is.
But there's no way you'll be able to playback this AVI. (Unless you maybe use InterVideo Platinum... it can playback DivX, and DTS, but I wonder if it can playback both at once... humm...)
alexnoe
2nd December 2002, 14:45
If someone could provide me frameheader specs of DTS, then I could try to implement DTS support into AVI-Mux GUI!
Afaik, Intervideo AC3 filter can playback DTS, so this should not be the problem.
DJ Bobo
2nd December 2002, 14:50
Implementing DTS support for AVI is senseless anyway. DTS has such high bitrates (768kbps and more) that it just doesn't make any sense to mux it with an AVI. You won't go under 3-CD-Rips if you wanna use DTS :eek:
E-Male
2nd December 2002, 16:49
depending on the lenth of the movie i could also b a 2cd rip
and for some movies it would definitivle worth it
DSPguru
2nd December 2002, 18:18
Originally posted by alexnoe
If someone could provide me frameheader specs of DTS, then I could try to implement DTS support into AVI-Mux GUI!
Afaik, Intervideo AC3 filter can playback DTS, so this should not be the problem. http://forum.doom9.org/showthread.php?s=&threadid=34958
alexnoe
2nd December 2002, 19:02
Why do you speak in sizes of CDs actually? What about putting 2 divX movies onto one DVD-R?
E-Male
3rd December 2002, 00:43
well, i cross fingers this will work
DJ Bobo
3rd December 2002, 13:09
@ alexnoe
Good point! never thought about it... (don't have a DVD-R burner)
alexnoe
3rd December 2002, 13:11
But you certainly want one ;)
DJ Bobo
3rd December 2002, 15:37
Oh yeah! if you lend me some money :D
alexnoe
22nd December 2002, 13:21
I got hand on a DTS frame header description which seems to be accurate enough to add DTS support to AVI-Mux GUI.
Problem: The AC3fromAVI-filter will send it as AC3 to the decoder (it seems to interprete a wFormatTag of 0x2000 as AC3), which therefore does not replay anything (already tried it).
Since I have absolutely no knowledge on DirectShow programming: Could someone modify the AC3fromAVIfilter either to handle both DTS and AC3 (and add a new wformattag, such as 0x2001), or create a DTSfromAVI filter (also using a new wformattag)?
Wilbert
25th December 2002, 16:13
Sorry for the useless post of mine, but I really hope that someone will help you because it will be really great if we can make/play avi with dts sound.
gabest
26th December 2002, 13:38
Of course it would be possible, but do you know a filter which would transform DTS into wave samples for the avi muxer with this new id on the media type? Not that it was hard to make such too.
Ah, and one more thing, the current ac3 decoder filters accept wave with id=0x2000 natively, but they don't know about our new id for DTS.
alexnoe
27th December 2002, 09:58
but do you know a filter which would transform DTS into wave samples for the avi muxer :confused: :scared:
The problem is about the player, not the muxer. AVI-Mux GUI does not use any of this broken DS filter stuff.
What I want someone to make:
=> a DTSfromAVI filter, which works the same way as AC3fromAVI, just with another wFormatTag
=> a new filter which passes DTS audio over to intervideo decode, but which tells the decoder that it is DTS. Currently, it is passed over as AC3
gabest
27th December 2002, 14:30
a new filter which passes DTS audio over to intervideo decode, but which tells the decoder that it is DTSI see, it should work as you say. Last question, what's the media type of DTS? The one to set at the output pin of the DTSFromAVI filter.
alexnoe
28th December 2002, 09:36
Last question, what's the media type of DTS? The one to set at the output pin of the DTSFromAVI filter.I don't know, but why not use graphedit to find it out?
Maybe you can parse a vob file containing DTS audio with graphedit and then just look up the media type.
E-Male
30th December 2002, 11:52
any progress-reports alexnoe?
Suiryc
30th December 2002, 20:44
Last time I had a look into mmreg.h (where common tags are defined).
What is the WAVE_FORMAT_DTS (0x0008) value (wFormatTag) for ?
Even with this name I am not sure this is related to Digital Theater Systems because the comment next to it is 'Microsoft Corporation' ...
Mango Madness
31st December 2002, 00:16
I would much rather see decoding of DTS so that we can have a cleaner source for mp3, ogg, or AAC compression. oh how i'd love to have a 6.1 channel 24bit wave file to have and to hold.
alexnoe
31st December 2002, 23:01
I've changed wFormatTag to 0x0008 in my test file, without success => whatever it is, it's not the DTS audio we speak about.
alexnoe
1st January 2003, 10:52
I've tried to render files containing DTS audio with graphedit, but without success.
Although a DTS file plays fine in PowerDVD, and a single VOB file containing DTS audio and MPEG2 video plays fine as well, graphedit refuses to render the DTS file and only renders the video output filter graph for the vob file :(
Seems that no generic DTS decode filters are installed.
Kadmium
1st January 2003, 15:33
I think perhaps the reason graphedit won't render a VOB with DTS audio is that all the VOB splitters I'm aware of just ignore DTS audio, so there is no DTS pin. If anyone knows of any DirectShow splitters that handle DTS properly could they let me know please?
gabest
2nd January 2003, 03:22
Because what Kadmium said, that no mpeg2 splitter recognizes and creates pins for private stream with 0x88+ id, I tried to make a standalone source filter for dvd2avi demuxed dts files, which could be used to simulate the DTS-out-of-AVI filter.
The first problem I ran into was that I didn't know the exact media type to set on my filter's pin. Ok, this is no news, let's look what audio decoders register themselves to be called in the graph for. The result was not promising. While they all registered MEDIATYPE_Audio/MEDIASUBTYPE_DOLBY_AC3 none of them did MEDIATYPE_Audio/MEDIASUBTYPE_DTS, however iviaudio and nvidia did it for MEDIATYPE_DVD_ENCRYPTED_PACK/MEDIASUBTYPE_DTS, so there was a slight chance if the checkings aren't stickt enough then I might be able to feed them with fake info in the PES and private stream headers (the dts data needs to be packetized back since dvd2avi has just stripped the headers and MEDIATYPE_DVD_ENCRYPTED_PACK means PES packets with the encryption bit set or not set to 1).
Btw, early ac3 decoder versions also only accepted PES and so mpgaudio.ax is also doing what I've just outlined (adds a header with the timestamp always set to zero and it still works :)). However, it is not needed nowdays since all ac3 decoder can accept the raw ac3 stream just fine (MEDIATYPE_Audio/MEDIASUBTYPE_DOLBY_AC3).
So, at this point I was constructing the code to read and repack dts as how it could be outputted from the dvd navigator filter or from other dvd players' demuxer. Then just hit another prob, I did't know the format GUID and structure for MEDIASUBTYPE_DTS, in dshow headers there are a few dvd related defined like FORMAT_DolbyAC3/FORMAT_MPEG2Audio/FORMAT_DVD_LPCMAudio, but DTS is missing, also the matching format describing structures cannot be found anywhere (it's something like the WAVEFORMATEX structure, but of course that is only for FORMAT_WaveFormatEx). I could spy these fields if I had a dvd with dts audio, but unfortunately I don't have any, and also have no idea how to author one... But if someone knows how to do it, please make one and upload it somewhere so I can download :)
Anyway. Without knowing the format I just put FORMAT_None there and left the structure empty. After a little experiencing I managed to connect my filter to the iviaudio decoder in graphedit, but when I hit play the slider just run to the end quickly and everything stopped.
This is how far I got now, thanks for reading :P
alexnoe
2nd January 2003, 15:20
I have made the following assumptions for AVI-Mux GUI for the next release (which will read DTS files!)
The strf-structure is, as for AC3 audio, WAVEFORMATEX, with cbSize being 0. Any granularity values are, as for AC3, set to 1.
Channels and frequencies in any AVI or stream headers are what you get from the main DTS frame header, i.e. a maximum of 48 kHz (if audio is 96 kHz, it is not funny at all to find that out without risking to missync subframes!).
wFormatTag will be 0x2001. 2 DTS frames will be packed into one chunk, as required for proper AC3 playback on broken SB drivers.
If you require a description of DTS frame headers (e.g. to set up some data to feed filters with), PM me. If you need a DTS audio DVD, PM me as well.
E-Male
2nd January 2003, 18:24
erm, does that mean avis with dts audio will soon be possibly???
sorry, but i didnīt understand much of it ;)
gabest
2nd January 2003, 19:12
Muxing dts into avi is not the prob, the playback is. Currently there is no way to connect the avi splitter to the decoders. Wrapping dts chunks into waveformat is only needed to the avi container.
gabest
2nd January 2003, 20:51
Good news, my dts source filter is working now. I can play demuxed dts files from dvd2avi in any dshow player :P
There are only a few little details I'm not sure about
1. dvd2avi cuts the first three bytes of the dts data (0x01 0x00 0x01), and I don't know if AVI-mux will store these bytes or also skip them.
2. How much is the time length of one packet? The iviaudio decoder doesn't seem to care about the timestamp I set on the samples and sets it own calculated from the stream data, but for responding to seeking command in the source filter I need to know this info.
edit:
The packet length looks to be 320000/3 ns, but I'm not sure if it's true for every file.
http://download.vobsub.edensrising.com/dtssource.ax
Register with regsvr32.exe and then try a demuxed *.dts in some player. Only works with the iviaudio decoder, I couldn't connect it to nvidia yet, and cyberlink can't decode dts.
E-Male
2nd January 2003, 23:21
very nice already
just 2 questions:
does this do digital output or analog stereo (downmix)?
and what player(s) do you recommend?
thx
e-male
gabest
2nd January 2003, 23:29
It just reads and seeks, decoding is done using iviaudio.ax. You have to set that to spdif to make it output digitally.
Kadmium
3rd January 2003, 03:28
Actually, as of PowerDVD 4, the Cyberlink decoder does handle DTS.
gabest
3rd January 2003, 04:01
The player may handle it somehow internally, but the filter doesn't want to accept and connect to any DTS type.
gabest
3rd January 2003, 07:41
Just muxed a dts audio track into an avi, and it plays fine :P
alexnoe
3rd January 2003, 10:26
My brother has the LOTR extended DVD, and it uses 768 kBit with 1005 bytes packages, meaning that something like 10ms are one packet.
The data you've given (01 00 01) is not a valid sync header. At the moment, AVI-Mux GUI only accepts DTS streams with a valid sync header at the very beginning.
gabest
3rd January 2003, 10:51
I could only find two small samples with dts sound and both were having a 106667ns length for every 2013 bytes, but of course this value should be only true for this bitrate. Is there a way to find out the bitrate of a dts file? I know where this info is stored in an ac3 file and I guess there must be something similar for dts.
About the 01 00 01. As I found these three bytes exist in a vob before the ac3 data too. Not always these numbers, it is varying. In the demuxed file they are not getting outputted, but for iviaudio I have to repack it like it was, or the closest possible :)
Where can I find "AVI-Mux GUI"? Meanwhile I made my own dshow filter to read dts and feed the avi muxer with "tag=0x2001" wave-format data, but I'd like to test the output of AVI-Mux GUI, too.
alexnoe
3rd January 2003, 11:00
The current version is not yet ready for public upload, so there might still be problems i'm not yet aware of (i have changed a few things which could turn out buggy)
I've uploaded it to the FTP you sent me via PM, as well as DTS frame header description. There you find your information about how to determine bitrate.
I've downloaded your dtssource filter, and I can connect a graph in graphedit, but i don't hear anything...is your replay filter already developed far enough to just open an AVI file with BS-Player and play it?
gabest
3rd January 2003, 11:07
Thanks, got the files, and already testing it :)
The first dts I tried crashed the prog (you get it from the root dir of my ftp), but the other produced something (I have yet to try it).
The only dts decoder I could connect that source filter was iviaudio. And it was even from 4.5, but I think 4.0 would have also worked. When I upgraded it a few days ago I didn't see too much developement, nothing noticable was changed in it.
alexnoe
3rd January 2003, 11:12
IE can't download the file :( and I don't have a better FTP prog here at the moment...maybe the one file is again misdetected as another format...I will set MP3 as least priority for autodetecting format.
gabest
3rd January 2003, 11:23
test1.dts, it can be found in the root dir, not in the /upload dir.
The latest builds of the filters I was talking about so far:
http://download.vobsub.edensrising.com/dtssource.ax
- same as the previous, but it can output more formats: raw, private1, PES, waveformat. (waveformat can be used to connect it to the avi muxer)
http://download.vobsub.edensrising.com/avi2ac3dts.ax
- it is a universal converter between waveformat and raw/private1/PES formats (back and forth), needed to connect the avi splitter outputting tag=0x2000/0x2001 and the ac3/dts decoders.
gabest
3rd January 2003, 11:55
Just tested the avi mux util, the output nicely played for the first try with my filter (avi2ac3dts.ax). Though there were twice as much data per sample (2*2013 bytes) as one PES packet can hold, but the time length was not doubled as well. I checked what the iviaudio decoder sets on the output samples for every 2013 bytes input, and it was always 106667ns for this dts file, while the samples coming from the avi splitter were 213229 ns long, which is not exactly 2*106667. But I have no idea if this counts, my dts files were too short to notice any desyncronization.
ChristianHJW
3rd January 2003, 12:12
What do you think guys, how much work was necessary to allow opening DTS files in VdubMod for muxing ?
I really dont want to question your work on AVImux Alex, its more like i am keen on having DTS muxing capability for OGM and matroska from VdubMod ( matroska test muxer is a modded version of VdubMod, statically linked to a one year old version of libmcf, for testing only ... extension is .mcf still :D ).
For the playback i cant see any major probs, Tobias' OGM playback filter should be able to do it without mods if AVI parser can do it, and for matroska parser we can do any modifications that were necessary ( actually, we have other problems than that right now, like connecting to AC3 decoder filters correctly :D, but it could be done in reasonable time for sure ).
Sorry for the interruption if you're busy with other stuff than making DTS available in other containers than AVI right now ... but you guys could also consider whether its making sense at all to make DTS in AVI available. The Vdub support forum i am admin on gets almost hammered by many people having probs with VBR MP3 and AC3 audio in AVI, as most AVI editing tools, including Vdub, couldnt handle that at all. It is maybe worth considering to reserve DTS audio to the new containers, being mainly controlled from this place here, used by well informed people. Just a suggestion guys, please dont jump on me if you dont like the idea ...
alexnoe
3rd January 2003, 12:24
For AC3, it is absolutely necessary to put 2 AC3 frames into one chunk in the AVI file. Not due to some specifications, but because otherwise some broken SB drivers malfunction in case you use SPDIF out (there has been a thread about that in the A/V format forum iirc). This is of course a flaw in one of the filters...
To be sure these idiotic drivers don't puke at users again, I've packed 2 DTS frames into each chunk.
Per definition, the size of an AVI chunk is any multiple of the nGranularity value. This is 1 for AC3, so requiring any special pack size there is, technically, a bug. However, we have to create files which work...meeting the specs doesn't suffice :sly:
Anyway, with only 10ms per chunk (i.e. 1 DTS frame), the avi overhead would be 8,5 MB per hour and DTS stream...which is even more than what MP3 VBR causes.
Problem: I can't replay anything. I've registered the filters with regsvr32. When trying to render such an AVI file with graphedit, it doesn't render audio. Rendering a DTS file only succeeds if an Intervideo audio decode filter is alreasy loaded in the form. Playing still doesn't work. Only silence.
When loading an AVI, I can manually connect AVI<->AC3/DTS, Intervideo audio and standard DirectSound, but the propery-page of intervideo continues to claim that the input is AC3 and only plays silence.
I can't even replay your test file. Maybe my iviaudio filter is obsolete. Where could I get current iviaudio.ax?
The file you sent is absolutely OK, it was indeed misdetected as MP3 (to verify MP3, a valid sync header is looked for, and if then 2 consecutive frames of MP3 audio can be read, the file is assumed MP3. I'll increase the number a bit, and MP3 is now lowest priority, i.e. only if AVI, WAV, AC3 and DTS verification fail, MP3 is tried).
Your test file indicates 1536 kBit/s, which means that the real bitrate is 1509.75 kBit/s (per definition). No idea if that works well, or if it is going to cause problems. 1536 is one of two strange bitrates...
Are you sure that your digits are right? 106667 sounds too much for me...do you mean 10667? AC3 has iirc 1536 bytes per 32ms for 384 kBit. 2013 bytes for 106.667ms at 1509 kBit/s can't be...and 2013/(1509.75/8) is 10.6666...
@Christian: People have problems with MP3 and AC3 in AVIs because they use broken software for muxing.
gabest
3rd January 2003, 12:41
Originally posted by alexnoe
For AC3, it is absolutely necessary to put 2 AC3 frames into one chunk in the AVI file. Not due to some specifications, but because otherwise some broken SB drivers malfunction in case you use SPDIF out (there has been a thread about that in the A/V format forum iirc). This is of course a flaw in one of the filters...It just the matter of how the AVI->AC3 filter packaging the samples, it would be possible to accumlate a few samples and send them out together...Problem: I can't replay anything. ...No idea, try the version I have here: http://download.vobsub.edensrising.com/iviaudio.axWhen loading an AVI, I can manually connect AVI<->AC3/DTS, Intervideo audio and standard DirectSound, but the propery-page of intervideo continues to claim that the input is AC3 and only plays silence.Register this dll (http://download.vobsub.edensrising.com/proppage.dll) and see what media type the iviaudio is using on the input.
Are you sure that your digits are right? 106667 sounds too much for me...do you mean 10667? AC3 has iirc 1536 bytes per 32ms for 384 kBit. 2013 bytes for 106.667ms at 1509 kBit/s can't be...and 2013/(1509.75/8) is 10.6666...Ah, all the time I meant N*100ns, dshow counts time in this unit and I got used to it too much that I forgot about it :)@Christian: People have problems with MP3 and AC3 in AVIs because they use broken software for muxing. LOL, nice comment :P I think this is half true, even if something is not muxed correctly with/for VfW editing tools, it can be decoded ok with dshow because it is more flexible.
ChristianHJW
3rd January 2003, 13:17
Originally posted by gabest
--------------------------------------------------------------------------------
alexnoe wrote:@Christian: People have problems with MP3 and AC3 in AVIs because they use broken software for muxing.
--------------------------------------------------------------------------------
LOL, nice comment :P I think this is half true, even if something is not muxed correctly with/for VfW editing tools, it can be decoded ok with dshow because it is more flexible.
.. its ok that you guys make fun of me in this respect :) ... i can handle that. Of course, you are used to posting on a l337 place with hard rules, and very few Newbies.
Me on the other hand gets in touch with frustrated Virtualdub users every day that have big problems understanding why they cant open and process AVIs with VBR MP3 and/or AC3 audio in them. It makes me shiver to estimate what will happen if DTS is added to this list of audio codecs that are generally unsupported in good old AVI.
I simply recommended to restrict the use of DTS to the OGM container for the time being, which is all in your power right now. Anyway, maybe not your problem but mine and of those mods on the Newbie places, so i should stop bothering you with this now ;) ....
gabest
3rd January 2003, 13:37
Tested it with ogm, seeking is slow as usual but works for me :)
ChristianHJW: Ask yourself: "Am I reading too many forums and too much time?" :D
Ah, and one more thing, anything is supported by avi which is packed into waveformat. The tag id for AC3 has been in the headers longer time than I can remember.
edit: Found it :) dx6mediasdk\mpgparse\include\mpeg2typ.h, line 80: #define WAVE_FORMAT_DOLBY_AC3 0x2000, file date: 17/08/1998
alexnoe
3rd January 2003, 14:05
@garbest:
Good news: With your new iviaudio.ax file, the graph renders automatically.
Bad news: The new iviaudio.ax doesn't replay anything, neither DTS nor AC3 in an AVI file nor standalone AC3 files. If I substitute my original iviaudio.ax which was provided with my WinDVD with your new file, WinDVD still works, but nothing else works...
gabest
3rd January 2003, 14:20
What do you mean "nothing else"? Regular ac3 avi files? Or even vobs in other players? Maybe the filter checks if you have a registered player installed...
Other. I had a little prob extracting the frame header bits... They just doesn't seem to give a sensible result.
4 byte sync, OK
6 bits additional sync: 0x3f, OK
1 bit "Frame Type": 0, OK
5 bits "Deficit Sample Count": 3, looks OK, whatever it is for :)
1 bit CRC: 1, must be OK, 50% chance
7 bits "Number of PCM Sample Blocks": 0x47, no idea if it is OK
14 bits "Primary Frame Byte Size": 14089 bytes, what does this number mean?
6 bits "Audio Channel Arrangement": 0x37, there is no such valid entry in the table, it must be wrong already
4 bits "Core Audio Sampling Frequency": 0, again an invalid value... I'm lost...
Basically I'm only interested in finding out the bitrate, but that is still to come. Could you just tell me how many bytes to count from the first 4 sync bytes and which bits to look for?
edit: What about the source filter, can you connect it to avi muxer and make a valid-looking avi with it?
alexnoe
3rd January 2003, 15:03
What do you mean "nothing else"? Regular ac3 avi files?For example. Haven't tried vobs in other players yet.
I'll try to get a full version of latest WinDVD...
DTS: ROTFL! You got into the same trap as I did!
Sync are 4 bytes. Nothing more. The next 6 bits can be considered sync, since they do not change for standard frames, but technically, they are not sync!
=> 32 bit sync, 1 bit frame type, 5 bits deficit sample count etc...
I haven't tried to write an AVI file with AVI-Muxer...I don't see what this should be good for. AVIs with DTS will probably be over 2 GB and require OpenDML...and the AVI Muxer doesn't create OpenDML compliant files anyway...
gabest
3rd January 2003, 15:13
Ah, thanks, stupid sync bytes :P
I haven't tried to write an AVI file with AVI-Muxer...I don't see what this should be good for. AVIs with DTS will probably be over 2 GB and require OpenDML...and the AVI Muxer doesn't create OpenDML compliant files anyway...Don't know what it creates, but I can capture tens of working gigabytes using it. The real pain is cutting on keyframes though.
alexnoe
3rd January 2003, 15:21
Yeah, but OpenDML specs require that the first RIFF list is compatible to AVI 1.0, meaning that the dwTotalFrames value should contain the number of frames in the first RIFF list only (=> 1 GB when using DS AVI muxer).
The overall total number is to be stored somewhere else.
DS AVI muxer write the overall total number to dwTotalFrames :angry: , which is, technically, wrong.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.