O'Reilly logo

Linux Multimedia Hacks by Kyle Rankin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #77. Create a DVR with MythTV

Turn any reasonably modern computer it into an open-source digital video recorder that rivals and even surpasses a TiVo in features.

People are busy and can't always be at home when their favorite show comes on. You could rearrange your life so you'll always be at home during the primetime broadcasting hours, but why bother? You've heard of a TiVo right? That magical appliance known as a DVR that digitally records all of your television shows and is much easier to figure out than a VCR. Well, now you can create your own TiVo using a computer and the free software program called MythTV. Although the instructions in this hack apply specifically to Fedora Core 4, a Linux user with just a modest amount of experience should be able to adapt these instructions to install and configure MythTV on most any distribution.

The Hardware

One of the most frequent questions asked by people wanting to build their own DVR is what hardware they'll need. Most people assume there is a magic bullet combination of hardware that is vastly superior to all others, but that simply isn't true. The hardware you need for your MythTV system really depends on your budget, your needs, and your own personal sense of taste. To find out about hardware other people have used to build their systems, visit the PVR hardware list found at http://pvrhw.goldfish.org/tiki-pvrhwdb.php.

The following list gives you a few more specific guidelines:

Processor

Your processor needs to be fast enough to decode the video playback stream. This usually means a Pentium III or better processor that is 500 MHz or faster. Either AMD or Intel processors are just fine, even in 64-bit form, but you would be wise to avoid the VIA processor family, because it generally lacks the oomph necessary for the task. The faster your processor, the better the playback and the more actions your MythTV system can perform at a time. For example, if you are using a bttv-based capture card as explained in [Hack #73] , you will need at least a 1 GHz processor if you expect to watch live TV and timeshift. However, if you use a Hauppauge WinTV card, as suggested in this hack, you can use a slower processor because the Hauppauge card performs the video encoding work for you, thus freeing your processor for other tasks, such as decoding for playback. Also, a fast processor will compress video more quickly (this includes compressing ripped DVDs and CDs) and finish scanning for commercial breaks within minutes of when the recording stops.

Memory

MythTV is not a memory-intensive program, and there is little to be gained having more than 256 MB, but additional memory could be useful if you are running multiple encoders.

Hard drives

You don't need the fastest hard drive with the largest cache, but you probably do want one with a high storage capacity. Any P-ATA or S-ATA 5,400 rpm drive or better should be up to the task. The amount of space taken by a recording varies depending upon the capture card, the resolution and bitrate of your recording, and the encoding scheme, but don't be surprised to see file sizes of 1 GB or more per hour of recording. If you are using an HDTV capture card (not covered in this book) you may see rates as high as 7 GB per hour of recorded video! Many people set up their video recording directory on a LinuxVolume Manager partition so they can add more drive space at a later date. Also, many people favor Seagate and Hitachi drives as they are known to be quieter than other offerings.

Video card

Since you'll be sending your output to your TV, you need a video card with TV-out capability. Many people favor the NVIDIA cards that are fully covered in [Hack #75] . You may be tempted to get an ATI All-in-Wonder card, which has a video-capture ability as well as TV-out, but all the features of these cards are not yet well supported in Linux so I don't recommend it.

Capture card

As explained in "Install a TV Tuner" [Hack #73] , a capture card is the device that enables you to tune into TV broadcasts and capture the stream into a format useable by your computer. In this hack I suggest you use a Hauppauge WinTV capture card of the 150/250/350 or 500 series. These cards have a built-in encoder ability, which converts the raw broadcast into MPEG2, thus relieving your processor of the duty of encoding the video. These cards come with a decent remote, and are well supported in MythTV—and the 500 series card even comes with two tuners! If you want to capture HDTV broadcasts you need to use a card which supports HDTV, such as those found at http://www.pchdtv.com.

Motherboard

Your choice of motherboard is usually determined by the processor brand and model you are using, the size your case will support, and the number of PCI slots you need to fit your capture cards. This means that if you want the ability to record three shows at a time but you only have single-tuner capture cards, you'll need at least three PCI slots. Though this requirement is easily met with an ATX motherboard, it might be difficult to meet with a micro-ATX ina slim form factor case.

Case

The case you choose for your MythTV project is your chance to make a style statement. Some people opt for basic tower cases that are hidden away behind the TV or in another room. Other people prefer stylish cases that can be placed on the A/V rack and look at home with the receiver and VCR. The Silverstone and Ahanix cases are quite popular.

Sound

Pretty much any sound card supported by the ALSA project will work well with MythTV. You can output your sound, analog or digital, to your receiver and have that device interface with your speakers. One reason the Hauppauge capture cards are better than most is they have integrated audio capabilities, which eliminates the need to have a sound card matched to each tuner.

You can purchase your computer hardware most anywhere, but two popular sites are http://www.pcalchemy.com and http://www.newegg.com.

The hardware used in this hack is a reasonably powerful 933 MHz Pentium III system with 256 MB of RAM, a GeForce 4 MX video card, a Hauppauge WinTV PVR-250 tuner card with remote control, and a 120 GB hard drive.

The Basic Steps

Before launching into the details of how to set up your MythTV system, here's a basic rundown of the steps involved:

  1. Assemble your computer. This is obviously needed and I'm not going to cover this in the hack itself.

  2. Install a Linux distribution with a minimal feature set. This hack uses Fedora Core 4, but other distributions could certainly be used.

  3. Install MythTV and related software. If you use a different distribution, you'll need to use its package management tools to install the needed software, but configuration of the system should basically be the same as outlined here.

  4. Configure your hardware, particularly your capture, sound, and video cards. You can optionally configure your remote at this time, but it is really a step that can be visited whenever you want.

  5. Create the MythTV database.

  6. Create a Zap2It account so you can retrieve program-listing data.

  7. Run the MythTV setup program and configure it for your capture card and cable or broadcast network.

  8. Populate the database with your program guide data.

  9. Set up your system to output to a TV instead of a monitor.

  10. Do the final tweaks to MythTV and your system to ensure smooth, minimal maintenance operation.

Without further ado, here are the specific steps you need to set up MythTV.

Install Fedora Linux

To start, you need to install Linux on the computer. While MythTV packages exist for multiple distributions, for this example, I'm using Red Hat's latest community release, Fedora Core 4. Note that for successful completion of this task, you'll also need an Internet connection, and the faster the better, because there's a fair amount to download. Start out with your system hooked to a regular monitor, but with the intention of connecting it to an analog television set when you've got everything all set up.

Tip

A lot of the instructions for setting up MythTV that you find on the Internet show you how to configure it for different desktop environments and window managers. Traditionally, MythTV was run with KDE, but in this hack, we'll set it up with GNOME.

You can obtain disc images for Fedora Core 4 from your friendly neighborhood Red Hat download mirror, which you can find by visiting http://fedora.redhat.com/download/mirrors.html. For simplicity's sake, perform a clean installation of a simple Personal Desktop install (which requires only the first two of the four FC4 CD images), but when you get to the partitioning section, select custom partitioning scheme "Manually partition with Disk Druid" so you can carve out a sizable dedicated partition for MythTV's video storage. On the example system above, I created a 100 MB /boot partition, a 256 MB swap partition, a 10 GB / partition, and allocated all remaining space to a /video partition, which is where I'll tell MythTV to place all recordings.

Tip

Later in the install, you'll have the option to customize your "to be" installed package selection. This is a good chance to remove any extra desktop packages you really don't think you'll need, such as Evolution or OpenOffice.org.

Your choice of filesystem does make a difference with MythTV, and you will most likely want to choose a journaled filesystem. ext2 is non-journaled, so in the event of a system crash and subsequent reboot, it will scan through all of the files on your /video partition to verify their integrity. Considering that most files will be in the gigabyte range, this can take a very long time on large partitions. Your best choice is to pick either ext3, XFS or JFS. ext3 is not as good a performer when it comes time to deleting files as other filesystems—XFS and JFS are very good at deleting multi-gigabyte files, but ext3 will most likely have better support from your distribution. XFS and JFS may not even be install-time options for you. In the example above, you may need to leave the final 100 GB /video partition unformatted until after your system has been installed, at which point additional tools such as xfsutils and jfsutils will be available for you to complete the task.

Many users opt to manage their /video partition with LVM, which will later allow them to expand the partition over multiple disks without the need to reformat the original /video partition.

I highly recommend that you configure a static IP address to your MythTV box, since changing addresses on the fly can have bad side effects, especially if you intend to have multiple MythTV boxes running as a cohesive system at some point. I also recommend disabling both the firewall and SElinux, at least for your first try, to minimize possible problems that might hinder your progress. Finally, you'll want to make sure to properly set the time zone for your machine, so that your programming guide data will match up with reality (otherwise, you'll end up recording the wrong programs). Now allow the installation to complete, and then restart your machine.

Configure Fedora

Upon restarting your machine, you'll be greeted by Fedora's firstboot utility. The first page of importance to your setup is the Date and Time page. You've already set the time zone, but now you need to set your clock to synchronize with an Internet time server.

This step is important to ensure clock accuracy. If you don't set this up, your system clock might drift, and you could quickly start to see recordings ending before the crucial final minutes of your favorite shows! Try to set the time as accurately as possible on the Date and Time tab, and then click over to the Network Time Protocol tab. On that tab, click the Enable Network Time Protocol checkbox. The provided time servers should be sufficient for your needs.

Continuing on, firstboot will now ask you to set up your display. Just opt for 1024 x 768 for the moment. At this point the resolution isn't a big deal, since you're only running on this display temporarily—you'll reconfigure everything for your TV later. Next, firstboot prompts you to create a normal user account. Create a user named mythtv, which you'll use to run MythTV. You'll also be prompted to test your sound card, so go ahead and make sure that's working. Click the rest of the way through firstboot, and then watch as your system finishes starting up.

Once you've been greeted by the Fedora Core login screen, log in to the system as the user mythtv. You'll make heavy use of your terminal application for much of the setup process, so click Applications menu → System Tools → Terminal to launch it.

Update Fedora

Generally, you ought to start out by applying all released errata updates. You can short-circuit this step if you want to save a bit of time by not downloading and applying all available updates to your system. However, if you've got the time and bandwidth, it's definitely a good idea. You can use either the up2date utility (click the flashing red circle with the exclamation mark in your tool bar), or the command-line yum utility. You'll make a lot of use of yum to install MythTV components, so you might as well get familiar with it. Become root, then type:

	# yum upgrade

After some dependency processing, you'll be informed of the upgraded packages to be installed and asked if you want to continue. Hit y and Enter, and then go get something to snack on. The further away from the initial release of Core 4, the more packages that need updates. Take special note of whether or not a new kernel package was installed, as you'll want to be running the latest available errata kernel for both security reasons and availability of third-party kernel modules, which you'll need to complete your MythTV setup. Assuming a new kernel was installed, go ahead and restart one more time so you're running on that new kernel.

Configure a Third-Party MythTV Repository

Now, you'll need to configure yum to be able to access a third-party RPM package repository, where you'll obtain all the necessary MythTV bits and their dependencies. Everything you need can be found in Axel Thimm's ATrpms repository, at http://atrpms.net/. First, install the ATrpms package-signing key as root to verify the authenticity of the packages you'll be installing:

	# rpm–import http://atrpms.net/RPM-GPG-KEY.atrpms

Now, add a yum configuration file called atrpms.repo in the /etc/yum.repos.d directory containing the following information:


	[atrpms]
	name=ATrpms for Fedora Core $releasever stable
	baseurl=http://apt.atrpms.net/fedora/$releasever/en/$basearch/at-stable
	gpgcheck=1
	enabled=1

Install MythTV

At this point, you are ready to pull down all the MythTV packages. Through the beauty of automatic dependency resolution and installation tools like yum, doing so is simply a matter of issuing a one-line command as root, and then sitting back and watching it execute:

	# yum install mythtv-frontend mythtv-backend mythtv-themes

This is all it takes to pull down and install the core MythTV packages, themes, and any and all dependencies required. Depending on the speed of your Internet connection, this might be a good time to go get something to drink or maybe even take a nap if you're on dial-up!

If you're curious what all it is that you're NOT having to do manually by using the ATrpms packages, give the official MythTV documentation, written by Robert Kulagowski, a read-through at http://mythtv.org/docs/mythtv-HOWTO.html. By using a third-party repository, you avoid having to compile anything or worry about dependencies, but for those who prefer to go straight to the source (code), Robert's guide is your ticket to compile.

After the intermission for all those packages to download and install, you'll still need to install a few more bits and pieces. You need a few kernel modules that aren't available in the main kernel tree. ATrpms provides these kernel modules in pre-packaged, easy to swallow pills. For your NVIDIA video card, you'll need the ATrpms nvidia-graphics kernel module packages; for your WinTV PVR capture card, you'll need the ivtv kernel module; and for its remote, the lirc kernel module.

Run the following command as root to retrieve all of these (the use of `uname–r` in these commands is to ensure you grab the appropriate module for your kernel):

	# yum install nvidia-graphics7174-kmdl-`uname -r` \
	nvidia-graphics7174 ivtv-kmdl-`uname -r` \
	ivtv lirc-kmdl-`uname -r` lirc

Now you have all the software you need installed on your system, so now you are ready to configure it for MythTV.

Configure System Modules

You'll need to make some modifications to /etc/modprobe.conf to tell the system about some of your hardware and which drivers to use with it. For the PVR-250, its remote, and your video card, you should have the following additions: (the nvidia portions may have been inserted already when the nvidia-graphics packages were installed):

	# ivtv
	alias char-major-81 videodev
	alias char-major-81-0 ivtv
	alias tveeprom tveeprom-ivtv
	alias msp3400 msp3400-ivtv
	alias tuner tuner-ivtv
	# lirc
	alias char-major-61 lirc_i2c
	install lirc_i2c /sbin/modprobe ivtv; /sbin/modprobe --ignore-install lirc_
	i2c
	# nvidia kernel module
	alias char-major-195 nvidia-1_0-7174
	alias nvidia nvidia-1_0-7174

After making these changes, rebuild your module dependencies:

	# /sbin/depmod–ae

Setting up your NVIDIA card.

Next, swap your X configuration and switch over to the nvidia driver (up to this point, you've been using the open source nv driver, which doesn't perform nearly as well as NVIDIA's own binary driver in key areas like video decoding). The ATrpms package actually created an appropriate configuration file based on your existing configuration, so switching drivers is a relatively painless process. As root, make a backup of your current configuration for good measure, then swap the xorg.conf.nvidia configuration into place:

	# cd /etc/X11
	# mv xorg.conf xorg.conf.nv
	# mv xorg.conf.nvidia xorg.conf

Now all that's left is to restart X. All open programs are going to terminate when you restart X, so save any unfinished business, then hit Control-Alt-backspace. Soon you will see the NVIDIA splash screen and then be taken back to a login prompt. Log back in and continue on with loading and testing the drivers for the PVR-250.

Setting up your capture card.

To get the PVR-250 prepped and ready for MythTV to use, you need to load the ivtv driver via a quick modprobe:

	# /sbin/modprobe ivtv

If you want to troubleshoot what's going on during this process, check out the /var/log/messages file. The ivtv driver has matured to the point where any PVR-250 on the market should be recognized and auto-configured correctly. Connect an antenna or cable feed to the coaxial input on the PVR-250, and then test the functionality of the capture card with cat and mplayer:

	$ cat /dev/video0 > testfile.mpg
	(hit ctrl-c to stop capture after a few seconds)
	$ mplayer testfile.mpg

Tip

If you don't get good audio and video in the test capture above, launch the ptune-ui.pl utility to tweak the video settings, while having MPlayer play video straight from /dev/video0, so you can change channels and other parameters in search of a viable signal:

	$ /usr/lib/ivtv/ptune-ui.pl &
	$ mplayer /dev/video0

Also, note that we're using mplayer to test the card; the output produced by the ivtv driver is a standard MPEG2 stream, not raw video, so programs such as xawtv and zapping will not work.

Setting up your remote control.

Once you're happy with the video from your tuner card, load up the necessary lirc modules and test out the functionality of your remote.

	# /sbin/modprobe lirc_i2c
	# wget http://wilsonet.com/mythtv/lircd-g3.conf.txt
	# mv lircd-g3.conf.txt /etc/lircd.conf
	# /sbin/chkconfig lircd on
	# /sbin/service lircd start

Note that there are actually three different remotes that have come with PVR-250 cards over time, and the previous code is for the newest version. For the two older versions, you can find appropriate configuration files for them in /usr/share/doc/ivtv-*/. Now launch the irw program, point your remote at the PVR-250's IR receiver and press some buttons. irw should output some text corresponding to the button presses it's seeing.

	$ /usr/bin/irw
	00000000000017e1 00 CH- hauppaugegrey
	00000000000017e1 00 CH- hauppaugegrey
	00000000000017d0 00 VOL+ hauppaugegrey
	00000000000017d0 00 VOL+ hauppaugegrey
	(control-c to stop)

If the output from this test looks good, you can drop a button-to-function mapping file for lirc to control MythTV into place:

	$ wget http://wilsonet.com/mythtv/lircrc-haupgrey-g3.txt
	$ mkdir ~/.mythtv
	$ mv lircrc-haupgrey-g3.txt ~/.mythtv/lircrc
	$ ln -s ~/.mythtv/lircrc ~/.lircrc

The last line symlinks the configuration file to the location xine and mplayer expect to find a lirc button mapping file. The file also contains settings for those programs, and some MythTV plug-ins also use the file to perform duties that'll be covered later on.

Tip

Appropriate lircrc files for the two earlier Hauppauge remotes are also available. A second-generation config file is located at http://wilsonet.com/mythtv/lircrc-haupgrey.txt.

The second-generation file should also work for most of the black first generation remotes, but users with these remotes may have to search the Internet (or ask the lirc mailing list) for a full configuration file.

Create the MythTV Database

The next step in the process is to actually configure MythTV itself. The bulk of MythTV's configuration settings and data are stored in a MySQL database backend, so you'll need to prepare a database before you can start configuring MythTV.

Fedora Core's stock MySQL configuration parameters cause it to perform sub-optimally with MythTV. To increase performance, there are a few parameters you should configure before you start up MySQL. To do this, edit /etc/my.cnf and add the following configuration options under the [mysqld] section in the file:

	key_buffer = 16M
	table_cache = 128
	sort_buffer_size = 2M
	myisam_sort_buffer_size = 8M
	query_cache_size = 16M

With those changes in place, you now need to set MySQL to load at startup, and then start it.

	# /sbin/chkconfig mysqld on
	# /sbin/service mysqld start

Set the mysqlroot password, replacing ROOT_PWD with a password of your choosing:

	# mysql -u root mysql
	mysql> UPDATE user SET Password=PASSWORD ('ROOT_PWD') WHERE user='root';
	mysql> FLUSH PRIVILEGES;
	mysql> quit

Now create and populate the MythTV database (called mythconverg) with some initial data:

	$ mysql -u root -p < /usr/share/doc/mythtv-*/database/mc.sql
	(enter the password you just set above when prompted)

Configure Zap2it Data Direct

A Personal Video Recorder without some means of knowing which programs are on which channels and at what time is nothing but a glorified VCR. A PVR with a good data source becomes much more powerful, since it is able to automatically adjust the scheduled program list.

If you give it some thought, it's pretty obvious that a PVR will need that data source. But how can it get it in a computer-readable format? Prior to April 2004, MythTV used a project called xmltv (http://xmltv.org) which implemented a number of programs called grabbers and an XML format to describe the details of a program, such as the start and end times, the name, channel, and so on. The grabbers worked in various ways to obtain raw data and place it into XML format. The grabber for the United States would execute the following basic algorithm:

Connect to http://www.zap2it.com and request a one-page listing of all programs for day x on channel y. Repeat for all channels in your zip code and for days 1 to 13.

As you can deduce, this is very inefficient. Zap2it had to generate a dynamic web page for each request, so in a typical cable TV lineup of 50 channels multiplied by 13 days, they had to create 650 web pages for each user. Typically, users would update their listings once a day, so that would be another 50 to 200 web pages to obtain updated listings for today, tomorrow, and any new days that had been added.

If you then multiply that by the popularity of MythTV in the United States, you can see what a server load MythTV was placing on Zap2it.com, especially between midnight and 5 A.M.

So, when Zap2it offered a means for non-commercial users to obtain listing data (Data Direct) in an XML format that didn't require dynamic web page generation on the Zap2it end or the error prone process of "screen scraping" on the user side, it was a win-win situation all around.

Zap2it gets demographic data on users, and users get greatly expanded, high-quality guide data listings. Zap2it offers detailed subtitles and episode descriptions, which were not available through the screen-scrape method.

Tip

Users who are not in the United States will need to use a XMLTV grabber. See the XMLTV web page for a list of supported countries.

Create your Zap2it account prior to configuring MythTV. Go to site http://labs.zap2it.com and click on "New User? Sign Up." Fill out the information requested, and for Certificate Code use ZIYN-DQZO-SBUT. Your account should be activated immediately and will expire in three to four months. MythTV will indicate in various status screens when your account will expire. Zap2it.com will send you an email approximately one week before your account expires; when you re-subscribe they'll ask some additional survey questions. Zap2it states that they have no intention of charging non-commercial users for access to the guide data.

Once you've entered your Zip Code and configured your channel lineup you may exit the Zap2it web page.

Tip

If you don't receive a particular channel, make sure that your Zap2it account reflects that, since MythTV will be using this information to schedule programs.

Configure MythTV

Now that you have somewhere to store your settings and you've configured your Zap2it account, start up the MythTV backend server configuration utility:

	$ mythtv-setup

The first time you run mythtv-setup you will be asked for your preferred language, then whether you want to clear out any existing configurations for your capture cards and your channel lineup information. On this first launch go ahead and answer yes to both of those questions (but not for any subsequent runs, unless you have good reason to, or you'll have to reconfigure both your capture cards and channel lineups).

After these initial questions you'll be presented with five choices:

  • General

  • Capture cards

  • Video sources

  • Input connections

  • Channel editor

You can use the arrow keys to move about the interface, and the space bar to select items. You'll want to go through these steps in order, as some later steps depend on earlier steps.

Tip

MythTV does not have mouse support—it is designed on the premise that you are going to be using a remote control.

Since you only have one system running MythTV at the moment, you can leave the IP and port settings on the front page at their default values of 127.0.0.1. If you are aiming to have multiple MythTV systems (either multiple backends or a backend and some remote frontends), you want to put the IP address of the machine's Ethernet interface into both of these slots.

The next settings page lets you set the directory paths where MythTV will store recorded programs and what partition should be used for the live TV buffer. You need to double-check that these paths exist and that your MythTV user login has read/write permissions on them, or bad things will happen (well, MythTV just plain won't work). The defaults for Live TV buffer and Minimum free Live TV buffer should be suitable, and leave the "Save original files after transcoding" option off, as the topic of transcoding is one for another day.

The Global Backend Setup page is where you'll specify your TV format, which should be self-explanatory. Leave VBI format set to None for now, as VBI (a.k.a. teletext or closed captioning) support isn't yet very well supported by the ivtv driver. The channel frequency table should also be fairly evident, but you can try a few different ones if you aren't certain which one is right for your locale. Start out without any time offset for your XMLTV listings and the last two options on this page unchecked.

Leave the Shutdown/Wakeup Options page at all of its default values for now, as configuration of these settings can get quite involved. It may be possible to set up your MythTV box such that it'll hibernate when not in use, but save that for another day and just get basic functionality working first. Similarly, options on each of the last few pages under the General heading should suit you fine for your initial setup.

Under section 2, Capture cards, set up a new capture card, of card type MPEG2 Encoder card (if your card has an MPEG2 encoder; otherwise, choose a setting that matches your card), a video device of /dev/video0, and Tuner 0 for your default input.

In section 3, Video sources, configure your channel listings lineup. Start by giving it a descriptive name, and then select the XMLTV listings grabber for your location. Assuming you're in North America, you'll use the DataDirect grabber. Enter your Zap2it username and password in mythtv-setup. For those outside North America, you'll find some helpful details on the matter in the official MythTV documentation, specifically on this page: http://mythtv.org/docs/mythtv-HOWTO-9.html.

Continuing on, in section 4, Input Connections, assign your channel lineup to an input on your capture card. Specifically, assign the channel lineup you just created to the Tuner 0 input of your PVR-250. Highlight "[MPEG: /dev/ video0](Tuner 0) → (None)" and hit the space bar, then assign the video source accordingly. The only other setting you should touch is the starting channel. Set it to a known working channel (so you can have your tuner fall back to that channel by restarting the backend if anything goes haywire).

The last section, the Channel Editor, isn't something you'll need to touch at this time. For starters, there's no data in it until you've successfully run a mythfilldatabase operation, which you'll do once you've exited mythtv-setup.

Running MythTV for the First Time

Now exit mythtv-setup, start up the backend server for the first time, and run mythfilldatabase as the exit message on the console suggests you do:

	$ mythbackend &
	$ mythfilldatabase

The mythfilldatabase step can be a time-consuming process, depending on how many channels are in your channel lineup, the speed of your Internet connection, and the efficiency of your listings grabber. The North American DataDirect grabber is extremely quick, as zap2it provides an XML feed, while other grabbers have to rely on screen-scraping web pages of listings to gather guide data. The moral of the story here is: be patient!

You should already have the mythbackend server running in your existing terminal window, so open up another one in which you'll type the following, to launch the mythfrontend application:

	$ mythfrontend

The benefit of running the frontend and backend from different windows initially is that you can tell what messages are being output to the console by which component—so if something goes wrong, you might have a clue why.

A nice easy test to see if the primary functionality is operational is to simply try watching Live TV. Also thumb around with the remote control a bit to verify its functionality. The top menu item of the very first screen you're presented with when starting up the mythfrontend is Watch TV. Pressing either the Play button or the OK button on the remote should start up Live TV mode. The channel up and channel down buttons should allow you to move from channel to channel, just like your "normal" TV, while buttons such as Pause, FF, and Rew will allow you to do things that a normal TV almost certainly cannot do.

Assuming that Live TV and the remote work as expected, you can be pretty confident everything else will fall into place, so its now time to configure the mythbackend server process to start automatically at system boot time, and then make some additional preparations to hook your system to the television. Set the mythbackend to run at system startup by issuing the command:

	# /sbin/chkconfig mythbackend on

Automatically Log In and Start MythTV

To have the mythfrontend automatically start when your mythtv user logs in, click Desktop → Preferences → More Preferences → Sessions. Then, on the Startup Programs tab, add mythfrontend. That takes care of starting MythTV once you've logged on to GNOME, but ideally you'd take it one step further, which is to have a default user (namely, mythtv), automatically logged into the desktop environment.

To have your mythtv user automatically logged in when the system boots, you'll make some changes to the GNOME Display Manager (GDM). Launch the gdmsetup utility from a root prompt:

	# gdmsetup

Within gdmsetup, on the first tab, called "General," you should see a section titled "Automatic login." Check the box for "Login a user automatically on first bootup" and select your mythtv user from the pop-up menu.

Tip

Alternatively, if you are not very comfortable with Linux just yet, and you suspect there may be occasions where you've mucked something up to the point that an auto-login will lock up the computer, you might not want to use Automatic Login. Instead, you might opt to use the "Timed Login" option, to log in the mythtv user a few seconds after the login screen first appears. This way, you can circumvent the mythtv user logging in, and log in as root to (hopefully) correct whatever you've broken.

Connect to TV

At this point, you should have your system configured far enough that you're ready to hook it up to your television and control it from the couch with your remote control (and/or wireless keyboard). You just have to make a few little changes to your X configuration to let the video card know you're going to be hooking up to a television now, instead of a computer monitor. Add the following options to the Device section in /etc/X11/xorg.conf (assuming an S-Video connection and NTSC-M below):

	# TV Out Setup
	Option		"TVStandard" "NTSC-M"
	Option		"TVOutFormat" "SVIDEO"
	Option		"ConnectedMonitor" "TV"

Adjust accordingly for your location and connection type, per Appendix J of NVIDIA's README for driver, available online at ftp://download.nvidia.com/XFree86/Linux-x86/1.0-7174/README.txt. Now shut your machine down, hook it up to the television, and you should be in business!

Tip

NVIDIA creates new versions of the Linux driver frequently, so ensure that you've downloaded the correct version of the documentation for the driver you're running.

There are a few more adjustments to make now that you've got your system hooked up to your television. First, you'll want to launch the nvidia-settings utility from a terminal window:

	$ nvidia-settings

With nvidia-settings, you can adjust your computer output to the visible area of your television screen. I also recommend adjusting the flicker filter setting. Turn it up a little ways to eliminate some of the flicker inherent with outputting a computer's display, which is intended for a progressive-scan computer monitor, on an interlaced display. Once you're happy with your settings, simply exit out of the nvidia-settings utility. To get these settings to be applied the next time you restart your machine (you shouldn't have to very often), go back into Sessions utility you used earlier to auto-start mythfrontend and add a line:

	nvidia-settings --load-config-only

Final MythTV Tweaks

Now go into the Utilities/Setup → Setup section of mythfrontend to adjust a few other settings. On the third page under the General section, you can adjust default audio volume levels to taste. On the last page of that section, you'll want to enable the "Automatically run mythfilldatabase" setting, so that your guide data gets refreshed on a nightly basis.

Under the Appearance section, you can choose different themes for the mythfrontend user interface (G.A.N.T. for me), pick different Qt styles (different button and menu styles—I prefer Keramik here), font sizes, a few different menu layouts, and other settings.

Under TV Settings → General, you can adjust some recording parameters, such as setting an amount of time before a show is supposed to start and/or after it is supposed to end that also gets recorded.

Under TV Settings → Playback, you can enable a deinterlace filter if video playback seems to be full of jagged lines in high-motion scenes, adjust your automatic commercial skipping behavior, your seeking behavior, overscan of the TV picture if necessary, and alter your on-screen display theme and font (Isthmus with FreeSans is my personal preference).

The last little section of note at the moment is TV Settings → Recording Profiles, where you can adjust the bitrate and resolution at which your recordings are made (and even have them transcoded, if you so desire). A lower bitrate means less storage will be used per recording, so you might want to tweak these settings to get an optimal combination of storage usage and visual quality.

Tip

The keys.txt file will specify which commands are associated with each button on the keyboard.

Schedule Recordings

The first order of business to attend to now that you have things set up to your liking is to schedule some recordings. From mythfrontend click Manage → Schedule to find yourself at a menu listing where you can schedule a show to record by paging through the electronic programming guide (Guide), browsing an alphabetical listing of all known shows (Finder), by any number of search methods (Search), or by manually specifying a time and channel to record (Custom Record).

Of course, when choosing a program to record, you can choose to record only that showing or pick from any number of repeating algorithms, ranging from "record only in this timeslot on this channel on this day of the week" to "record this show any time it comes on any channel." The MythTV scheduler is very powerful, and because most grabbers will give you from 12 to 14 days of program listings, sometimes it may be best to give the scheduler more leeway in deciding when to record something. Rather than thinking "I have to record channel 'X' at time 'Y' in order to watch program 'foo'," you should consider that what you really want to do is to record program 'foo' and allow the scheduler figure out how to make that happen. This is especially useful when two or more programs you'd like to watch are on at the same time. Hopefully, at least one program will have a repeat; if not, and you are continually running into scheduling conflicts, the simplest solution may be to purchase additional capture cards.

With the Hauppuage PVR-500 card (which has two separate MPEG2 encoders on the card) and an Intel D865G motherboard (6 PCI slots) you could potentially record 12 programs at the same time, which should be enough to satisfy most people. If 12 programs aren't enough, simply set up an additional MythTV backend and configure it as a slave. The MythTV scheduler will then deconflict as many programs as possible.

Your MythTV system should now be happily recording your favorite TV shows for viewing (without having to watch commercials) when you get around to it. Once you have one or more programs recorded, simply navigate from the main page into the Media Library section and then into Watch Recordings. Just thumb through the recordings library and pick one to view at your leisure.

Conclusion

By no means was this a complete or authoritative look at all that MythTV has to offer and the myriad of options and features, but hopefully, it's a good start to your MythTV journey. A wealth of information can be found in the official MythTV HOWTO (http://mythtv.org/docs/mythtv-HOWTO.html), and the preceding is a somewhat abridged (and altered) version of the web site I maintain, dedicated to running MythTV on Fedora Core, which can be found at http://wilsonet.com/mythtv/fcmyth.php.

The MythTV community is a very active, on both the developer and user sides, with lively mailing lists (http://mythtv.org/modules.php?name=MythInfo) and IRC channels (#mythtv and #mythtv-users on FreeNode), as well as a number of community-run forums and wikis. If you have any problems or questions, there's bound to be someone out there who can help you on your way to MythTV nirvana.

Jarod Wilson

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required