Playing AC3/DTS tracks sourced from DVD

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smst
    Senior Member
    • Jun 2005
    • 286

    Playing AC3/DTS tracks sourced from DVD

    Hi all,

    A little while ago I wrote a utility to help me play AC3/DTS files through the SqueezeBox2. I've finally found the time to write some documentation on it, so I now present it as part of a guide to playing multi-channel audio sourced from DVD.

    I'll be happy to answer any questions about this and generally help to get it going, but bear in mind that I'll be slow at responding for the next two or three weeks.
    • Introduction
    • Requirements
    • Dolby Digital (AC3)
      • Ripping
      • Converting
      • Configuring SlimServer
      • Playback
    • DTS
    • To Do


    Introduction
    Multichannel audio on a DVD-Video uses the formats Dolby Digital (henceforth called AC3) and DTS, with a frequency of 48000Hz (compared to CDs which use 44100Hz). The SB2 is capable of playing these formats by passing a slightly modified form of the digital data through to a suitable receiver. I'll explain here how to get that working.

    You can of course use this information to play back extracts from a film's audio track, but it's more likely that you'll want to play back an album which has been remixed to 6 channels. Many DVD-Audio discs are released with a DVD-Video layer which is recognised by normal DVD players, with the audio encoded as AC3 or DTS. The fidelity is not as high as the DVD-Audio layer, but certainly suffices for most of us. This guide DOES NOT cover ripping of the DVD-Audio layer; I have no idea how to go about that, or if it's even possible.

    Requirements
    You'll need a SqueezeBox2 or SqueezeBox3 (I'll refer to them both as SB2), with a digital connection to a receiver which can decode Dolby Digital. (We don't do any decoding ourselves; we simply pass the encoded data through to the receiver for decoding.) SB1 is not supported, although it could be with a small amount of work (more later). SLIMP3 is not supported.

    Continued in next post...
  • smst
    Senior Member
    • Jun 2005
    • 286

    #2
    Dolby Digital (AC3)
    Ripping
    First you'll need to obtain an AC3 file from your DVD. There are lots of guides available on the Web for using various DVD ripping software; I'll give a brief example using SmartRipper (for Windows) which I hope will be enough to give the general idea. In brief, you need to demultiplex the ac3 soundtrack into a separate file (with extension 'ac3'; if you get a 'vob' it's not quite unpacked).

    SmartRipper example: use rip method "Movie". Under the Input tab find the largest Title, which is likely to be the one containing the body of the album (other titles may exist for the menus, for extra features, etc). Choose a Program Chain similarly, and then Angle 1. You'll see a list of chapters to the right; if you click each one in turn, the chapter information below will show you its length, which you should be able to use as a guide to picking the right song (assuming you know the track running times). Click the "none" button beside the Chapters list, then tick a chapter to be extracted. Note that some albums may have a very short chapter at the start; check the track length and pick the first chapter that looks right. (You'll find it hard to test the later stages if you've ripped a few seconds of silence!) Don't worry about the Cells list.

    From the Stream Processing tab, click "none" to uncheck all the streams, then tick the stream containing the surround mix -- it's probably labelled "Audio English AC3(6Ch) 48kHz", and is often stream 0x80 or thereabouts. From the choices on the right, be sure to choose "Demux to extra file"; this is important! Choose an output directory at the bottom of the screen, then click "Start". If all goes well, you'll end up with an ac3 file in that location, which you'll probably want to rename to something suitable. (If you have problems with this, I recommend you seek out a guide for your ripping software. The most common problem is probably with region-coding, if you've bought a DVD intended for a different global territory than your drive is configured for.)

    Other DVD extraction utilities: oreillymj describes how to use DVD Decrypter (with screenshots!) in this post.

    Converting
    Now you'll need to convert the ac3 file into a format suitable for streaming over the SB2's digital output. Grab the utility posted below (spdifconvert.py) and get it set up (there are instructions later). Grab a command prompt by clicking "Start", "Programs", "Accessories", "Command Prompt" (I'll continue with Windows examples, and assume that Linux users can translate easily enough). Windows tip: you can copy text from below, then paste it into your command prompt by clicking the icon at the top-left of the window, and choosing "Edit" then "Paste" (this is in Windows 2000; I'm sure other Windows systems are similar). Now you'll need to change to the drive and directory containing your ac3 file (the large bold text below gives examples of how to do that):
    Code:
    Microsoft Windows 2000 [Version 5.00.2195]
    (C) Copyright 1985-2000 Microsoft Corp.
    
    c:\>[b][size=+1]z:[/size][/b]
    
    Z:\>[b][size=+1]cd "Ripping\Ripped From DVD"[/size][/b]
    
    Z:\Ripping\Ripped From DVD>[b][size=+1]dir[/size][/b]
     Volume in drive Z is Massive
     Volume Serial Number is F4DD-63BB
    
     Directory of Z:\Ripping\Ripped From DVD
    
    2005-11-23  13:22       <DIR>          .
    2005-11-23  13:22       <DIR>          ..
    2005-10-20  07:16           14,162,397 01 - Fight Test.ac3
                   1 File(s)     14,162,397 bytes
                   2 Dir(s)  12,334,592,000 bytes free
    Now run the utility on the ac3 file. You can specify one or more individual ac3 files, or just use *.ac3 to convert them all. You'll only provide the names of the ac3 files, not the full paths, since you should have changed to the directory which contains them. (Advanced users' note: you may use a different working directory as long as you supply the full path and file name for the ac3 file. By default the output will be in the same directory as the input file; see the help text to know how to change this.) Note that the path to your copy of the utility may be different:
    Code:
    Z:\Ripping\Ripped From DVD>[b][size=+1]"c:\Program Files\spdifconvert\spdifconvert.py" *.ac3[/size][/b]
    Reading input from file 01 - Fight Test.ac3
    Writing output to file 01 - Fight Test.ac3.wav
    Detected stream type: ac3
    You now have a WAV file containing a padded version of the original ac3 file. I recommend you convert this to FLAC, which will allow you to add tags later using WinAmp, fb2k, etc; I'm using the FLAC executable provided with SlimServer here (and note the use of the --best option):
    Code:
    Z:\Ripping\Ripped From DVD>[b][size=+1]"c:\Program Files\SlimServer\server\bin\MSWin32-x86-multi-thread\flac.exe" --best "01 - Fight Test.ac3.wav"[/size][/b]
    
    flac 1.1.1, Copyright (C) 2000,2001,2002,2003,2004 Josh Coalson
    flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
    welcome to redistribute it under certain conditions.  Type `flac' for details.
    
    options: -P 4096 -b 4608 -m -l 8 -q 0 -r 3,3
    01 - Fight Test.ac3.wav: wrote 30221995 bytes, ratio=0.622
    Put this file somewhere that SlimServer can see it. You'll probably need to do a "new and changed" rescan from the settings menu, or use "Browse Music Folder" to give SlimServer a nudge. Add the file to your current playlist (or make a playlist of one song containing this track).

    Configuring SlimServer
    The FLAC data must be passed to the SB2 unchanged. Through the web interface, go to Server Settings and then File Types. Ensure that of "FLAC FLAC (built-in)" is ticked, and that "FLAC MP3 flac/lame" is not ticked. You'll need to click "Change" if you change these values.

    Now go to the player settings (on the skin I'm looking at, there's a Settings link on the right-hand player frame) and then to the Audio section. Set Digital Volume Control to "Digital output level is fixed" and Bitrate Limiting to "No Limit" -- these settings ensure the digital data is not adjusted on its way to the digital output. You can leave Replay Gain enabled, but you mustn't set RG values in your ac3.flac file! For now, disable crossfade also (IIRC the only problem with crossfade is that the transition from a 44100Hz track to 48000Hz track results in a speed-up for the last few seconds of the former, but I can't remember for sure if it works otherwise with the digital formats). Click "Change" if you had to adjust any of these settings.

    Playback
    Ensure that your server and player are configured as above, and that your SB2 is connected to your receiver through a digital (optical or co-ax) output. Your receiver must be able to decode Dolby Digital streams, of course. Unplug any analogue outputs from the SB2; analogue output will sound like white noise.

    Now play the track! If your receiver auto-detects surround formats, its Dolby Digital indicator should illuminate and you'll hear the music. If not, try telling your receiver that you're expecting a DD stream.

    If you hear white noise, it's probably a volume problem: double-check that your digital volume is fixed in the player settings. Another cause is transcoding to MP3: check that bitrate limiting is not enabled and that the "FLAC MP3 flac/lame" conversion is not enabled.

    Continued in next post...
    Last edited by smst; 2009-12-15, 09:11.

    Comment

    • smst
      Senior Member
      • Jun 2005
      • 286

      #3
      DTS
      DTS tracks can be obtained from DVDs in the same way as AC3 (look for a 6-channel audio stream with "SDDS" mentioned), and are de-multiplexed to files with the extension 'dts'. The spdifconvert utility supports DTS files (at least, the ones I've tested!).

      With SB2 firmware revisions below 35, playback of full-bitrate DTS files is not quite perfect. The FLAC files I've created in my tests have very poor compression (this isn't PCM audio data, so the FLAC algorithms just aren't built for it; the AC3 files I've tested have compressed well due to large amounts of padding), and I believe that the SB2 is struggling to decode them in real-time (similar to Bug#1859). The bitrate of a DTS-FLAC is about 1535 kilobits/s, which is almost the same as the DTS-WAV file it contains. (A half-bitrate DTS file ends up as a DTS-FLAC file with a bitrate of about 1494 kilobits/s -- still not great compression but the SB2 decodes it with no problems.)

      We could decode the FLAC to WAV on the server (by enabling "FLAC WAV flac" and disabling "FLAC FLAC (built-in)" in the File Types section), and there's no bandwidth penalty for doing so, but we run into another problem: Bug#128. The SB2 firmware currently plays all WAV data at 44100Hz, so our 48000Hz files are slowed down a little. (You can try this: convert a DTS file to WAV, then play it back directly through the SB2: an auto-detecting DTS-capable receiver will illuminate its DTS indicator, but the audio will sound slightly wrong.)

      However, with firmware revision 35 (and presumably later versions too) native decoding of FLAC files containing full-bitrate DTS works perfectly. See #53 in this thread for more details.

      Aside: DTS CDs are already supported by the SB2! DTS comes in two flavours: one which looks like the 16-bit PCM audio found on CDs, and one which we find on DVD soundtracks. If you have a DTS CD, rip it as normal and encode to a lossless format (such as FLAC; you mustn't involve a lossy format like MP3 or Ogg Vorbis at any stage here), and follow the playback tips above regarding volume and bitrate limiting.

      To Do
      There may be AC3/DTS streams not properly supported by the spdifconvert utility (I've only tested it with those I've encountered on my limited library of 5.1-mixed albums). If anybody encounters one, I'll be happy to try adding support for it.

      I've named my own converted files with extensions ".ac3.flac" and ".dts.flac"; since there are two dots, they're seen as having just a "flac" extension and SlimServer recognises them. It might be worth standardising on ".ac3-flac" and ".dts-flac" (with dashes, so they're not seen as just "flac"), which would allow finer control over the streaming formats -- I'm thinking in particular of allowing DTS-FLAC -> WAV if that turns out to be the best way to play them back. The downside is that additional configuration is needed, but perhaps this could be supported by default in a future release.

      These files must not be played over analogue outputs, and the volume control must always be disabled. If there was a way of telling SlimServer that a particular file contained special digital data, it might be possible to enforce these settings automatically as needed. (Sean Adams suggested this as a possibility, but again this is not a promised feature since it requires a firmware change.) Custom extensions might suffice here.

      SB1: the SB1 doesn't quite pass through digital data perfectly. I believe it's possible to write a small utility which losslessly converts file to a format which compensates for the SB1's mangling, and adjust the SlimServer configuration to apply that conversion when the target is an SB1 box. As I understand it, this is the only thing preventing the SB1 from playing back these surround files.

      The spdifconvert.py Utility
      This utility is distributed under the GNU General Public Licence.

      Follow this link to github. Click the 'spdifconvert.py' link, then the "Raw" button, and save the page as 'spdifconvert.py'.


      spdifconvert.py is a Python script which takes as input an AC3 or DTS file (sourced from a DVD) and encapsulates it in an IEC61937 stream. This stream is then wrapped in a WAV file which can be played over an S/PDIF link with no modifications (ie no volume adjustments); a digital receiver will be able to interpret the AC3 or DTS data contained within this stream (assuming the receiver knows the AC3/DTS formats).

      To run this script you'll need to install Python. I've tested the script with version 2.3.5, so any release from the 2.3 cycle should be fine. I expect that version 2.4 or later will also give no problems, up to the 2.6 cycle. The script definitely doesn't work under Python 1.5.2, or Python 3.0 or onwards.

      Windows users: download and install Python, and allow it to associate itself with '.py' files. Extract spdifconvert.zip somewhere sensible -- I recommend you create a sub-directory of Program Files named "spdifconvert" and extract the zip file into there. Note: I wrote this when the zip file was attached to this post. You can download a zip from the github link above, or just the PY file.

      Open a command prompt by clicking "Start", "Programs", "Accessories", "Command Prompt". Type the following:
      Code:
      [b]"c:\Program Files\spdifconvert\spdifconvert.py" --help[/b]
      ...and you should see a page of text describing the usage of the utility. I would expect that only more advanced users would need to use the arguments described there; the basic usage is simply running the utility with AC3/DTS file names as arguments (without the '--help' option), and that will usually be all you need. You can either specify individual files as separate arguments (separate by spaces; enclose a name in "double quotes" if it contains a space) or by using a wildcard: *.dts for example. Reply to this thread if you have any problems and I'll try to help you out.

      Linux users: you've probably got Python installed and in your path already. The #! line in the utility names just "python" (with no path), so just making the script executable should be enough to get you going. Again, reply here if you have any problems.

      Mac users: I'm sorry, but I have zero experience with using a Mac! Start by downloading and installing Python. As long as you can (1) get a command prompt (or terminal), and (2) cause Python to execute the utility, you should be able to follow along.

      Mac users update: thanks very much to jsnell, who replied later in the thread with this useful advice:
      Just a note for Mac users -- download the python script and place it in your home folder. Then launch the Terminal application and type:

      python spdifconvert.py

      Press the space key, then switch into the Finder and drag and drop the file you want to convert onto the Terminal window. Terminal will automatically fill in the file path; all you have to do is hit Return.
      I'll refrain from going into too much more detail about the various options; see the Converting section for basic usage. Note that while stdin and stdout are supported, using them both together is not very useful as there's no way to get the WAV header written accurately.

      If anyone has a file which doesn't seem to convert correctly, try running with the --verbose option for a little more detail. I'm happy to modify the utility if there are flavours of AC3/DTS which aren't converted correctly.

      Utility version: 0.4.
      Last edited by smst; 2016-02-20, 20:10. Reason: New version: 0.4

      Comment

      • smst
        Senior Member
        • Jun 2005
        • 286

        #4
        Aside to anyone reading this guide through the email list, instead of on the forum: I'm not sure how the command prompt examples will look in the email, and you may therefore find it easier to read the forum post instead. Find it here:

        Comment

        • eldebil
          Junior Member
          • Dec 2005
          • 2

          #5
          Thank You !

          I have done a quick test with a dts file and it work perfectly, thank you very much !
          I hope the improvements you proposed 'll be included in firmware & slimserver.

          Comment

          • smst
            Senior Member
            • Jun 2005
            • 286

            #6
            Originally posted by eldebil
            I have done a quick test with a dts file and it work perfectly, thank you very much !
            I hope the improvements you proposed 'll be included in firmware & slimserver.
            I'm glad to hear it! I'm interested to know if you included the FLAC step for your DTS file, and if so if it sounded okay or a little jerky or stuttery. If you didn't go for FLAC (just WAV, as I described in my earlier post) did you notice a slight slow-down? I found it most noticeable on vocal sections of a song. It'd be good to confirm the behaviour I saw here, in case there's a chance it's something to do with my setup.

            Thanks for your appreciative comments.

            Comment

            • Andy Hawkins
              Senior Member
              • May 2005
              • 875

              #7
              Playing AC3/DTS tracks sourced from DVD

              In article <smst.20an0b (AT) no-mx (DOT) forums.slimdevices.com>,
              smst<smst.20an0b (AT) no-mx (DOT) forums.slimdevices.com> wrote:
              > I'll be happy to answer any questions about this and generally help to
              > get it going, but bear in mind that I'll be slow at responding for the
              > next two or three weeks.


              Any chance of a step by step guide to getting the audio from a DVD video
              disc and into a format suitable for playback on my SB2?

              Thanks

              Andy

              Comment

              • smst
                Senior Member
                • Jun 2005
                • 286

                #8
                Originally posted by adhawkins
                Any chance of a step by step guide to getting the audio from a DVD video disc and into a format suitable for playback on my SB2?
                That's what I've tried to provide above. Are there aspects you feel haven't been covered?

                Comment

                • smst
                  Senior Member
                  • Jun 2005
                  • 286

                  #9
                  Originally posted by adhawkins
                  Any chance of a step by step guide to getting the audio from a DVD video disc and into a format suitable for playback on my SB2?
                  I've just thought -- do you mean stereo audio, such as you'd get from a normal CD? I have done this before so will try to give you a quick idea about how to go about it.

                  Roughly, you rip audio from the DVD as above (see my SmartRipper example) but look for a 2-channel track (labelled with "2Ch" in SmartRipper, say). You're not interested in preserving the exact digital data so just decode the ac3 file to WAV; a piece of software called BeSweet will do this for you I think (you can get a GUI/wizard version which should help).

                  A program called Headac3he can also decode ac3 files -- and has various options for downmixing 5.1 channels into 2, in case you can't find a stereo track on the DVD.

                  From a WAV you can encode to MP3, Ogg Vorbis, FLAC, whatever; BeSweet can probably do that for you too. Note that the audio so obtained will be at 48000 Hz, so it's not ready for burning to CD without re-sampling.

                  Hope this helps. I'll be offline for a few days now so will try to answer questions on my return.

                  Cheers,
                  Steve

                  Comment

                  • Andy Hawkins
                    Senior Member
                    • May 2005
                    • 875

                    #10
                    Playing AC3/DTS tracks sourced from DVD

                    Hi,
                    In article <smst.20k5ln (AT) no-mx (DOT) forums.slimdevices.com>,
                    smst<smst.20k5ln (AT) no-mx (DOT) forums.slimdevices.com> wrote:

                    > That's what I've tried to provide above. Are there aspects you feel
                    > haven't been covered?


                    The bit of actually getting the audio from the DVD. What software should I
                    use? I did try ripping the audio from a DVD using some software (can't
                    remember the name off the top of my head, sorry) but all it did was crash
                    the Squeezebox when I tried to play it.

                    What I'm after is the name of a piece of software that can perform the
                    ripping process, and any instructions on how to use it.

                    Thanks

                    Andy

                    Comment

                    • smst
                      Senior Member
                      • Jun 2005
                      • 286

                      #11
                      Originally posted by adhawkins
                      The bit of actually getting the audio from the DVD. What software should I use?
                      My second post above has a section on ripping, with a brief guide to using SmartRipper. When you've got the file you'll need to convert it to a playable format following the rest of the instructions.

                      Comment

                      • eldebil
                        Junior Member
                        • Dec 2005
                        • 2

                        #12
                        Originally posted by smst
                        I'm glad to hear it! I'm interested to know if you included the FLAC step for your DTS file, and if so if it sounded okay or a little jerky or stuttery. If you didn't go for FLAC (just WAV, as I described in my earlier post) did you notice a slight slow-down? I found it most noticeable on vocal sections of a song. It'd be good to confirm the behaviour I saw here, in case there's a chance it's something to do with my setup.

                        Thanks for your appreciative comments.
                        My test was the following:
                        software :
                        ---16 mn of "Faithless - Live at Alexendra Palace" (DTS half rate )
                        ---extracted with DVDdecrypter
                        ---converted to WAV with your python script
                        ---compressed in FLAC (compression=max).
                        hardware :
                        ---SqueezeBox 3
                        ---receiver: Yamaha RX-V750
                        ---SPDIF connection: coaxial

                        I haven't noticed any problem with this setup but I plan to rip all my concert DVDs to test it a little more deeply.
                        I promise to post more feedback of my tests in this thread.

                        PS: Merry Christmas to everybody

                        Comment

                        • chrisal
                          Junior Member
                          • Apr 2005
                          • 24

                          #13
                          Hi,

                          I'm having a go at this but winzip is telling me the archive is corrupt - is there another place to download it?

                          Cheers

                          Chris

                          Comment

                          • chrisal
                            Junior Member
                            • Apr 2005
                            • 24

                            #14
                            It's ok - i've managed to unzip it ok now...

                            Comment

                            • adhawkins
                              Senior Member
                              • May 2005
                              • 875

                              #15
                              Apologies for being dim and asking for a step-by-step guide. I was reading this through the GMane interface, and for some reason the second of your posts didn't make it there.

                              I'm just ripping a DVD now, but I can't get the spdifconvert ZIP file to download successfully. Can you help?

                              I notice someone else had similar problems and then got it to work. How did you do that?

                              Andy

                              Comment

                              Working...