Exporting MythTV Video to DVD

One of the nice things about having a MythTV system at your home is that it helps you to record all sorts of shows that you may not otherwise be able to watch at their original broadcast time. It also helps you to make a collection of your favorite shows!

Inevitibly, your hard drive will fill under the burdens Myth places on it. The question: what to do with the old shows? If you don't want to delete them, the obvious choice is to migrate to disc-based storage. In principle this is simple: just burn the stored video files to a CD/DVD and forget about it. Unfortunately, Myth stores its video in an uncommon format (.nuv) with non-human-readable filenames.

I wanted to take this backup process one step further -- to make video DVD's that would play in any DVD player as a regular movie, with a graphical menu interface for episode selection. And, since this is a Linux thing after all, my goal is to stick with Linux-based utilities to accomplish this task.

So, as my hard drive filled, I was driven more and more urgently to find some sort of a solution to this issue. The good news: I have a system that works. The bad news: It's tricky to get going, and relies on lots of beta-level software. So, with that in mind, here's how I have been exporting my MythTV shows to DVD.

Summary of Useful Software
For those interested in the tools that I'm using (and where to find them), look no further:

nuvexport
replex
dvdauthor
KDE DVD Author-Wizard

Getting Video Out of Myth
There are several steps involved in the conversion process, the first of which is simply getting a usable video stream out of the Myth database. There are several utilities around that can assist with this process, but I found nuvexport to be very useful. Nuvexport is a command-line based script that can query the Myth database and extract shows (respecting the cutlist -- no more commercials!) in a wide variety of formats. (Essentially it's a script that combines a database query with mythtranscode coupled with the mjpeg tools, a nontrivial task!)

By using nuvexport, you can select the shows you want and save them as DVD-compatible (right resolution, etc.) MPEG files. Since I use a hardware MPEG encoder, this effectively unpackages the .nuv files and provides a human-readible filename.

Fixing Said Video
It turns out that the raw stream isn't quite compatible with the DVD standard. There is apparently a small glitch in some of the hardware encoding done by the chip on my PVR-150 encoder. As such, another round of processing needs to be done to detect these glitches and patch them. A command-line tool has been written which does just that: replex.

Here's the syntax:

$replex -t DVD -k -o Out.mpg In.mpg

The above command would take an input file In.mpg, generated by nuvexport, and create a new, fully DVD compatible file Out.mpg.

A slightly fancier command can be done to process all the .mpg files in a particular directory:

$find . -name '*.mpg' -print0 | xargs -0 -i replex -t DVD -k -o '{}'.replexed '{}'

This will take all input files as ending with the .mpg file extension, process them, and generate outputs that have the same base name but with 'replexed' appended as the new file extension.

Making a DVD
Now that we have replexed, fully-DVD ready MPEG files, we can use the powerful dvdauthor software package to create a DVD filesystem with the appropriate .vob filesystem structure from our source files.

This is simple enough for making a DVD without a menu, but it becomes much more complicated if you want one. (Creating a master XML file that describes the contents, generating MPEG movies for the menu, thumbnails for the menu, multiplexing a null audio stream, etc.)

I am not the first person to notice this -- not to knock the authors of dvdauthor in any way (quite the opposite!). To make things easier for us mere mortals, several people have made shell scripts or other wrappers around dvdauthor. The first one that ended up working for me was the KDE DVD Author-Wizard.

This little GUI does a lot of the work for you, and generates a simple menu! Heck, after it makes the DVD filesystem, it'll even call mkisofs to make an ISO and invoke KIII-B to burn it if you so desire. Very slick. It's also very buggy, but under active development.

Conclusion
It may not be perfect, pretty, or easy, but this combination of tools works. I've been satisfied that I have something that I can use to offload my shows to DVD, as well as more easily share them with my less techincally-adept friends and family.

If you have any thoughts or suggestions on how to improve on this method, feel free to get in touch!

Back to MythTV Guide