|
It is currently 25 Mar 2025, 05:44
|
View unsolved topics | View unanswered posts
 |
|
 |
|
Author |
Message |
mikechambers
|
Post subject: dtsutil - A simple utility to extract DTS bitstreams  Posted: 31 Jan 2025, 06:21 |
Honest fan |
 |
 |
Joined: 25 Feb 2020, 05:51 Posts: 120 Location: United States Has thanked: 24 times Been thanked: 34 times
|
dtsutil is a little utility I wrote to extract the raw DTS bitstreams from PCM WAV recordings taken from the LaserDisc SPDIF output. I know a couple of utilities already exist, but I had issues reliability extracting the entire movie's stream with them. I capture my LDs as one audio/video file with all disc sides in it. This means there are blank pauses/gaps between the SPDIF data in the files. This sometimes seemed to cause issues with the existing utilities I tried, so I wanted to try to make my own that will (hopefully) handle this reliably. Here's the GitHub link if anybody is interesting in trying it: https://github.com/mikechambers84/dtsutilIt's an alpha version right now. I haven't tried a lot of discs, but I did a couple and had no issues. I use an ESI U24 XL with ASIO to capture the SPDIF output. I will probably add AC3 support as well, but am starting with DTS and just threw this together today. I hope it's useful to someone else out there! If anybody has problems getting it to work properly, please create an issue on the GitHub page so that I can look into it. Usage example: 
_________________ My collection: Click!
I also write software.
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 31 Jan 2025, 07:36 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
mikechambers wrote: If anybody has problems getting it to work properly, please create an issue on the GitHub page so that I can look into it. Will git it a try! How long did it take to process Dark City entirely after TOSLINK capture? Did you concatenate side 1 and 2 into a single WAV before extraction? Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
mikechambers
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 31 Jan 2025, 16:42 |
Honest fan |
 |
 |
Joined: 25 Feb 2020, 05:51 Posts: 120 Location: United States Has thanked: 24 times Been thanked: 34 times
|
admin wrote: mikechambers wrote: If anybody has problems getting it to work properly, please create an issue on the GitHub page so that I can look into it. Will git it a try! How long did it take to process Dark City entirely after TOSLINK capture? Did you concatenate side 1 and 2 into a single WAV before extraction? Julien It took about 8 or 10 seconds to process the whole movie's stream. And yes, they were in a single WAV. When I capture LD's, I just record everything into one file for all sides and then clip out all the frames in the video before the first disc frame, and between side changes in VirtualDub 2. During this step I also crop to 720x360 (for widescreen movies) and run the IVTC filter on it. I don't have to clip out any of the blank audio between sides when extracting DTS though, I wrote this so that when it hits any samples without DTS packets, it just keeps seeking forward until it sees the next one and then it resumes extraction to the output file. I am noticing an odd issue though. When I played the extracted DTS file directly in VLC, everything sounded perfect and the entire movie's length was there with no glitches in the sound. Now that I'm trying to mux together an MKV with video and audio in ffmpeg, it seems to miss packets and the audio is only around half the length of the movie in the MKV output and it seems to play through it too fast. Hmm. I'm not sure if it's an issue with my extraction or with ffmpeg's muxing. Like I said, the raw .dts file sounds great alone in VLC. You can also see in the screenshot that's it's processed 1:45:07 worth of samples in DTS frames, which is the correct length of the video, and is also what VLC reports as the length of the .dts file. ffmpeg -i dark_city_video_only.avi -i dark_city_audio_only.dts -aspect 16:9 -vcodec h264 -preset veryslow -b:v 8000k -acodec copy dark_city.mkv
This is the command line I used. EDIT: I'm also thinking of writing another utility to stream the SPDIF input and save it directly as an AC3 or DTS bitstream. It would be nice to eliminate the intermediate step of making a WAV file.
_________________ My collection: Click!
I also write software.
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 03 Feb 2025, 18:58 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
Compiles instantly with GCC. $ gcc dtsutil.c -o dtsutil.exe $ ./dtsutil.exe dtsutil v1.0 alpha by Mike Chambers A tool to extract the DTS bitstream from WAV files.
Specify input WAV and output DTS files on command line: dtsutil.exe input.wav output.dts
Will play a DTS LD + ZOOM U-44 capture to give it a try soon. Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
mikechambers
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 13 Feb 2025, 08:34 |
Honest fan |
 |
 |
Joined: 25 Feb 2020, 05:51 Posts: 120 Location: United States Has thanked: 24 times Been thanked: 34 times
|
jakeheke wrote: AC-3RF decoding would be epic Mr. Chambers Actually doing it direct from the RF output would be awesome, but unfortunately impossible with PC audio capture equipment. The carrier frequency is 2.88 MHz, wayyyyy beyond what you can do with audio equipment... and that's not even getting into figuring out how they modulated the signal into it. Demodulator and SPDIF capture required!  Once you have that it's a pretty simple thing, identify the AC3 frame data in the PCM bitstream and just throw them into a raw .ac3 file. Similiar to DTS.
Last edited by mikechambers on 13 Feb 2025, 08:41, edited 1 time in total.
_________________ My collection: Click!
I also write software.
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 13 Feb 2025, 08:41 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
mikechambers wrote: Julien, what software do you use to capture the DTS WAV? I'm using Reaper. I'll be trying with Audacity. Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
mikechambers
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 13 Feb 2025, 08:42 |
Honest fan |
 |
 |
Joined: 25 Feb 2020, 05:51 Posts: 120 Location: United States Has thanked: 24 times Been thanked: 34 times
|
admin wrote: mikechambers wrote: Julien, what software do you use to capture the DTS WAV? I'm using Reaper. I'll be trying with Audacity. Julien Interesting. I tried that before Reaper, but it seemed to corrupt a lot of the data no matter what I did. What driver/settings are you using? EDIT: I'm on Windows though. Audacity doesn't support ASIO out of the box, and the other drivers it does support are probably mangling the data.
_________________ My collection: Click!
I also write software.
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 13 Feb 2025, 15:06 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
mikechambers wrote: Interesting. I tried that before Reaper, but it seemed to corrupt a lot of the data no matter what I did. What driver/settings are you using? Audacity couldn't sync with ASIO well, I went straight to Reaper. First 60 seconds of Jackie Brown (1997) [15065 AS]: $ ./dtsutil.exe dts-test.wav dts-test.dts dtsutil v1.0 alpha by Mike Chambers A tool to extract the DTS bitstream from WAV files.
Opening WAV: dts-test.wav Valid WAV file! (10767798 bytes) Searching for first DTS header and detecting pack mode... 14-bit packed found at byte 231418
DTS audio format: 44100 Hz, 5.1 channels, 1200 Kbps DTS frame size: 3584 bytes
Extracted DTS frame: 2528 (Time 00:00:58) Finished!
dts-test.wav [1:01] 10.2MB (Windows) dts-test.dts [0:29] 8.64MB (Foobar2000) dts-test.dts [0:58] 8.64MB (VLC)
Trying the DTS file with Foobar2000... It plays as 44.11kHz/6ch/32bit bitrate 2470kbps DCA (DTS Coherent Acoustics), but it plays twice too fast? Trying VLC... It plays as DTS Audio (dts)/3F2M/LFE/44.1kHz/32bit, and it plays at the right speed. Header issue? Tried another 2min sample from 11:30 till 13:30: $ ./dtsutil.exe dts-test.wav dts-test.dts dtsutil v1.0 alpha by Mike Chambers A tool to extract the DTS bitstream from WAV files.
Opening WAV: dts-test.wav Valid WAV file! (21380534 bytes) Searching for first DTS header and detecting pack mode... 14-bit packed found at byte 6106
DTS audio format: 44100 Hz, 5.1 channels, 1200 Kbps DTS frame size: 3584 bytes
Extracted DTS frame: 5175 (Time 00:02:00) Finished!
Same result: VLC at the right speed, Foobar2000 at double-speed. Tried PowerDVD 22 for good measure: it can't detect the media information but plays the DTS twice too fast as well. I would assume Foobar2K and Power DVD trust the header data and get confused. VLC skips the header and tries to guess the contents by itself? This seems to be a known issue when extracting DTS from (basically) a CDDA stream: https://forum.doom9.org/archive/index.php/t-54738.htmlFoobar2000 detects: Duration: 1:00.093 (2 650 112 samples) Sample rate: 44100 Hz Channels: 6: FL FR FC LFE SL SR Bits per sample: 32 Bitrate: 2469kbps Codec: DCA (DTS Coherent Acoustics)
Isn't a bitrate of 2469kbps suspiciously around 2 x 1200kpbs from the LD? VLC detects (while playing): Input bitrate: ~1228 kb/s Content bitrate: ~1235 kb/s
Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 13 Feb 2025, 17:57 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
From the first frame in my DTS extract: 7F FE 80 01 FC 7C E0 02 06 30 A0
Based on https://wiki.multimedia.cx/index.php/DTS#14-bit_words and https://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.05.01_60/ts_102114v010501p.pdf, that would imply: Sample frequency = 0b1000 => 44 100 HzBitrate = 0b11101 => targeted bitrate "open"Open probably leaves some room to the decoder to improvise? I played a little game and replaced 5,175 times all 0x7FFE8001FC7CE002 63A0 with 0x7FFE8001FC7CE002 6260 which is supposed to force 1,280kbps (or 0b10011). But that didn't work, I might be a few bits off!  Checking with a DTS CD wav file, the bitrate decoded by Foobar2000 is declared as 1,255 kbps (similar to what VLC detects when decoding). Then I tried WAV2DTS from https://forum.fanres.com/thread-2255.html: Desktop>wav2dts.exe dts-test.wav FileSize : 21380534 bytes Initial invalid bytes : 6106 Last bytes rejected : 177628 ------------- Valid Header FrameSizeRead : 3585 bytes. FrameSize14le : 4096 bytes. FrameSize16be : 3584 bytes. NumFrames : 5175. Channels mode : Surround. SampleRate : 44.1 KHz. Done, created : dts-test.dts
Again, VLC plays it normally and find 2:00 length. It plays well as well in Foobar2000 but 2:00 is detected as 1:45 at 1,411 kbps, not good either. However when played side to side they are identical... and Foobar2000 display goes up to... 2:00/1:45! Clearly some players trust fully the headers while other try to figure out the contents regardless of headers. dtsutil header is 0x7FFE8001FC7C E00263A0. wav2dts header is 0x7FFE8001FC7C DFF262C0. Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
mikechambers
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 13 Feb 2025, 22:29 |
Honest fan |
 |
 |
Joined: 25 Feb 2020, 05:51 Posts: 120 Location: United States Has thanked: 24 times Been thanked: 34 times
|
admin wrote: Clearly some players trust fully the headers while other try to figure out the contents regardless of headers.
dtsutil header is 0x7FFE8001FC7CE00263A0. wav2dts header is 0x7FFE8001FC7CDFF262C0.
Julien Thanks for experimenting! That's interesting, I'll need to dig deeper into the header and see . While BeSplit outputs a dts with the exact same file size as mine, I also see a few differences in the header. I wonder what's going on there. So yeah, these other extractors are making some mods to the header. But again, BeSplit's output also acts funny for me in anything other than VLC for me as well. I'm going to give wav2dts a try too and see how that does. I'm going to figure out what changes I need to make and then hopefully upload a fixed version that also includes AC3 support some time in the next few days.
_________________ My collection: Click!
I also write software.
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 16 Feb 2025, 08:46 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
admin wrote: dtsutil header is 0x7FFE8001FC7CE00263A0. wav2dts header is 0x7FFE8001FC7CDFF262C0. I went ahead and replaced all dtsutil headers 7FFE8001FC7CE00263A00D3A8009EF7B to wav2dts headers 7FFE8001FC7CDFF262C00D3A8009EF7B. File plays at 2:00/1:45 just like the wav2dts version. More than this, a binary diff between the 2 shows they're identical bit-for-bit. Only the header seems to be the part to modify to get to the magic 1,235kbps that seems to correspond to the 1,200kbps 14-bit expanded to 16-bit. Next step: sampling the full Jacky Brown DTS soundtrack on 3 sides in 3 WAVs $ ./dtsutil.exe Side_A.wav Side_A.dts dtsutil v1.0 alpha by Mike Chambers A tool to extract the DTS bitstream from WAV files.
Opening WAV: Side A.wav Valid WAV file! (579256822 bytes) Searching for first DTS header and detecting pack mode... 14-bit packed found at byte 949082
DTS audio format: 44100 Hz, 5.1 channels, 1200 Kbps DTS frame size: 3584 bytes
Extracted DTS frame: 141070 (Time 00:54:35) Finished!
All done: Side 1Extracted DTS frame: 141070 (Time 00: 54:35) Side 2Extracted DTS frame: 145407 (Time 00: 56:16) Side 3Extracted DTS frame: 115980 (Time 00: 44:53) Total size for the full Jacky Brown DTS 5.1 soundtrack (at fixed bitrate) is 1.34GB. If my calculation is right, that's about 1,202kbps, which is probably a rounding error for 1,200kbps. Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 16 Feb 2025, 16:08 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
mikechambers wrote: Thanks for experimenting! That's interesting, I'll need to dig deeper into the header and see . This might be useful: https://github.com/hypercube-software/DTS-parserWill decode the header for you. I ran Side 3.dts through DTSParser and the "fixed" output is binary identical. Attachment:
DTSParser.png [ 31.74 KiB | Viewed 341 times ]
It does detect the 20bit/44.1k/5.1ch as well as the "open" bitrate. But I think we're just 20 years late to the game  Quote: BeSp09b7/BeSplit -core( -input "g:/01.wav" -output "g:/01.dts" -type dtswav -fix )
BeSplit replaces the "open bitrate" header with a cbr header. (it also converts the 14bit data into 16bit, therefore the extracted dts streams are 12.5% smaller) The .dts should be normally a bit smaller than the .wav, because the dts stream (14bit @ 44.1kHz => 1.234 mb/s ) is packed as 16bit @ 44.1kHz => 1.4112 mb/s in order to comply with the CD - Red Book (CD-A specs) - so these CDs can be played on every CD-Player, though only those with a digital out - connected connected to some external decoder would produce some useable / audible results >BeSplit.exe -core( -input "Side 1.wav" -output "Side 1 - BS.dts" -type dtswav -fix ) BeSplit v0.9b8 by DSPguru. --------------------------
[00:00:00:000] +------- BeSplit ----- [00:00:00:000] | Input : Side 1.wav [00:00:00:000] | Source Sample-Rate: 44.1KHz [00:00:00:000] | Channels Count: 5.1, Bitrate: 1411.2kbps [00:00:00:000] | Output : Side 1 - BS.dts [00:00:00:000] +--------------------- [00:54:35:639] | Writing Side 1 - BS.dts [00:54:35:639] +--------------------- [00:54:35:639] Operation Completed ! [00:01:38:000] <-- Process Duration
The "fixed" header seems to be: 7FFE8001FC7CE002 62C00D3A80 However Foobar2000 still see it as 1,411kpbs and believes the track will be 47:46 when it's actually 54:35... And it plays double-speed  Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 17 Feb 2025, 07:20 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
mikechambers wrote: Good tips and info, thanks Julien! I will re-extract a WAVDTS from a DTS CD to play with it, check headers and how VLC/Foobar2K detect it. I had to go back to the 2002 version of https://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.02.01_60/ts_102114v010201p.pdf to find Table 5.8 that was removed later: Quote: RATE specifies the targeted transmission data rate for the current frame of audio (see Table 5-7). The open mode allows for bit rates not defined by the table. Attachment:
Table-5.8.png [ 22.43 KiB | Viewed 323 times ]
So I guess the best would be to convert 14-bit DTS to 16-bit DTS (padding 2 bits to 0) and set the standard 1.411Mbps rate? Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 17 Feb 2025, 14:22 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
admin wrote: I will re-extract a WAVDTS from a DTS CD to play with it, check headers and how VLC/Foobar2K detect it. Here you go (as recognized by Foobar2000): - WAV DTS- 35.5MB [3:31] - 44100Hz/2ch/16bit/1,411kbps (using Foobar2K dts plugin)
- WAV2DTS output = 31MB [3:05] - 44100Hz/6ch/32bit/1,411kbps - plays normally
- DTSUTIL output = 31MB [1:45] - 44100Hz/6ch/32bit/2,470kbps - plays too fast
- BeSplit dtswav = 31MB [3:05] - 44100Hz/6ch/32bit/1,411kbps - plays too fast
- BeSplit dtswav -fix = 31MB [3:05] - 44100Hz/6ch/32bit/1,411kbps - plays too fast
DTS headers are respectively: 7F FE 80 01 FC 7C DF F2 62 C0 0D 3A 80 09 EF 7B 7F FE 80 01 FC 7C E0 02 63 A0 0D 3A 80 09 EF 7B 7F FE 80 01 FC 7C E0 02 62 C0 0D 3A 80 09 EF 7B 7F FE 80 01 FC 7C E0 02 62 C0 0D 3A 80 09 EF 7B
BeSplit -fix doesn't seem to change anything. So far the best candidates are the dts plugin from Foobar2000, getting the running time and replay correct by parsing the whole data inside the WAV. p_info.info_set_int("bitrate", (t_int64)m_decoder->avg_bitrate / 1000);
... and VLC -- not trusting the header but computing running average values -- will play any of them properly. Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
admin
|
Post subject: Re: dtsutil - A simple utility to extract DTS bitstreams  Posted: 19 Feb 2025, 14:06 |
Site Admin |
 |
 |
Joined: 07 Aug 2002, 23:37 Posts: 4902 Location: Tokyo Has thanked: 349 times Been thanked: 1386 times
|
Not all DTS soundtracks seem equivalent. Used the same sampling chain for Eagles: Hell Freezes Over (1994) [ID4065GF] and the WAV-DTS can be played in Foobar2K or VLC. But if I use wav2dts the output is not readable (Foobar2K) or just plays silent (VLC). I get better results with dtsutil. Julien
_________________ HARDWARE DATABASE HLD-X0/9 LD-S9 OPPO 105/205 SL-1200G LDD-1 MSC-4000 R2144 PONTUS II C45 MC257
|
|
|
|
 |
|
|
 |
|
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|