<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

Play DVD Tracks

From SqueezeboxWiki

Revision as of 00:51, 5 July 2010 by Soulkeeper (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Playing AC3/DTS DVD tracks

Introduction

Multichannel audio on a DVD-Video uses the Dolby Digital (henceforth called AC3) and DTS formats , 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 or DTS. (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.

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.)

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 text below gives examples of how to do that; I've typed the part after each "X:\path>"):

Microsoft Windows 2000 [Version 5.00.2195](C) Copyright 1985-2000 Microsoft Corp.

c:\>z:

Z:\>cd "Ripping\Ripped From DVD"

Z:\Ripping\Ripped From DVD>dir
 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:

Z:\Ripping\Ripped From DVD>"c:\Program Files\spdifconvert\spdifconvert.py" "01 - Fight Test.ac3"
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):

Z:\Ripping\Ripped From DVD>"c:\Program Files\SlimServer\server\bin\MSWin32-x86-multi-thread\flac.exe" --best "01 - Fight Test.ac3.wav"

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.

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 (version 0.4) Utility

This utility is distributed under the GNU General Public Licence.

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.

Open a command prompt by clicking "Start", "Programs", "Accessories", "Command Prompt". Type the following:

"c:\Program Files\spdifconvert\spdifconvert.py" --help

...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 the associated forum thread if you have any problems and I'll try to help you out:

http://forums.slimdevices.com/showthread.php?t=19260

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.pyPress 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.

/Contributors: smst, EricCarroll/