EFF's HDTV-PVR Cookbook

Requirements

You will need:

Optionally, you may want to add

Typically, you will use a computer monitor for setup purposes even if you intend eventually to use your PVR with a television. You will also need a means of obtaining the KnoppMyth CD (usually, a broadband Internet connection and a working computer with a CD burner). Ideally, you should have a separate working computer available during the installation process for research purposes; see our list of documentation and support resources below.

Step 1: Assemble and plug in your computer

Once you've installed your pcHDTV card and any other interface cards, locate your computer in a convenient spot, and attach all of its cables and peripherals. Be sure to connect your antenna or antennas. (With current hardware, you will need at least one connection into your computer for every television programming source you want to receive; for example, if you want to receive both ATSC and NTSC broadcasts, you will need two antenna connections.)

Step 2: Obtain a KnoppMyth installation CD

KnoppMyth releases can be downloaded from several mirror sites, including PlanetMirror. Once you've downloaded an ISO9660 image, you can verify its checksum with the md5sum program and then burn it to a CD-R disc using your favorite CD recording software.

Step 3: Start KnoppMyth setup

Ensure that your MythTV system is set to boot from CD-ROM. Put your KnoppMyth disc into the CD-ROM drive, and power on the computer.

At the boot: prompt, press Enter.

If you receive a note about an "undefined video mode", press the space bar; otherwise, don't worry about this. (This appears most likely to occur if you have your machine connected to a television rather than a computer monitor.)

For now, choose manual install (option 4) from the menu. (After the forthcoming release of KnoppMyth v5, this recommendation may change.)

Be sure to set your timezone properly, or program guides won't align properly and scheduled recordings won't work. Ensure that your system clock is set accurately with respect to the selected timezone. (Sometimes, the time may need to be corrected, especially if your computer has been unused for a long time or previously used a non-Linux-based operating system. Once you have your system running, you can keep the time properly adjusted with the ntpdate utility.)

This installation process will wipe out any contents of the hard drive onto which KnoppMyth is installed, unless you understand the installation process in sufficient detail and choose to ask it to do otherwise.

Begin by partitioning the hard drive onto which KnoppMyth will be installed. Choose option 3, "Partition", from the KnoppMyth installation main menu. In our example, we are installing on /dev/hda, the first (master) hard drive on the first (primary) IDE/ATAPI controller. If you are installing onto a different hard drive, you'll need to select that hard drive instead. (You can select a hard drive by highlighting it and pressing the space bar.) If your computer uses serial ATA (SATA) for its primary drive, your installation will most likely be to /dev/sda.

KnoppMyth expects a specific configuration of partitions that works well for storing the large video files HDTV creates. A suitable partition layout for KnoppMyth is as follows:

partition one,    /        the root filesystem (5000MB)
partition two,    swap	   as large as your physical RAM
partition three,  /cache   for storing live TV buffer files (10000MB)
partition four,   /myth    for storing recordings and other media (as much as possible)

Choose the hard drive to be partitioned from the menu and press the space bar to select it; then press Enter.

You will then need to partition the hard drive using cfdisk. Pressing h within cfdisk gives brief instructions, or you may wish to consult the cfdisk manual at this point.

Screenshot 1: cfdisk, showing a drive's partition table

In short, you move among the options at the bottom of the screen with left and right arrow keys or type the first letter of the option you want to select. First, delete any existing partitions on the hard drive you are partitioning. (Note that this will result in loss of any existing data on that hard drive; if your system contains multiple hard drives, please be certain you are partitioning the hard drive you intended to partition!) Create a new partition, set its type to "primary", enter its size in megabytes (we recommend 5000 MB), and set its type to "Linux" (83). Select [Bootable] for this first partition. This will be your root partition, /, where the KnoppMyth software is installed. Create a second partition, the size of your physical RAM, and set its type to "Linux swap" (82). Create two more "Linux" (83) partitions, 10,000 MB /cache and the remainder /myth. (Whenever cfdisk asks you where a new partition should be located, choose [Beginning].)

When you are done partitioning your hard drive, you should select [Write], followed by [Quit]. If you exit cfdisk without Writing, none of your changes will be saved.

Now choose menu item 1, "Configure Installation". You will be asked a small number of questions about your system. When prompted, choose the partition in which KnoppMyth should be installed (your root partition), and select it by pressing the space bar, and then press Enter. When prompted, also enter your username and password information, and choose an administrative (root) password. You will need to use these passwords later. When prompted, indicate that the LILO bootloader should be installed into the Master Boot Record (MBR) of the hard drive. Finally, give your computer a hostname, or accept "box" as the default name.

Now choose menu item 2, "Start Installation". You will be asked to confirm the choices you made in the "Configure Installation" dialogues. Do so by choosing "Yes" and pressing Enter. At this point, KnoppMyth will install software onto your hard drive. A small number of error messages at the conclusion of this process are normal and do not indicate a problem.

After the installation process is complete, you will be presented with a shell prompt; you'll need to use this prompt to perform a few minor housekeeping tasks. In the examples given below, we assume that your root filesystem is called /dev/hda1; if your root filesystem is somewhere else, you'll need to substitute its device name for /dev/hda1 in the examples that follow.

First, mount the new system and chroot into it:

root@tty1[/]# mkdir /target; mount /dev/hda1 /target
root@tty1[/]# chroot /target

Now remove the initrd line from /etc/lilo.conf, and be sure that your video mode setting is appropriate to your choice of computer monitor or television. If you are using a computer monitor, you will use the following command:

sh-3.00# grep -v initrd /etc/lilo.conf > /tmp/lilo.conf
sh-3000# mv /tmp/lilo.conf /etc/lilo.conf

If you are using a television rather than a computer monitor, you will use the following command instead:

sh-3.00# grep -v initrd /etc/lilo.conf | sed 's/vga=791/vga=normal' > /tmp/lilo.conf
sh-3.00# mv /tmp/lilo.conf /etc/lilo.conf

Now install the lilo bootloader:

sh-3.00# lilo -v

Now add "sysfs /sys sysfs defaults 0 0" to the end of /etc/fstab:

sh-3.00# echo 'sysfs /sys sysfs defaults 0 0' >> /etc/fstab

Give /var/tmp the appropriate permissions:

sh-3.00# chmod 1777 /var/tmp

Finally, finish up the process and restart the computer:

sh-3.00# exit
root@tty1[/]# umount /target
root@tty1[/]# reboot

When the system prompts you to remove the CD, remove it and press Enter. The system will then attempt to reboot using the KnoppMyth system that has been installed on the hard drive.

Step 4: Perfect your video settings

During the reboot process, it should become quickly apparent whether KnoppMyth has failed to choose appropriate graphics settings. If you see a graphical display, KnoppMyth has detected your graphics settings properly; if you see an error about video modes, it has not.

Using a computer monitor rather than a television significantly increases the chance that KnoppMyth will get your video settings right out-of-the-box. If you intend to use a television but KnoppMyth does not provide appropriate video output, try using a computer monitor initially for setup purposes, and consult the resources described below for more information about perfecting your video settings. In general, whether you are using a television or a computer monitor, if you don't have a good on-screen display or display resolution, you will need to change the X server configuration at this point. In some cases, running xf86cfg as root may assist in this process; if you need more help, please consult the resources described below.

If you have success with a particular video card, you are encouraged to submit your XF86Config-4 file to the KnoppMyth project so that other users can benefit from your experience.

NVIDIA's Binary Drivers

NVIDIA has pursued an anachronistic and counterproductive policy of publishing its drivers in binary-only form and refusing to release sufficient information for the creation of a free/open source driver. For this reason, we are eager to collect information about users' success with other manufacturers' video cards, and hope to publish more detailed information about other video cards here following tests later in January 2005.

Please contact NVIDIA and ask them to release a free/open source driver or information sufficient to allow third parties to create one.

2701 San Tomas Expressway
Santa Clara, CA 95050
Tel: 408-486-2000
Fax: 408-486-2200
E-mail: linux-bugs@nvidia.com

(NVIDIA's policy about this has been established and unchanged for years, but it has not improved and NVIDIA still needs to hear that current and prospective customers are dissatisfied.)

Information for NVIDIA users

If you're using an NVIDIA card, you may wish to use our XF86Config-4 file, which we've found to work with the FX5200; to use it, you'll need to install it as /etc/X11/XF86Config-4. You can do this by downloading it from within a web browser and then running commands such as

root@box:~# mv /etc/X11/XF86Config-4{,.original} 
root@box:~# mv -f fx5200-XF86Config-4 /etc/X11/XF86Config-4

After installing the XF86Config-4 file, you must restart your computer, or else restart the X server by pressing Ctrl-Alt-Backspace. The NVIDIA kernel driver will be loaded automatically. (Note that this will taint your kernel; you will receive a syslog message such as "box kernel: nvidia: module license 'NVIDIA' taints kernel.")

Our configuration should be suitable for use with either a computer monitor (via the VGA interface) or a television (via the DVI interface); you might need to adjust the resolution if the default resolution is inappropriate for your display device. You can cycle through supported display resolutions by pressing Ctrl-Alt-Plus or Ctl-Alt-Minus.

Step 5: Complete the installation process

After a successful reboot from the hard drive, you'll be prepared to continue with the configuration of MythTV. Note that, when using the Fluxbox window manager which is the default on KnoppMyth, you'll need to keep your mouse pointer located within the borders of the window you want to type in.

Close the window that is initially displayed and asks for your root password. You can do this by clicking the "X" in its upper right-hand corner.

Now open up a new xterm. To do this, right-click on the desktop, select XShells, and then select Xterm.

Screenshot 2: a new xterm after entering the root password

Become root.

sh-3.00$ su -
	[enter the root "administrative" password]

Depending on your hardware and network configuration, your machine may or may not have started networking automatically. If it has not connected automatically (test by pinging a known host), you will want to start that now. (Here we assume that your machine is connected to a network that provides DHCP service. If not, you will need to follow the general procedure that you ordinarily follow for manual network configuration. In some cases, it is currently necessary to start networking manually every time your KnoppMyth system is rebooted.)

Test for network connectivity:

root@box:~# ping -c 1 google.com
PING google.com (216.239.57.99): 56 data bytes
64 bytes from 216.239.57.99: icmp_seq=0 ttl=242 time=11.2 ms

--- google.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 77.6/78.1/79.8 ms

If instead you wait a few seconds and see nothing, follow the next step to run dhclient.

root@box:~# dhclient

After verifying/starting networking, perform some basic network service reconfiguration. (Reconfigure the secure shell, ssh, and set the apache webserver to load PHP version 4 modules, as required by MythWeb.)

root@box:~# dpkg-reconfigure ssh
	[answer "yes" if asked about the ssh-keysign program]
	[answer "yes" if asked about starting the sshd server]
root@box:~# /etc/init.d/ssh restart
	[sshd will restart]
root@box:~# cat /etc/apache/httpd.conf | sed 's/#\(AddType.*php[ -].*\)/\1/' > /tmp/httpd.conf
root@box:~# mv -f /tmp/httpd.conf /etc/apache/httpd.conf
root@box:~# echo 'LoadModule php4_module /usr/lib/apache/1.3/libphp4.so' >> /etc/apache/modules.conf
root@box:~# /etc/init.d/apache restart
	[apache will restart]

Step 6: Test your reception and obtain channel listings

Now it's time to find whether the system can recognize your ATSC capture card. To find the device number of your pcHDTV card, run dtvsignal:

$ dtvsignal /dev/dtv0 [channel frequency] 

If it's not dtv0, increment the device number, e.g. /dev/dtv1, /dev/dtv2, etc. (/dev/dtv0 is the most likely possibility on a system containing only a single pcHDTV card.)

It helps if you know a frequency with a strong DTV signal. Within the United States, you can find the frequency of a local DTV station, and its compass direction from your location, by entering your ZIP code the Antennaweb.org site, operated by the Consumer Electronics Association. (Follow the "choose an antenna" link at Antennaweb.)

If you have selected the correct device, dtvsignal will return a chart something like this:

sh-3.00$ dtvsignal /dev/dtv2 19
main: argc 3 argv[1] /dev/dtv2
channel 19
freq*16 = 8020
main: ioctl 1 rtn 0
main: ioctl 2 rtn 0
dtvsignal ver 0.1 - by Jack Kelliher (c) 2002
channel = 19 freq*16 = 8020
 30db       0%         25%         50%         75%        100%
Signal:     |     .     :     .     |     ._____:_____._____|
Signal: 033 ----------------

While the dtvsignal program's bar graph is displayed on your screen, it will be updated to display the current signal strength in real-time, and so you can watch it as you reorient or relocate your antenna as necessary to get a strong signal. When you're satisfied, you can exit dtvsignal by pressing Ctrl-C.

If you guess an incorrect device number, instead of a signal strength bar graph, you'll typically see a result similar to this one:

sh-3.00$ dtvsignal /dev/dtv1 19
main: argc 3 argv[1] /dev/dtv1
No such device - couldnt open file /dev/dtv1

On our test machine, the HD-3000 was called /dev/dtv2; we refer to the name of the HD-3000 capture device as [dtvdevice] in the instructions below.

Now you'll need to set up Zap2it channel listings for your local DTV broadcasts, so that MythTV will know what's on TV when. From this point forward, we suggest that you have a graphical web browser installed on your MythTV machine. For example, you might choose Mozilla Firefox:

root@box:~# apt-get update
root@box:~# apt-get install mozilla-firefox
	[confirm the download and installation of the Firefox browser]

(That won't put an icon onto the desktop, but to start Firefox, you enter firefox & at the shell prompt.)

If you don't want to install Firefox at this point, or you have another computer available, you may use your other computer for this step. At http://labs.zap2it.com/, sign up as a new user. (Zap2it provides guide data free on an individual basis, but asks users to complete a quarterly survey.)

The MythTV "Certificate Code" is ZIYN-DQZO-SBUT.

You'll then need to create a Zap2it "lineup" (a list of channels for which you wish to receive guide data).

Screenshot 3: Telling Zap2it to create a broadcast channel lineup

You'll want to configure a lineup with only digital channels for the pcHDTV card. (If you have a second tuner card that receives NTSC channels, you can create a lineup for it in a neighboring ZIP code; currently it is difficult to use a lineup that mixes ATSC and NTSC channels. Therefore, you should unselect all channels before beginning to create your lineup.)

Screenshot 4: Zap2it shows local channels available for selection

You'll have the smoothest experience if you start out with only channels you know you receive. With the antenna set to its optimal position, run dtvscan:

sh-3.00$ dtvscan [dtvdevice] > chanlist
sh-3.00$ cat chanlist 

This will show the listing of channels received in the form callsign: standard channel: dtv frequency: subchannel; for example, you might see a line like

KBWB-DT:      :20.1 :19: 1:0

Unselect in the Zap2it lineup any channels that don't show up in the chanlist file. (This will prevent MythTV from trying to receive channels that are not available in your area; if you want to try improving your reception, you can also reorient the antenna and try the dtvscan process again.)

Step 7: Configure the MythTV software

Now you're ready to start MythTV setup:

sh-3.00$ mythtv-setup
	[answer "no" if asked to clear capture card or program information]

Screenshot 5: MythTV setup menu

The mouse is not used in MythTV, so you navigate with the arrow keys. If you've attached a remote control adapter to your system, or if it came pre-equipped with one, you can likely also use a remote control to control MythTV at this point. When using arrow keys on the keyboard or arrow buttons on a remote control, up and down arrow move among the options; right and left arrow select check boxes or list choices. Return/Enter/Select moves to the next screen, Esc cancels out of a screen or, when the main screen is displayed, cancels the entire setup process.

The default options are generally all right, except for those changes indicated below:

In General Setup, third setup screen ("Global backend setup")
TV-Format: ATSC
Channel Frequency Table: us-bcast

Screenshot 6: Global backend settings

In Capture cards setup
New capture card 
Card type: pcHDTV ATSC Capture Card
Video device: [dtvdevice] (type into the field)

Screenshot 7: New capture card

In Video sources Setup
New video source
Data Source: North America (DataDirect) gets the Zap2it listings
Name this source HDTV-broadcast
Retrieve listings to download guide data

Note that you must enter your own Zap2it username and password in the video source definition here.

Screenshot 8: New video source

Input connections
Select the HDTV: [dtvdevice] (Television) 
Video Source: HDTV-broadcast (the name you created in the previous step)
Starting channel: (we'll get back here later)

Screenshot 9: Input connections

Return to the main screen and press Esc to exit the setup process. Then run

sh-3.00$ mythfilldatabase

Various scrolling messages, including "401 Unauthorized" as the service authenticates, are normal.

The last thing you need to do before starting to watch TV is to put the correct DTV frequencies into your channel listing table. It's easiest to do that through the MythWeb web-based interface. On your MythTV machine, start a web browser and load the URL http://localhost/mythweb/settings_channels.php, like this:

sh-3.00$ firefox http://localhost/mythweb/settings_channels.php &

(We should reiterate here that, if you don't have some software you need, such as Firefox, you can install it using the apt-get command; as root, first run apt-get update and then apt-get install [packagename], where [packagename] is the name of the Debian package containing the software you need.)

If you see an error about the unavailability of a MythTV backend, you should be able to clear it up by running

sh-3.00$ mythbackend &

and then trying the MythWeb interface again.

Your web browser should present you with a web-based interface to MythTV; in this interface, you can control a variety of MythTV functions. (At the top of the MythWeb interface, you can read amusing quotations about copyright law.) For now, we will use this interface only to update MythTV's internal channel listing table.

You need to change two columns in this table: channum and freqid.

The channum must be purely numeric (no letters or punctuation) and must be distinct for each channel or subchannel. This is inconvenient because DTV broadcast stations typically have subchannel numbers such as "30-1", but the hyphen is not allowed as part of a MythTV channum. What's more, if your computer includes both an analog TV (NTSC) tuner card and a digital TV (ATSC) tuner card, you may receive an NTSC and ATSC station with the same channel number; to distinguish them within MythTV, they must be assigned different channums.

Therefore, you will typically have to follow some convention to choose new channum values for the DTV stations you receive. One common convention is to use a four-digit number beginning with the digit "1", followed by the channel number, followed by the subchannel number; for example, San Francisco's KQED-DT (at DTV channel 9) would have its five subchannels given the chanid values 1090, 1091, 1092, 1093, and 1094. Since chanid values are arbitrary and only used to let MythTV tell channels apart, you can use any convention you prefer, although it's best to be consistent. It is possible that future versions of MythTV will assign usefully distinct chanids automatically, so that this step may disappear in the future.

Next, for each channel, the freqid should be changed to match the frequency you saw in the chanlist file above (or the frequency given in the table at Antennaweb.org), with a hyphen (-) between the channel and sub-channel. Using the example of KQED-DT, the freqids are 30-1, 30-2, 30-3, 30-4, and 30-5. If there's only one subchannel for a particular DTV station, it's often (but not always) designated channel xx-1.

Now you're almost ready to start up MythTV. But, before starting MythTV for the first time, make sure you're tuned to a strong signal. You can verify this by running

$ dtvsignal [dtvdevice] [freqid of a strong channel]

For example, if your DTV tuner is identified as /dev/dtv2 and you know that you have good reception on local DTV channel 30, you would enter

$ dtvsignal /dev/dtv2 30

Once you have done this, you'll want to start up the mythfrontend program.

$ mythfrontend

Screenshot 10: MythTV main menu (other themes are available)

You may want to set the "Starting Channel" option (mentioned above) to the channel you just used dtvsignal to select, so that this channel will be tuned automatically whenever MythTV is started.

A few setup tweaks from within the MythTV application help make browsing smoother. First, in TV Settings - General - Screen 1:

Channel ordering: use database order

This will improve the channel ordering. In TV Settings - General - Screen 2, we recommend setting

Time limit for ATSC Signal Lock: 10000
ATSC signal threshold: 50

Both of these settings ask MythTV to try harder to tune in weak signals. In Playback - Screen 10:

Always use Browse mode [check]

When you first tune to a particular channel, it is normal for MythTV to take several seconds before beginning to show live TV programming, since it waits to catch intermittent "keyframes" within the MPEG-2 encoded signal.

Step 8: Securing your Myth box

Since your Myth box will be connecting to the Internet for program guide data, you will want to make sure that it is secure. You don't want someone remotely setting your box to record every episode of "Barney and Friends," or worse, using your machine as a base for attacks on others.

Give MythWeb basic security with the /var/www/mythweb/.htaccess file, by removing the # marks (comments) from the first four lines of this file.

root@box# sed '1,4s/^#//' < /var/www/mythweb/.htaccess > /tmp/htaccess
root@box# mv -f /tmp/htaccess /var/www/mythweb/.htaccess 

Now create a new user and password:

root@box# htpasswd -c /var/www/htpasswd [username]

You will be prompted to enter a password twice.

You will also want to change the default password for the MythTV user account.

Step 9: You're done

Now that your KnoppMyth installation is complete, you can keep installed software up-to-date using the Debian apt-get program. You can also start a MythTV frontend by running mythfrontend at a shell prompt, or configure MythTV to start up automatically when your computer is booted.

If you choose, you can set up other client machines that will use your PVR as a server to provide network streaming of recorded programming. For more on this and other MythTV features, please consult the MythTV documentation.

Have fun, keep in touch, and please let your friends know about the broadcast flag restrictions.

Thanks to all the developers and documentors who have made MythTv work much better than what Hollywood will let you use.

Other resources

Documents Lists and forums Home pages