A Linux DVR Is No Myth—It's MythTV!

James Turner gives us an overview of MythTV—a Linux-based TiVo replacement.

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.

Figure 1. The Hauppauge WinTV PVR-250 is the MythTV card of choice for analog TV reception.

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.

Figure 2. Program Guide

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.

Figure 3. MythWeb

Figure 4. Recorded Programs

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.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

security dvr?

dennyhalim.com's picture

mythtv is good for home watching tv and recording them.

how about dvr for security cams? recording a dozen cameras simultaneously 24x7 ??

anything for this application??

tia

linux security dvr

linuxdvr's picture

There are some choices you can consider. Check out www.apeccctv.com dvr card section, there are three to four choices you can use to build your own Linux Security DVR. The software are loaded in a Disk on Module, which it is a plug and play drive inserting into the IDE. This means you really don't need to load Linux OS at all and it is self installed.

To know more, call APEC CCTV at 9095953488.

Do you have to defrag the DVR running LINUX

LINUX newbie's picture

We have multiple DVRs running on LINUX and we aren't sure if we need to be running a defrag application periodically or not. Typically, we run a defrag on our Windows Servers that write and rewrite to the same disk over and over again, thus the question arose for our DVR's. Any help would be greatly appreciated.

Linux DVR

Anonymous's picture

I am looking for a LINUX based DVR software.
I noticed you use such a thing in your comment.
Can you share the name/mfg of your Linux DVR Software and Card

Thanks

A little late but:

Anonymous's picture

A little late but:

Linux filesystems like reiserfs are designed to not require defragmenting.

File Sizes on Webpage

Anonymous's picture

This article contains small images, some of which are 240k in size. Web page images should never exceed 40k, otherwise it is unreadable for those on dialup.

Total page weight

Anonymous's picture

I'm seeing a total weight of 109kB, which is less than half the size you claim for a single image on this page. Maybe the page has changed, or maybe you are simply wrong. I'm betting on the latter.

Who uses dialup in this

Anonymous's picture

Who uses dialup in this modern day?

Open Source not Dead in Windows

Anonymous's picture

Yes the fatal starting words Windows!!!

Myth TV has and will remain a beacon of what a integrated PVR solution should be, with backend and frontend distributed home entertainment for your whole house.

However the none available for free comment here is very misguided.

Myth TV does exist in another form for windows more inspired by than a copy of but one of the best PVR software and its free.

MEDIAPORTAL

Check it out. http://www.team-mediaportal.com/

Available for free for Windows with almost most of the same features of Myth TV. And create your own with Python scripting included.

And gaining more and more as time goes by.

Inspiration to Dump SageTV

William Strathearn's picture

I put together a PVR a few months ago and was stuck on Windows/SageTV for fear of myth installation difficulty and cutting edge hardware support in Linux. Reading this article inspired me to dump SageTV and embark on a fresh install of Gentoo 2005.1 and MythTV. The whole thing went pretty well, with only one hardware component needing to be replaced for lack of support. The Gentoo community resources were invaluable in getting the whole thing installed and configured in about 20 hours time.

So far, I'm blown away by the large set of features offered by MythTV and shunned by other PVR software offerings. Myth Rocks way harder than any other PVR software offering in existance!

I've documented my journey as a guide to others researching thier own DIY PVR's: http://diylinuxpvr.blogspot.com/

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState