MythTV Setup

This page describes what I've been through to set up my MythTV box. If you're considering doing this yourself, you should be warned that making one is certainly not a trivial undertaking, either in terms of time or money. Now that it's working basically OK the box is great, but if you're not at least partly setting it up out of interest this is likely to be a frustrating and time-consuming exercise. This page isn't really intended as a guide, although it might be of some use if you're trying to set up a MythTV DVB-T box in the Edinburgh area...

There's a lot of helpful advice on the web which this is heavily based on. As well as random pages turned up with Google, Martin Smith's MythTV DVB Setup Guide and Jarod C. Wilson's guides were particularly useful.

Summary

Since it may appear a short way into this document that the whole thing was just an unmitigated nightmare, I should make it clear that there are lots of things that are very cool about my MythTV box:

The things that aren't so good are basically just that:

Hardware and Costs

I overspecced the hardware somewhat, since I wanted to make sure that the box would be able to cope with playing back high definition video in software. You could make it much more cheaply, though, as is noted below.

So, that all cost about £490 in total (all those prices include VAT, but not delivery costs.) The most obvious ways you could cut that down are:

I had a TV already, so the cost of a display isn't included, and similarly I borrowed a keyboard + mouse from another PC for setting it up - in use, it's fine with just the IR remote control bundled with the Hauppauge card.

Operating System

I installed Debian from an etch boot-CD, with a quite minimal set of packages, adding things as I needed them. I made APT's default release "testing". You need a late 2.6 kernel to support the Nova-Ts' Conexant chips. I'm currently using 2.6.18, but it's been find from 2.6.13.1. For completeness, you can see my kernel .config and lspci -v output. I used nVidia's XFree86 drivers, which work well - my XF86Config-4 is essentially as suggested in the nVidia drivers' README file for a PAL TV configuration, although note that I've commented out the DPMS line in the Monitor section. The card is smart enough to start displaying on the TV from boot if the S-Video but not VGA is connected. I'm currently using version 8774 of the nVidia drivers.

MythTV Software

For reasons I forget now, I decided against using the Debian packaged version of MythTV and built my own from the sources in the MythTV Subversion repository using the release-0-18-fixes branch. built my own from source. Although I've tracked the latest SVN for some period, that's a frustrating exercise unless you're actively interested in finding and fixing bugs - the 0.20a release is great for me.

Preliminaries

Firstly I followed the instructions in Martin Smith's MythTV DVB Setup Guide to check that my Nova-T cards were working, using scan from dvb-utils and using the resulting channels.conf with gxine. The Black Hill transmitter (that seems to give me a pretty good signal) has a start file for scan in the dvb-utils package: /usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-BlackHill

Two sites that may be useful for finding transmitter information are:

Running mythtv-setup

You may have to try this a couple of times, so for a mostly clean start, say "yes" to "delete card settings" and "delete channel settings". Only do that if you really are starting from scratch again, though. mythtv-setup should be run without mythbackend, mythfrontend or mythfilldatabase running.

General

These should mostly be left at the default settings, although you may need to change (or create with appropriate permissions) the directories to hold recordings and hold the Live-TV buffers. TV format should be PAL, VBI format should be PAL Teletext and the Channel frequency table should be europe-west. On the page marked "Job Queue (Host-Specific) I turn off "Allow Commercial Detection jobs" since I haven't found that the commercial detection works very well, and the mythcommflag processes are running more or less all the time.

Capture cards

Add all your DVB-T cards here with the default options. I have two Nova-T cards, so I end up with DVB 0 and DVB 1.

Video sources

"Video source" seems to be the slightly odd name for a program listings database. In this case, I use the excellent and free RadioTimes XMLTV feed, so give it a name like "Radio Times Guide" and select the XMLTV listings grabber "United Kingdom (alternative): tv_grab_uk_rt". This will then start grabbing channel information, at which point you'll have to alt-tab to the terminal you started mythtv-setup from to say to add all channels. Switch back and move on to the next step:

Input connections

Just connect all the DVB cards to the Radio Times Guide video source you just created. The only tricky bit here is that it's important that your "Starting channel" is one that you can actually receive, so I normally set it to "3" - ITV seems to be pretty reliable for me.

Channel editor

Update (2006-10-09): mythtv-setup has been much improved since I wrote this, so just doing a full scan from mythtv-setup should (I hope) work OK. If you're obviously missing channels you think you should get, then try repeating the scan a few times or entering a transport manually. I've moved the older material from this section to another page. Essentially, after you are happy with the results of the scan (i.e. once all the channels you expect are listed in the Channel Editor) you exit mythtv-setup and run mythfilldatabase (making sure that the backend is running.) However, mythfilldatabase will take a very long time unless you remove many of the xmltv IDs from the file that it looks at (in my case that's ~mythtv/.mythtv/RadioTimes Guide.xmltv), so you should edit that. I've ended up with the following lines in that file:

channel scotland.bbc1.bbc.co.uk
channel scotland.bbc2.bbc.co.uk
channel scottishtv.co.uk
channel channel4.com
channel channel5.co.uk
channel itv2.itv.co.uk
channel choice.bbc.co.uk
channel teleg.co.uk
channel knowledge.bbc.co.uk
channel itv3.itv.co.uk
channel more4.channel4.com
channel e4.channel4.com
channel abc1.disney.com
channel qvcuk.com
channel the-hits.emap.com
channel ukbrightideas.tv
channel ftn.tv
channel tmf.nl
channel idealworld.tv
channel bid-up.tv
channel price-drop.tv
channel itv4.itv.co.uk
channel filmfour.channel4.com
channel C1990.radiotimes.com
channel cbbc.bbc.co.uk
channel cbeebies.bbc.co.uk
channel C1981.radiotimes.com
channel news-24.bbc.co.uk
channel parliament.bbc.co.uk
channel communitychannel.org
channel itn.co.uk
channel dvb.teachers.tv

For reference, my dtv_multiplex table looks like this:

mysql> select mplexid, transportid, networkid, frequency from dtv_multiplex;
+---------+-------------+-----------+-----------+
| mplexid | transportid | networkid | frequency |
+---------+-------------+-----------+-----------+
|       1 |        4156 |      9018 | 570166670 |
|       2 |        8209 |      9018 | 538000000 |
|       3 |       12291 |      9018 | 489833330 |
|       4 |       16384 |      9018 | 513833330 |
|       6 |       24576 |      9018 | 618166670 |
+---------+-------------+-----------+-----------+

... and my channel table looks like this:

mysql> select chanid,channum,callsign,name,xmltvid,mplexid,visible from channel order by (channum+0);
+--------+---------+--------------+--------------+-------------------------+---------+---------+
| chanid | channum | callsign     | name         | xmltvid                 | mplexid | visible |
+--------+---------+--------------+--------------+-------------------------+---------+---------+
|   1001 | 1       | BBC ONE Scot | BBC ONE Scot | scotland.bbc1.bbc.co.uk |       1 |       1 |
|   1002 | 2       | BBC TWO Scot | BBC TWO Scot | scotland.bbc2.bbc.co.uk |       1 |       1 |
|   1003 | 3       | stv          | stv          | scottishtv.co.uk        |       2 |       1 |
|   1004 | 4       | Channel 4    | Channel 4    | channel4.com            |       2 |       1 |
|   1005 | 5       | five         | five         | channel5.co.uk          |       3 |       1 |
|   1006 | 6       | ITV2         | ITV2         | itv2.itv.co.uk          |       2 |       1 |
|   1007 | 7       | BBC THREE    | BBC THREE    | choice.bbc.co.uk        |       1 |       1 |
|   1009 | 9       | BBC FOUR     | BBC FOUR     | knowledge.bbc.co.uk     |       4 |       1 |
|   1010 | 10      | ITV3         | ITV3         | itv3.itv.co.uk          |       2 |       1 |
|   1013 | 13      | More 4       | More 4       | more4.channel4.com      |       2 |       1 |
|   1014 | 14      | E4           | E4           | e4.channel4.com         |       2 |       1 |
|   1015 | 15      | abc1         | abc1         | abc1.disney.com         |       3 |       1 |
|   1099 | 18      | The HITS     | The HITS     | the-hits.emap.com       |       6 |       1 |
|   1100 | 21      | TMF          | TMF          | tmf.nl                  |       6 |       1 |
|   1030 | 30      | ITV4         | ITV4         | itv4.itv.co.uk          |       2 |       1 |
|   1105 | 31      | Film4        | Film4        | filmfour.channel4.com   |       6 |       1 |
|   1080 | 80      | BBC NEWS 24  | BBC NEWS 24  | news-24.bbc.co.uk       |       1 |       1 |
|   1081 | 81      | BBC PARLMNT  | BBC PARLMNT  | parliament.bbc.co.uk    |       4 |       1 |
|   1087 | 87      | Community    | Community    | communitychannel.org    |       4 |       1 |
+--------+---------+--------------+--------------+-------------------------+---------+---------+

I edited this table by hand to completely remove lots of channels (rather than just making them invisible) and to manually enter correct xmltvids for each channel (which is not done automatically.

Anyway, that's the difficult bit all set up...

"Kiosk"-style operation (using gdm)

To make everything work as smoothly as possible after reboots and power cuts, I set up gdm with:

AutomaticLoginEnable=true
AutomaticLogin=mythtv

... and gave the mythtv user a ~/.xsession that looks like this:

#!/bin/sh

xset s off
xset -dpms

xvattr -a XV_COLORKEY -v 66048
# xvattr -a XV_COLORKEY -v 0

export LD_LIBRARY_PATH=/usr/local/lib
mythfrontend -v everything 2>&1 >> /var/log/mythtv/mythfrontend.log

The xvattr line is to stop the blue lines around the picture that you get with nVidia graphics cards and TV-out. It's important to turn off screen blanking here and in the XF86Config-4, since I found that I couldn't wake up the display again after it blanked.

"Kiosk"-style operation (using startx)

I've found that the frontend still crashes very occasionally, and it's nice to have it restart automatically. Since inittab has a sensible respawn mechanism built in, it seems reasonable to use that. Following this suggestion I changed /etc/inittab so that the default runlevel is 3 instead of 2 (id:3:initdefault:) and added the line TV:3:respawn:/bin/su - mythtv -c startx (where TV is an arbitrary identifier that meets the requirements mentioned in the inittab man page.) You also need to allow the mythtv user to start the Xserver, so I changed allowed_users in /etc/X11/Xwrapper.config from console to anybody. You should use a ~mythtv/.xinitrc file that's identical to the .xsession file that's suggested above. You should then remove the gdm package and reboot.

cron setup and logging

In addition, you'll want to make mythfilldatabase run every week, which I do with /etc/cron.weekly/mythtv as:

#!/bin/sh

export LD_LIBRARY_PATH=/usr/local/lib

su - mythtv --command="nice mythfilldatabase"

... and set up logrotate to deal with the log files by adding a file /etc/logrotate.d/mythtv with the contents:

/var/log/mythtv/mythbackend.log {
        daily
        rotate 7
        notifempty
        copytruncate
}

/var/log/mythtv/mythfrontend.log {
        daily
        rotate 7
        notifempty
        copytruncate
}

That's basically just following what's in the Debian packaged version. You'll also want to start mythbackend as the mythtv user on startup using one of the skeletons in the contrib directory of the mythtv source distribution and update-rc.d.

The Hauppauge Remote Control

/var/log/dmesg should show a line like "cx88[0]: registered IR remote control" to show that it's detecting the remote control. Assuming your kernel configuration is fine, this will just appear as a /dev/input/event? device. You can check which one with cat /proc/bus/input/devices :

I: Bus=0010 Vendor=001f Product=0001 Version=0100
N: Name="PC Speaker"
P: Phys=isa0061/input0
H: Handlers=kbd event0 
B: EV=40001 
B: SND=6 

I: Bus=0001 Vendor=0070 Product=9002 Version=0001
N: Name="cx88 IR (Hauppauge Nova-T DVB-T"
P: Phys=pci-0000:00:0a.0/ir0
H: Handlers=kbd event1 
B: EV=100003 
B: KEY=100fc312 214a802 0 0 0 0 18000 41a8 4801 9e1680 7bb80 0
10000000 

I: Bus=0001 Vendor=0070 Product=9002 Version=0001
N: Name="cx88 IR (Hauppauge Nova-T DVB-T"
P: Phys=pci-0000:00:0b.0/ir0
H: Handlers=kbd event2 
B: EV=100003 
B: KEY=100fc312 214a802 0 0 0 0 18000 41a8 4801 9e1680 7bb80 0
10000000 

In this case I'm using the event1 remote control, so my /etc/lirc/hardware.conf looks like:

# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS=""

#Don't start lircmd even if there seems to be a good config file
START_LIRCMD=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="dev/input"
# If DEVICE is set to /dev/lirc and devfs is in use /dev/lirc/0
# will be
# automatically used instead
DEVICE="/dev/input/event1"
MODULES=""

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""

One thing to watch out for is that these devices will be renumbered depending on whether you have a keyboard plugged in or not...

There are plenty of samples of what your /etc/lirc/lircd.conf file should look like on the web, but I created my own using irrecord lircd.conf.kernel-2.6.13.1 --driver=dev/input --device=/dev/input/event1 just to check it was all working with my kernel version. You should restart lircd after updating /etc/lirc/lircd.conf. I created a ~/.mythtv/lircrc with configuration for MythTV and xine. (You have to symlink to that from ~/.lircrc for the configuration to be picked up by xine.) You will probably want to change the key assignments to something you're comfortable with, but for the record my lircrc is available. The Hauppauge remote works well, and makes the whole system feel much more like an appliance than if you have to have a keyboard on your sofa.

Miscellaneous Further Problems

The serious problems I've had have either been fixed by the 0.20a release (the one I'd recommend) or replacing what turned out to be a dodgy SATA disk with a working EIDE disk.