A Linux DVR Is No Myth—It's MythTV!
The advent of personal digital video recorders (DVRs) has transformed the experience of watching TV for millions of people. The VCR may have freed viewers from having to watch programs when the networks wanted them to, but the DVR has given them dramatically more freedom and control.
Most consumers use a set-top DVR, either buying it outright or getting it as part of a bundle with a satellite or cable package. But by their nature, these boxes fail to realize the benefits of a DVR fully. For one thing, because of the politics of business, DVR manufacturers have been reluctant to develop technologies to allow viewers to skip commercials automatically. Also, commercial systems require monthly subscription fees to receive the viewing guides, which can easily exceed the original cost of the recording in a single year. Finally, the manufacturers discourage owners from making simple modifications, such as adding additional disk space or networking their DVRs to allow other TVs in the house to watch recorded content.
This brings us to solution number two—building a DVR from scratch. Several packages are available for Windows—none for free—that do a competent job of providing DVR capabilities. But if you want a high-quality DVR that runs under Linux, MythTV is the way to go. This article walks you through the steps you need to set up MythTV on an already functional Linux system.
The architecture of a MythTV box is fairly simple. A dæmon process called mythbackend is responsible for actually talking to the tuner cards, figuring out what programs should be recorded and otherwise handling the day-to-day business of being a DVR. In theory, that's all you need to have running on your server. For example, if you have a Hauppauge MediaMVP set-top box, you can run a special bootstrap load on it that will communicate directly with a MythTV back end on your server and let you watch your recorded content anywhere in the house.
Most users, however, also will want to run mythfrontend, which provides all the PVR user-level functionality through a GUI. In addition to letting the viewer choose what to record and to watch existing programming (as well as live shows), mythfrontend also can display weather data, current news, browse Web pages and even play games through the use of plugins. You can use multiple front ends (conceivably running on different machines), all talking to the same back-end server.
To begin with, we need to talk a bit about hardware. As with most things, what you are going to need depends on what you want to do with it. For example, the more tasks you expect your MythTV server to handle simultaneously, the more processor power you will need. Recording two shows at the same time while watching a third and transcoding a fourth for a DVD burn can take a fair amount of horsepower, so it doesn't hurt to spend a little for a decent processor. Thankfully, you won't need a liquid-nitrogen cooled, triple-overclocked speed demon to get the job done, a 2.8GHz chip should do it nicely.
You're also going to want a good supply of disk space on hand to store all those “Survivor: Sunnyvale” episodes. Because the whine of a noisy disk is the last thing you want to hear while watching your favorite show, go with SATA. A pair of 250GB drives shouldn't set you back more than $250 US if you wait for them to be on sale, and they will hold enough content to satisfy even the most hardened video junkie. We'll talk about filesystems in a bit.
Surprisingly, the video adapter is not a critical component. This doesn't mean you should dig out that old circa-1995 Hercules card you've got lying in the back room, but any reasonably recent AGP card of the past year should do just fine, although good OpenGL support will help out a lot. Tuner cards are a big deal, however. Choosing the right cards can make setup and use of your MythTV system much easier. You obviously need to look at factors such as whether you want to record HDTV, in which case picking a non-HD card is a non-starter. For the purposes of this article, we use the workhorse of most MythTV systems, the Hauppauge WinTV-PVR-250 and WinTV-PVR-350. What makes the Hauppauge cards so attractive is that they include MPEG encoders on the card, which drastically reduces the workload on the host CPU. You can easily record two shows at once using two of these cards and see only 5–6% CPU usage. The difference between the 250 and 350 is that the 350 also includes a hardware MPEG decoder and video out connector, so that you can hook it up to a TV set. However, it's going to run you another $50 US or so more than the 250. Because you probably don't want to stick your server in the middle of the living room just so you can hook it to your TV, I'd recommend going with the 250, which can be had for around $130 US retail and get a MediaMVP (around $80 US) for your TV hookup. Hauppauge also offers a WinTV-PVR-500 MCE with two tuners built in and a video out, but it doesn't include a remote, which is useful for controlling MythTV from a distance. The WinTV-PVR-250 is a reasonably economical way to get shows onto your system, but be warned that if you're going to try to record HDTV, the Hauppauges aren't going to do the job for you.
Another thing you need to think about is whether you're going to need to control a satellite receiver or cable box to change channels. To make this work, you'll probably need an IR Blaster—a device that hooks up to your serial port and sends the proper commands to your set-top box. Also be aware that you can tune only one channel per set-top box, so if you want to record two shows at once, you're going to end up forking out for two boxes. This is the one big advantage that the DVR solutions offered by the cable and satellite companies have; they are built in to the set-top box, so this isn't an issue.
With the hardware requirements out of the way, it's time to provision the system. In spite of its reputation as a hard install, I've found that Gentoo offers the easiest overall experience in setting up MythTV. Use any of the standard tutorials to get a base Gentoo system up. The main thing you need do is make sure you set your filesystems up right. Assuming you bought two 250GB SATA drives, you really want to use the Logical Volume Manager (LVM) to turn most of the space into one large partition. I recommend doing the install normally but leaving most of drive 0 and all of drive 1 unassigned. So, you might use 10GB of drive 0 to set up your root, usr, swap and var space, leaving 240 remaining. Once your system is up and running, set up a 490GB LVM partition out of the remaining space.
The generally accepted wisdom is to use JSF (the IBM Journaling File System) as the filesystem for the partition on which you'll store your shows. This is because it offers the best performance when deleting large files—an activity that MythTV does frequently. This means you should make sure to compile JSF into your kernel (and not as a module). You also need to bake in LVM support.
The Gentoo Wiki site (see the on-line Resources) offers an excellent walk-through on setting up the kernel correctly to handle the integrated Hauppauge remote control and install the required packages. Once you have everything up and operational, you're ready to configure MythTV itself. Thankfully, the setup pretty much consists of running mythsetup and walking through a series of wizard screens that configure things such as your home cable/satellite system information. It shouldn't take more than five to ten minutes to do the basic setup.
One of the interesting things about MythTV is that it stores everything (except the actual video, of course) in a MySQL database. This makes it easy to import and extract information, and make tweaks. For example, if you need to fine-tune a channel's frequency, you can poke different values into the appropriate database table, go up and down one channel using the remote and see if it made things any better. Of course, it would be really snazzy to be able to tweak the fine-tuning using the GUI; maybe someone will implement that for a future release. It also means that you can run a simple query and see every show you've ever watched, or even write custom software that leverages the two-week program guide data MythTV automatically downloads for you.
Once this is all working, you should be able to record shows and watch them on your monitor and speakers (which would be plugged in to your sound card and or motherboard speaker jack). To use the Hauppauge MediaMVP, you need to enable NFS on the server and export the filesystem with the video content. You also have to run a DHCP server and tftp server. Again, there's an excellent walk-through at the SourceForge site (see Resources).
Another option is to install MythWeb, which gives you an Apache-driven Web front end to view your program guide, scheduled recordings and already recorded programs. On Gentoo, this is as simple as typing emerge mythweb.
One outstanding feature of MythTV is the ability to skip commercials automatically. You enable this with a check box in the setup wizard. Once turned on, programs are queued up for commercial scanning after the end of the show. This means you can't skip commercials while watching a show that's being recorded or soon after, but generally the flagging is available within 30 minutes from the time the show ended. Then, while watching the show, you can use the skip-forward button to move past a group of commercials. The flagging isn't perfect, but it's pretty close. You also can set up MythTV to transcode content for later DVD burning automatically. In fact, you can configure it to run any arbitrary Linux program on a video file after the recording is complete.
Is MythTV the right solution for you? If all you're looking to do is record content on the TV to which your PVR is attached, probably not. You can purchase DVRs from your cable or satellite providers that are cheaper and better integrated with their content and don't take a day or more to set up. But if having full control over your content is important, if you want to be able to share it all over your house from a single source and if you don't want to fork out $150 US a year for program data, MythTV offers the ultimate in flexibility, configurability and hackability.
Resources for this article: /article/8584.
James Turner is Product Review Editor for Linux Journal. He has written two books on Open Source Java development and is a Senior Software Engineer with Axis Technology, LLC.
|Android Candy: That App Is for the Birds!||Mar 22, 2017|
|Hodge Podge||Mar 21, 2017|
|William Rothwell and Nick Garner's Certified Ethical Hacker Complete Video Course (Pearson IT Certification)||Mar 20, 2017|
|Preseeding Full Disk Encryption||Mar 16, 2017|
|William Gurstelle's ReMaking History, Volume 3 (Maker Media, Inc.)||Mar 15, 2017|
|GRUB Boot from ISO||Mar 14, 2017|
- Two Ways GDPR Will Change Your Data Storage Solution
- Hodge Podge
- William Rothwell and Nick Garner's Certified Ethical Hacker Complete Video Course (Pearson IT Certification)
- Preseeding Full Disk Encryption
- Android Candy: That App Is for the Birds!
- Flash ROMs with a Raspberry Pi
- Minifree Ltd.'s GNU+Linux Computers
- Two Factors Are Better Than One
- GRUB Boot from ISO
- William Gurstelle's ReMaking History, Volume 3 (Maker Media, Inc.)