Media PC Software

Introduction

I'm afraid it's true: Setting up a mythtv box can be a bit of a pain. I've been through it twice now, the first time I didn't really know what I was doing, but ended up with a working MythTV 0.18 install on Ubuntu Breezy. The second time I kept notes as I went. Even with the benefit of hindsight, there were a few missteps, but I do now have a working MythTV 0.19-and-a-bit install on Kubuntu Dapper. Here's how I did it. Now that I have a working setup, I'm not going to want to nuke it and start over without good reason, so these instructions are the simplified version of my notes, untested. (I didn't think everyone would want to read how I tried something, then uninstalled it all, tried something else, uninstalled that and went back and got the first thing working in the end...). Please do leave a comment if you spot errors, or have any questions.

The instructions presented here assume you want a system just like mine, obviously feel free to deviate if you want or need to.

1. Install the Operating System

When I started out, Ubuntu was nearing their Dapper release, so I installed from a Kubuntu Flight 7 CD. That didn't go too smoothly, but I submitted a fix. Install Dapper from a Kubuntu Dapper install CD. I created a mythtv user during the install. Mythtv will be the user logged in most of the time, running the frontend app. I deliberately made this different from my normal user login, because I let friends etc use the computer when they're over.

I created a 10Gb ext3 partition for /, a 1Gb swap partition and left the rest for /video (formatted to JFS). After a few months of usage, / is 75% full (including some junk in ~mythtv, etc), so I think that's about right. With the flight7 install CD, I had some problems making /video JFS formatted and mounted as /video from the installer, so manually formatted it with
mkfs.jfs /dev/hda3
and added it to /etc/fstab.

Reboot into the newly installed OS.

Next up was to configure the wireless network card - edit /etc/network/interfaces to look like this:
auto lo
iface lo inet loopback

iface ath0 inet dhcp
wpa-driver madwifi
wpa-ssid mynetworkssid
wpa-key-mgmt WPA-PSK
wpa-psk "mynetworkkey"

auto ath0

iface eth0 inet static
address 192.168.2.1
netmask 255.255.255.0

auto eth0

eth0 is used to connect to the PS2, and forward traffic onto the wireless network (and also to connect any other machines that temporarily find themselves in my living room, if they don't have wireless). To make configuration of those easier, I installed dnsmasq.

ath0 is my wireless network card. Sometimes I have to
sudo /etc/init.d/networking restart
after a reboot to get it to connect to the wireless network. Not sure why that is (only seems to be a problem after I switched from WEP to WPA).

Anyway, now that we're on the network, edit /etc/apt/sources.list and uncomment all the repositories that were commented out. I prefer synaptic to adept, so
sudo apt-get install synaptic
Before you go any further, the adept update alerter is probably signalling new updates available, so run that and upgrade everything to the latest, and reboot into the new kernel.

The first such update is probably quite a big one, so fiddle with some cosmetic settings while it's going.

Install build-essential, devscripts, fakeroot, and anything else you like to have on your system (firefox, kget, etc). Install and run EasyUbuntu to get all the proprietary codecs, decss, latest nvidia drivers, fonts etc). Let it add the new repositories to your sources.list. Make sure nvidia-glx is installed.

Install more useful stuff for a mediapc, such as acidrip, mplayer, mencoder, dvdauthor, ffmpeg, dvdrip, dvdslideshow...), remove some junk (feel free to remove kubuntu-desktop, it is only there to depend on everything else, so is done being useful after installation). See the attachment below for a list of packages I have installed on my system. (You probably don't want the anthy/scim/skim stuff, but I'm slowly trying to learn Japanese too.)

Install apache2 for mythweb.

Enable autologin from System Settings/System Administration/Login Manager.

Configure video output

The idea here is to have X configured to use 2 screens. One (localhost:0.0) is the normal monitor, on which you can do normal computery things, the other (localhost:0.1) is displayed on the TV, and will mostly be running mythfrontend or xine fullscreen. See the attachment below for my configured /etc/X11/xorg.conf. Log out and back in to restart X and have it use both screens.

IVTV

ivtv is the driver for the WinPVR 250 card (and others). I use 0.4.6 (since the Dapper kernel is 2.6.15, and newer versions require 2.6.16 or later).
Download the source from ivtvdriver.org, and install it with the following commands:
# Decompress the source
cd
tar xfvz ivtv*

# Move the old versions of some modules out of the way (but keep a backup in case)
mkdir /tmp/ivtvmodules_backup
sudo mv /lib/modules/$(uname -r)/kernel/drivers/media/{tda9887,tuner,tveeprom}.ko /tmp/ivtvmodules_backup

cd ivtv-0.4.6
make
sudo make install
sudo update-modules
echo 'alias char-major-81 videodev' >/tmp/ivtv
echo 'alias char-major-81-0 ivtv' >>/tmp/ivtv
sudo mv /tmp/ivtv /etc/modutils/ivtv

Next we must install the firmware for the PVR card (see also the IVTV page on the subject):
mkdir /tmp/ivtvfirmware
cd /tmp/ivtvfirmware
wget ftp://ftp.hauppauge.com/Support/PVR150/Beta/amity24073.prerelease.zip
unzip amity24073.prerelease.zip
sudo cp HcwMakoC.ROM /lib/firmware/$(uname -r)/v4l-cx25840.fw
sudo cp HcwFalcn.rom /lib/firmware/$(uname -r)/v4l-cx2341x-enc.fw
wget ftp://ftp.shspvr.com/download/wintv-pvr_250-350/inf/pvr_1.18.21.22254_inf.zip
~/ivtv-0.4.6/utils/ivtvfwextract.pl pvr_1.18.21.22254_inf.zip
sudo rm /lib/modules/ivtv-fw-enc.bin
sudo mv /lib/modules/ivtv-fw-dec.bin /lib/firmware/$(uname -r)/v4l-cx2341x-dec.fw
sudo cp v4l-cx2341x-init-mpeg.bin /lib/modules
sudo cp v4l-cx2341x-init.mpg /lib/firmware/$(uname -r)

Note that on ubuntu, the firmware files are stored separately for each kernel version, so if you upgrade your kernel, you'll need to install the firmware as above again.

Now ivtv should be installed. We can test it with:
sudo modprobe ivtv
ls /dev/video0
# Should show /dev/video0. If you get an error about not
# being able to find a /dev/video0, then something's not
# installed right.

ivtvctl -p 5
cat /dev/video0 > test.mpg
# wait a few seconds, then stop it with ctrl-c

You should, with a bit of luck, be able to play test.mpg in xine or mplayer, and it should be a recording of some TV. If things don't work, and you decide to try a reboot, the PVR card doesn't seem to reset completely on a quick reboot, so leave the power off for about a minute rather than just rebooting.

LIRC

lirc is the infrared control component. There are two sides we need to set up for this: input (controlling apps from a remote) and output (changing the channel on the sky decoder).

I installed lirc from source, since the version included with ubuntu was a bit older, still, if you want an easy life, using the ubuntu ones might be easier, if they work for you.

Before we can build lirc, we need to install the linux kernel source, and build some files that the lirc build needs.
sudo apt-get install linux-source
cd /usr/src
sudo tar xfj linux-source-2.6.15.tar.bz2
sudo ln -s linux-source-2.6.15 linux
sudo cp /lib/modules/$(uname -r)/build/.config linux/
cd linux
sudo make oldconfig
sudo make include/linux/version.h
sudo make modules

Download the source from lirc.org.
tar xfv lirc-0.8.0.tar.bz2
cd lirc-0.8.0

# First build lirc for the hauppauge remote (input)
./configure --sysconfdir=/etc/lirc --with-driver=hauppauge
make
sudo make install

# Now build it again with the serial output driver
./configure --sysconfdir=/etc/lirc --with-driver=serial --with-transmitter
make
sudo make install

sudo update-modules

You'll need some lirc config files, and a script to change channels. You can find mine attached below.
Try it out with:

sudo modprobe lirc_dev
sudo modprobe lirc_i2c
sudo modprobe lirc_serial

# This should cause your sky box to change channel to 106 (Sky One)
changechan.sh 106

# This will display incoming IR events, press some buttons on the PVR250 remote
# Ctrl-C when you're done.
irw

 

XMLTV

XMLTV is the program that will fetch tv listings so that mythtv knows what's on. You'll need to get the downloadchannels and updatechannels scripts from this knoppmyth wiki page. I had to edit the updatechannels.pl file to add '-u root -p my_mysql_root_password' to the mysql lines. (Note that you should set a root password for your mysql install with
sudo mysqladmin -u root password
)
Run downloadchannels.pl, and edit the matched file (I deleted a bunch of channels I never watch, and added/fixed a couple of entries it didn't quite manage to set up right - notably it seems to get confused with +1 channels). Now you can make a .xmltv file with
sed 's/[0-9]*,[^,]*,/channel /' matched >matched.xmltv
You'll need this matched.xmltv file later, once mythtv is installed.

Building MythTV

Ubuntu has packages for MythTV 0.18.1, but that's old, so I built my own packages for MythTV 0.19 (which turned out not to work so well, so I applied some fixes from their 0.19.1 branch - so this will build 0.19 and a little bit). MythTV 0.18.1 is still pretty nice (I used it for a while with ubuntu breezy), so if you want to use the packages instead, you should still be able to get a working system. Make sure you install mysql-server-4.1 and not 5 if you do so though, or the scheduler doesn't stay connected to the database, and doesn't record your programmes.

First, make sure you have everything required to build mythtv:
sudo apt-get build-dep mythtv
mkdir ~/mythrebuild
cd ~/mythrebuild
apt-get source mythtv

If you now do debuild -us -uc, you should be able to rebuild the mythtv packages as shipped with ubuntu. (I recommend doing this, so you can iron out any environment problems before trying to build the newer mythtv.)

Here's what I did to update the 0.18.1 packages to 0.19. You can either follow these steps, or download my patches below, apply them and skip straight to the dpkg-buildpackage step (I'd provide the whole deb files, but I don't have a lot of bandwidth on this poor little server).

Download the MythTV 0.19 source to ~/mythrebuild
cd ~/mythrebuild/mythtv-0.18.1
uupdate -u mythtv-0.19.tar.bz2

# now delete any .orig and .rej files, the patches that fail to apply between
# these versions aren't important.

cd ../mythtv-0.19
# apply critical patches from the 0.19.1 branch
patch -Np1 -i ~/mythtv-0.19-fixes.patch

dpkg-buildpackage -rfakeroot

Note that some of the files aren't built anymore, so you might get errors. Also, some new files are built now, so they should be added. Attached below are my updated files from the debian/ directory in the form of a patch that you can apply to the mythtv source.

Now you can install the rebuilt mythtv packages with sudo dpkg -i mythtv-common_0.19-1_all.deb libmyth_0.19-1_i386.deb libmyth-dev_0.19-1_i386.deb mythtv-backend_0.19-1_i386.deb mythtv-database_0.19-1_all.deb mythtv-doc_0.19-1_all.deb mythtv-debug_0.19-1_i386.deb

If that's all working, we can rebuild the plugins in a similar way:
sudo apt-get build-dep mythtv-plugins
apt-get source mythtv-plugins
#download the new source
cd mythtv-plugins-0.18.1
uupdate -u mythtv-plugins-0.19.tar.bz2
# ignore .rejs again (delete the files)
# edit debian/rules and add --enable-transcode to the ./configure line,
# so that mtd isn't useless like it is in the default ubuntu packages
# edit the debian/control file and change the dependencies to >=0.19-1, rather than 0.18
debuild -us -uc
sudo dpkg -i mythbrowser_0.19-1_i386.deb mythphone_0.19-1_i386.deb mythdvd_0.19-1_i386.deb mythgallery_0.19-1_i386.deb mythvideo_0.19-1_i386.deb mythgame_0.19-1_i386.deb mythweather_0.19-1_i386.deb mythmusic_0.19-1_i386.deb mythweb_0.19-1_all.deb mythnews_0.19-1_i386.deb

If you're still here, we're nearly done. Everything's installed, and now just needs to be configured.

Configuring MythTV

Run mythtv-setup, and set:

General

Directory to hold recordings = /video/mythtv
TV format = PAL-I
Channel frequency table = europe-west

Capture cards

Card type = MPEG-2 encoder card
Video device = /dev/video0
Default input = Composite 4

Video sources

Video source name = sky
XMLTV listings grabber = United Kingdom (alternative)

Input connections

MPEG:/dev/video0 Composite4 = sky
Copy that matched.xmltv file from the XMLTV section into ~/.mythtv/sky.xmltv
Now you can run /etc/cron.daily/mythtv-backend to grab some listings (might take a while, especially the first time).
Run mythfrontend, and go to the Utils/Setup/General. Uncheck "Use internal volume control" (since I have an amp that can do all the volume stuff). Under TV Settings/Recording profiles, ensure that everything is set to 720x576. Not doing this causes pauses every couple of seconds when watching TV.
Change the player for video files to "xine -pfhq" (I find it looks nicer doing the deinterlacing than the default mplayer).

Copy the lircrc file attached below to ~/.mythtv.

For mythweb, you'll need some apache configuration:
echo '' >/tmp/mythweb
echo ' AllowOverride All' >>/tmp/mythweb
echo '
' >>/tmp/mythweb
sudo mv /tmp/mythweb /etc/apache2/conf.d/
sudo ln -s ../mods-available/rewrite /etc/apache2/mods-enabled
sudo chown -R www-data /var/www/mythweb/data

Edit /var/www/.htaccess to match the database password (found in mythfrontend under Utils/Setup/General)

Now go relax in front of the TV. You've earned it.

Attachments

Note: The patches for mythtv deb building referred to above aren't here yet because I need to correct some versioning info and rebuild, since they shouldn't claim to be official ubuntu packages.

AttachmentSize
installedpackages.txt162.95 KB
/etc/X11/xorg.conf4.49 KB
/etc/hardware.conf557 bytes
/etc/lirc/lircd.conf9.37 KB
changechan.sh276 bytes
~/.mythtv/lircrc4.83 KB
Posted in