High Definition Disk Formats

From MythTV Official Wiki
Revision as of 18:06, 3 June 2008 by Iamlindoro (talk | contribs) (Whoops, forgot to mention DTSHD)

Jump to: navigation, search

It is indirectly possible to play back Hi-Def media such as Blu-ray and HD-DVD Disks in MythTV. While it is currently impossible to place a HD-DVD disk in the drive and play it with MythTV, one can rip the files onto the hard drive and play them with a patched version of MPlayer. Please note the following caveats before following this guide:

  • Decrypting copy-protected media may be illegal where you live. Take note of any local laws concerning the circumvention of copy-protection and act accordingly.
  • Currently, most HD-DVD and Blu-Ray disks are implementing new audio formats that are only experimentally supported in open-source players. You will need to be capable of and familiar with compiling your own copy of mplayer to make the audio work in most cases.
  • Playback of 1080p content is extremely processor-intensive. Many users download 1080p content from the internet that has been transcoded and downsampled to very low bitrates. True HD-DVD and Blu-ray rips average between two and four times higher bitrates. These files are therefore substantially more difficult to play. The advantage to this method is that the quality is vastly superior when viewing an untranscoded rip.
  • This guide is written for use with Ubuntu, but there is very little within that cannot be directly applied to any other distribution.
  • Menus and other interactive content are currently unavailable in Linux. The user will only be able to play the video files on the disk.
  • Blu-ray disks with the newer BD+ encryption are currently unrippable in Linux. There are Windows alternatives that are able to offer some BD+ ripping support. One option is SlySoft AnyDVD HD, which rips both HD-DVD and Blu-ray disk formats.


Understanding HD-DVD and Blu-ray structure

Blu-ray and HD-DVD are fundamentally the same creature from a linux perspective. Both contain muxed files using either the MPEG-4 Part 10 (H.264), VC1, or MPEG-2 codecs, and audio tracks in AC-3, E-AC3, DTSHD, TrueHD, or MLP audio formats. HD-DVD uses the EVO container which is analogous to a VOB file in DVD parlance. Blu-Ray uses M2TS, or MPEG-2 Transport Stream containers. The video formats on both disk types are well understood and supported in both MPlayer and FFmpeg. The audio codecs are not. Presently, it is necessary to compile MPlayer to play most audio tracks found on Hi-Def disks.

Blu-Ray features are generally found in a single .m2ts file, while HD-DVD features are usually two EVO files (Usually the two largest on the disk and sequentially numbered, ie FEATURE_1.EVO and FEATURE_2.EVO).

Mplayer demuxing of EVO and m2ts files is imperfect, sometimes leading to missing audio tracks. For example, on a rip of "Crank" Blu-Ray, only the "family friendly" audio track is currently visible/playable. This appears to be related to the Blu-ray format muxing multiple audio streams into a single PID.


Ripping Hi-Definition Media

To rip Hi-Def Media to the disk, you will need all of the following:

  • A drive capable of playing back the media you intend to rip (ie the Xbox 360 HD-DVD Drive or the LG GGC-H20L HD-DVD/Blu-ray Combo Drive)
  • Adequate disk space for the entire movie, generally between 25-50 GB/disk. After removing extras and menus, this is commonly 20-30 GB/movie.
  • A Kernel with UDF 2.5 Support (You may need to compile your own. See here for further details.) Ubuntu users of Feisty and Gutsy can find a udf.ko kernel module at this thread, which should be copied into /lib/modules/`uname -r`/kernel/fs/udf/. Back up the existing udf.ko first!
  1. Begin by downloading DumpHD, available at the Doom9 Forums. Navigate to the directory where you downloaded the file and unzip it:
    unzip dumphd_0.4.zip
  2. Download a current keydb.cfg file, again at Doom9. Copy the keydb.cfg file into the dumphd_0.4 directory.
    cp keydb.cfg dumphd_0.4
  3. Start DumpHD and insert the HD-DVD or Blu-ray Disk into your drive.
    cd dumphd_0.4 && sudo java -jar DumpHD.jar
  4. Click "Browse" in the upper right and navigate to your disk (ie, /media/300_HDDVD) and select it as the source.
  5. Click "Browse" in the section marked "Destination" to select the directory in which to copy the files (ie, /tmp).
  6. Click "Dump" to begin ripping the disk.
  7. Optional Step: If the feature is composed of multiple files, you can append the files with the cat command.
    cat FEATURE_1.EVO FEATURE_2.EVO > outfile.evo


Erase any extra files. Only the feature film is necessary for playback.


Playing Ripped Hi-Definition Material

Playback of HD rips requires MPlayer patched for both MLP/TrueHD and E-AC3. Patches for both, as well as .debs for 64-bit Ubuntu are available here. These patches work with mplayer SVN revision 25826. These same patches will work with FFMpeg revision 11584. It is advisable to compile both, as ffmpeg will make it easier to determine what type of audio tracks are available.

Once you have patched, compiled, and installed mplayer as appropriate, you need to edit or create the codecs.conf file in your ~/.mplayer/ directory. Insert the following into an existing or new file:

audiocodec mlp
  info "FFMpeg mlp"
  status buggy
  format 0x0
  driver ffmpeg
  dll "mlp"

audiocodec ffeac3
  info "FFMpeg EAC3"
  status buggy
  format 0x0
  driver ffmpeg
  dll "E-AC3"

At this point, it is possible to play back your film. If you patched and compiled FFMpeg, use it to inspect your film (In this case a rip of the "300" HD-DVD). The format is "ffmpeg -i filename".

root@mythtv:~# ffmpeg -i /movies/300.EVO 
FFmpeg version SVN-r11584, Copyright (c) 2000-2008 Fabrice Bellard, et al.
  configuration: --prefix=/usr --enable-shared --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-liba52 --enable-liba52bin --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
  libavutil version: 49.6.0
  libavcodec version: 51.49.0
  libavformat version: 52.5.0
  libavdevice version: 52.0.0
  built on Jan 20 2008 18:24:00, gcc: 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Input #0, mpeg, from '/movies/300.EVO':
  Duration: 01:56:32.5, start: 20523.753856, bitrate: 22580 kb/s
    Stream #0.0[0xfd55]: Video: vc1, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 29.97 tb(r)
    Stream #0.1[0xfd56]: Video: vc1, yuv420p, 720x480 [PAR 40:33 DAR 20:11], 29.97 tb(r)
    Stream #0.2[0xc4]: Audio: liba52, 48000 Hz, stereo, 192 kb/s
    Stream #0.3[0xc3]: Audio: liba52, 48000 Hz, 5:1, 640 kb/s
    Stream #0.4[0xb1]: Audio: mlp, 48000 Hz, 5:1
    Stream #0.5[0xc2]: Audio: liba52, 48000 Hz, 5:1, 640 kb/s
    Stream #0.6[0xc0]: Audio: liba52, 48000 Hz, 5:1, 640 kb/s

On movies with MLP audio tracks, it is best to use it rather than the liba52 tracks (these tracks can be either E-AC-3 or AC-3). In order to play the film, you must specify the demuxer, the audio codec, the audio ID, and the frame rate. For all HD-DVD and Blu-ray movies, the demuxer will remain the same. The other options will change. For example, on this rip of 300 HD-DVD, the correct command line is:

mplayer -fs -vo xv -demuxer lavf -ac mlp -aid 4 -fps 24000/1001 /movies/300.EVO

This command line invokes MPlayer in full screen mode with Xv output, sets the demuxer to lavf, the audio codec to MLP, the audio track number to 4 (derived from the ffmpeg output, "Stream #0.4"), and the frame rate to 23.97. To play back one of the E-AC3 tracks in the same file, use a command like this:

mplayer -fs -vo xv -demuxer lavf -ac ffac3 -aid 3 -fps 24000/1001 /movies/300.EVO

If you experience slow playback, try the following options:

-lavdopts threads=2:fast:skiploopfilter=all -sws 0 -framedrop

This will remove all processing of the file and play back multithreaded if possible.

If the playback works properly, copy the file into your MythTV video directory. Enter the Video Manager in MythTV's frontend. Select the film from the list and press the right arrow. Select "Edit Metadata." The last option is to set a custom player command for the file. Paste or type the command you used into the box and press "Done." The file should now play back as any other in MythVideo.