MythTV on a Pundit-R
Introduction
In December 2004 I put together a Myth TV box using a Pundit-R barebone system. This page shows how I did it... Hopefully, it might help someone who's putting together a similar system.
Note that this guide is still pretty relevant if you want to setup a system using Debian Unstable. However, I've done an updated guide based on Ubuntu if you'd like to do it the easy way...
The resulting system surpassed all my expectations. It's not just a PVR, but a complete multi-media centre. Here's a list of what I use it for:
Myth HTPC Features
- Displays digital freeview programs on my TV
- Outputs digital sound to my amplifier
- Pauses live TV
- Shows a 7 day programme guide
- Records any selected programmes from the guide
- Records all episodes in a series
- Can archive any recorded programmes to DVD
- Allows me to login over the internet and setup my recording schedule
- Allows me to login over WAP using my mobile and schedule recordings from (nearly) anywhere in the world
- Holds my entire collection of MP3s and plays them through my stereo
- Runs peer-to-peer software
- Plays downloaded MPEGS/AVIs direct to my TV
- Stores and displays my digital photos on the TV
- Connects to my main PC over a wireless link
- Allows me to run my main PC as a frontend to watch TV
- Half-life 2 dedicated server
Hardware Specification
- PC Barebone system: Asus Pundit-R (black)
- Processor: Intel Celeron D 335 2.80GHz, chosen to keep the power consumption low
- Hard Drive: Maxtor DiamondMax Plus9 SATA 160GB
- Memory: Kingston ValueRAM 184DIMM PC3200 512MB
- DVD-RW: Lite-On SOHW-1653S
- Hauppauge WinTV Nova-T DVB card (UK)
- Wireless keyboard and mouse
- Edimax 802.11g 54Mbps PCI wireless NIC
- One-for-all Kameleon 6 Universal Remote Control
Asus Pundit-R
Pundit Features
I chose the Pundit-R because it's a sexy piece of kit and perfect for a Myth TV box. I wanted a combined front/backend system in my living room which could be left on all of the time. The Pundit is small, quiet, looks great and doesn't consume too much power. It also has TV-out and digital audio build into the motherboard, which is perfect.
- Intel Socket 478 Celeron or Pentium 4 Northwood/Prescott, 3.2GHz+
- Low power consumption (200W)
- S-video TV-out
- S/PDIF digital out
- USB 2.0
- Firewire
- PCMCIA
- SD card reader
- Ethernet
- Silver or black
- Cool blue LED strip across front panel
- Variable speed fan
- ATI Radeon 9100 graphics
- 6 channel audio
- 2 PCI slots
- 1 HDD bay and 1 CD/DVD drive bay
Pundit Problems
After living with the Pundit for a while, the main problem with it is that it's too loud. It's quieter than most desktop PCs, but is still louder than I'd like for a living room. The alternative would be a passively cooled system such as an EPIA, but the extra power is probably worth it.
The other flaws of the Pundit chassis are well documented on the Web:
- The SPDIF digital output is on the front panel. This is crap and a real design flaw.
- The PCI card bay is too small. The Nova-T card only fits in the bottom slot, and that's if you force it. A friend of mine had to file his card to fit it in!
- The supplied SATA cable is too short. I had real trouble fitting my Maxtor hard drive.
- The Linux support for the hardware isn't as good as for the old Pundit. The ATI graphics card support isn't great (but getting better all the time).
As mentioned above, fitting the components is a tight squeeze and nowhere near as easy as in a full-size chassis. Still, once it's done you have a neat little system. I just can't help feeling that all of the problems could have so easily been fixed by ASUS...
Linux Installation
Debian Unstable
I chose the Debian Unstable (Sid) distribution as the base operating system because it's up-to-date and has the power of APT. APT allows you to install the latest version of any package, including all dependencies, with a simple command.
The only downside of Sid is that there's no way to install it straight from CD. I had to install the "testing" distribution (Sarge) and upgrade from there. However, once it's done, it's the easiest distribution to keep on the bleeding edge.
Kernel Compilation
I had previously got MythTV working on a 2.4 system, so I was shocked at how easy it was with a 2.6 kernel. However, the first thing I did was compile my own kernel from the Debian sources. With a system like this, you're probably going to need to compile some kernel modules (wireless drivers, etc.), and it's much easier to do if you compile against the source of the running kernel.
If I were doing it again, I'd seriously consider using the Ubuntu distribution. Despite a strange obsession with putting pictures of naked blokes on their website, it's actually a great way to install a fairly recent snapshot of Debian unstable :-)
DVB
DVB Kernel Drivers
The DVB drivers are all included in the kernel, so all I had to do was install the binary firmware for my Nova-T card. I had this on a Windows system which I'd installed the Hauppauge drivers onto. However, I guess it'll be available on the driver CD or even the web.
cp /home/garry/mythtv/tda1004x.bin /usr/lib/hotplug/firmware/tda1004x modprobe tda1004x
DVB Testing
The DVB hardware can be tested by using utilities from the dvb-utils package. Use scan to generate the channel list and tzap to tune the card into the correct frequency.
apt-get update apt-get install dvb-utils dvbstream scan /usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-WinterHill > /root/.tzap/channels.conf tzap "BBC ONE"
Once the channel is tuned, you can test the card by piping the output of the dvbstream utility through mplayer. The following example is for BBC 1.
dvbstream -o -ps -qam 16 -cr 3_4 512 650 | mplayer -
Database Installation
My SQL
My SQL must be installed for Myth to work. You'll probably find that it's already there if you're running any flavour of Debian. However, I also found that I needed some QT MySQLlibraries installing also:
apt-get install qte3-mt-mysql libqt3c102-mysql libqt3c102-mt-mysql
Myth TV
Debian Packages
Myth TV is a suite of software providing Personal Video Recorder functionality, and much more besides. It's the inspiration behind this whole project and a great piece of software. It's still in beta, currently version 0.18, but extremely feature packed and getting better all the time.
I initially installed 0.16, but version 0.17 included vastly improved DVB support, which was exactly what I needed! I previously had to populate all channel and schedule data using third party scripts and utilities, but now it's all included as standard. For this reason, I'll only cover version 0.17+ from now on.
I have installed all Myth components from the Debian packages put together by Mr Matt Zimmerman (thank you so much, mate). To access them , add the following line to your /etc/apt/sources.list:
deb http://dijkstra.csh.rit.edu/~mdz/debian unstable mythtv
MythTV is then installed using the following command:
apt-get install mythtv
MythTV DVB Setup
DVB Channel Data
Once it's installed, the first thing to do is run the setup utility.
mythtv-setup - configure card - video source=dvb - scan for channels
Fixing Channel Data
Update: I've come up with a better way of doing this - see this HOWTO.
As good as the new DVB updates are, they don't automatically populate the xmltv IDs in the channel table. These keys link the entries in the DVB programme guide with each channel and and must be added to the table manually. The xmltv ID which you use depends on where you'll be getting the schedule data from. Here in the UK, there are two main methods for freeview - getting the data from the DVB signal or from the Radio Times website (see below).
Once you've decided what schedule to use, you need to update the xmltv IDs in the channel table to match the channel IDs in the guide. I've got a simple script, updatedvb, which reads a config file, xmltv.dat (thanks to Lee for keeping this up-to-date), and configures either radio times or DVB data. The config file contains the channel name, radio times ID, freeview ID and icon path. It can be run with -r for radio times or -d for DVB. I've done it like this to allow me to switch between the two types if I ever need to. You'll need to apt-get gawk if you don't have it installed...
Icons are available from here.
Radio Times Schedule
The Radio Times schedule has improved recently, as they've kindly released the listings in XML format, removing the need to scrape their website. This is great news, as the actual listing data is far superior to the freeview EPG, with 14 days instead of 7 and much more detailed information. Most of the programmes are colour coded correctly and the movie listings in MythWeb work perfectly.
- Get a list of xmltv available IDs tv_grab_uk_rt --list-channels - Update your xmltv config with the channels you want to grab /root/.xmltv/vim tv_grab_uk_rt.conf - edit xmltv.dat and add the channel/xmltv mappings for your area - Run the script to update the channel table updatedvb -r - Check that the table has been updated correctly echo "select chanid,channum,callsign,xmltvid from channel" | mysql -D mythconverg - Update the listings by running the following every day using cron tv_grab_uk_rt > /tmp/rt.xml mythfilldatabase --quiet --no-delete --file 1 0 /tmp/rt.xml
Freeview EPG
The Freeview EPG is a pretty convenient 7 day guide, and is great if you don't have an internet connection on your box, but I'd highly recommend using the Radio Times feed if you can.
- edit xmltv.conf and add the channel mappings for your area - Run the script to update the channel table updatedvb -d - Check that the table has been updated correctly echo "select chanid,channum,callsign,xmltvid from channel" | mysql -D mythconverg - Update the listings by running the following every day using cron tv_grab_dvb -t60 > /tmp/rt.xml mythfilldatabase --no-delete --file 1 0 /tmp/rt.xml
My old script for just updating the freeview channel IDs is still available from here: xmltv.sql. run with "mysql -p < xmltv.sql"
Graphics Card
ATI 9100 TV-Out
Getting the ATI TV-out working was kind of fun(?!). The fglrx driver is a close source proprietary driver produced by ATI. The main problem with it is that there's a major bug in the driver which stops the TV-out from working on a 9100 card. All you get is grey/white lines on your TV. Fortunately, there's a very clever and simple hack which fixes it by editing the binary! The instructions below are for the 3.12.0 version, but a similar technique works on the newer 3.12.10 version - see this thread. As far as I know, the bug still isn't fixed on later version of the ATI driver, despite numerous complaints. Anyway, here's how to hack the binary...
- Download the package from the ATI site - Convert the RPM to a .deb and install it alien fglrx-4.3.0-3.12.0.i386.rpm dpkg --force-overwrite -i fglrx_4.3.0-4.12_i386.deb - Build the kernel module cd /lib/modules/fglrx/build_mod bash make.sh - Edit the driver with your favorite hex editor(!) hexedit /usr/X11R6/lib/modules/drivers/fglrx_drv.o At locations 13B2F and 13BE4, replace the value 2C with 19 Many thanks to anonbeat: http://www.rage3d.com/board/showthread.php?mode=hybrid&t=33781391 - Insert the module insmod /lib/modules/2.6.9-gaz/kernel/drivers/char/drm/fglrx.ko
Display Setup
The only display connected to my MythBox is a TV, so there's no dual-head complications. The Pundit is setup to output PAL in the BIOS and the X screen resolution is 1024x768. This gives a pretty usable X display even on the TV. Myth outputs a anamorphic widescreen 4:3 picture and the Panasonic TV is set to "just" mode so that it stretches it to 16:9. The picture in Myth looks great, although there's a slight colour shadow on bright faces. This may be down to the S-Video to SCART cable I'm using. I might buy another just incase. Here's my XF86Config-4.
Playback Settings
There are loads of settings to play with in the Myth setup screens. However, the big one is to enable "Deinterlace" during Playback. Moving images look awful otherwise...
Remote Control
Hauppague Grey Remote
The Nova-T now comes with a little silver remote-control, referred to by forums as the "grey" version as opposed to the old black one. It's a bit cheap feeling, but does the job. The button presses are interpreted by the evdev module, fed through the LIRC daemon and into Myth.
Event Device Support
The remote uses the event device kernel module.
- Insert the module if necessary: modprobe evdev - Check if the kernel can now see the device: cat /proc/bus/input/devices I: Bus=0000 Vendor=0000 Product=0000 Version=0000 N: Name="Budget-CI dvb ir receiver saa7146 (0)" P: Phys= H: Handlers=kbd event2 B: EV=3 B: KEY=1b0c4004 31 0 0 0 0 18000 4180 4000801 9e1680 0 14000 50000ffc - This shows that the remote is on device /dev/input/event2 - Test it by catting the device and typing some buttons: cat /dev/input/event2 - The evtest utility can also be used: evtest /dev/input/event2
LIRC
LIRC is a daemon which reads from the event device and passes it on to Myth, MPlayer, etc. When I build my box, the Debian package did not have event support compiled in. This may no longer be the case. However, here's what I needed to do:
- Download version lirc-0.7.0.pre8
./configure
change from "driver:serial io:0x3f8 irq:4" to "Other -> Linux input layer (/dev/input/eventX)"
(i.e. do NOT choose {TV card -> Hauppauge TV card!!!)
make
make install
- create startup script & link:
ln -s ../init.d/lirc S19lirc
- The daemon must be run with the correct event device:
/usr/local/sbin/lircd --device="/dev/input/event1" /etc/lirc/lirc.conf -n
- LIRC can be tested using the irw utility
irw
As well as all that, both the /etc/lircd.conf and ~mythtv/.mythtv/lircrc files must be correct for the remote. The files linked work for me, but apparently the Hauppauge remotes can vary quite a bit...
MythWeb
The MythWeb interface allows many aspects of Myth, most importantly the scheduling, to be controlled from any we browser. The interface is great and much quicker to use than the TV interface, mainly due to the higher resolution. Follow the instructions in /usr/share/doc/mythweb/README.gz to st it up. The main step is changing the permissions of the following directories so that apache can write to them:
apt-get install mythweb
cd /var/www/mythweb
/var/www/mythweb# chgrp -R www-data /var/www/mythweb/{image_cache,php_sessions}
/var/www/mythweb# chmod g+rw /var/www/mythweb/{image_cache,php_sessions}
MythWeb over WAP
It's possible to login to Mythweb using a WAP-enabled mobile phone. I've got a fairly old Nokia phone which can only handle WML. However, I can still login from anywhere in the world and schedule recordings - very handy if you're in the pub and remember that the X-factor is on (only joking)! One important point to remember if you've got this type of phone is that you can't browse to the URL "http://yourbox/mythweb/", as this is a HTML page and a WML phone will reject it. You need to use "http://yourbox/mythweb/program_listing.php".
Wireless Network
Edimax Wireless-g PCI Network Card
This has been by far the most difficult aspect of the whole project to get working. The card uses a Ritek RT2500 chipset, the driver for which was originally released under a "look but don't touch" license. It was also crap. It caused major problems with my kernel; my poor Pundit wouldn't stay up for more than a few minutes. Most of the hacks put forward by people didn't work for me. I eventually got it fairly stable, but it still caused the odd kernel freeze. Not good at all...
I then tried the ndiswrapper driver. This is a kernel module which implements the Windows NDIS API and uses the actual Windows driver for your card. It's intended for completely closed source drivers. It worked pretty well for me, but I still had a few problems - the network would drop after a few days. Manually restarting the interface would usually bring it back, but sometimes it would lock the kernel.
Finally, the RT2500 driver was released under an open source license, and the guys at rt2x00 worked frantically to bring it up to scratch. I'm pleased to report that the latest CVS version has been running on my system for a few weeks without a hitch. Thanks, guys! Here's how to install it...
- First of all, install the wireless tools package
apt-get install wireless-tools
- Get the driver from CVS. You need a network connection for this, so it's kinda chicken and egg!
mkdir /usr/src/rt2500
cd /usr/src/rt2500
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/rt2400 login
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/rt2400 co source
cd source/rt2500/Module
make
- Install the new module
cp rt2500.ko /lib/modules/$(uname -r)/misc/rt2500.ko
- Stick an entry into /etc/modules
echo rt2500 >> /etc/modules
- Rebuild module dependencies and insert the kernel module
depmod -a
modprobe rt2500
- Check if the access point is found
iwconfig
- If not, try scanning for it.
iwlist ra0 scan
- Add the interface to the /etc/network/interfaces file
auto ra0
iface ra0 inet dhcp
hostname loki
- Bring up the interface
ifup ra0
Wireless Channel Problems
I've got a Netgear wireless ADSL router, which defaults to channel 11 for the UK. I had problems with the WLAN connection dropping after about 2-3 minutes when I was using the ndiswrapper driver. Changing to channel 1 on the router seemed to fix it.
Sound
S/PDIF Digital Out
The Pundit-R has S/PDIF digital output on the front panel. This is a real pain and if you're going to use this port, then you either have to a) hide your pundit behind a chair, b) keep the front panel open all the time or c) drill a hole through the panel and poke your cable through it! I'm going with option 'a' for now, which also helps the Pundit's 2nd major fault - the noisy fan, which is too loud even with the "quiet fan" BIOS option enabled.
As my system was built from a Sarge package list, the OSS audio drivers were being used by default. This caused "Prebuffering pauses" which caused pauses in MythTV playback. The solution was switching to the new ALSA sound drivers. These are the replacement for OSS.
apt-get install alsa-base alsa-oss alsa-utils alsamixergui alsaconf
Once alsa is installed, you can tell Myth to use it (and the S/PDIF output) in the setup by changing the source device to:
ALSA:spdif - and also MythMusic to use /dev/adsp
Note, however, that I couldn't get the mixer to work when using S/PDIF. I'm not sure why this is. For now, all I need to do is control the volume from my amplifier. A programmable remote would be the ideal solution...
Database Backup
Don't forget to backup your Myth MySQL database once you've got everything working:
mysqldump -c -a -p mythconverg > /home/mythtv/dbdump/mythconverg_0.18.dmp
Other Myth Packages
There's much more to Myth that being a great PVR. You can install and play around with the following packages:
- mythmusic - plays your MP3s
- mythagllery - displays your digital photos
- mythnews - news scraped from the web
- mythvideo - play video files
- mythweather - weather in your area
- mythbrowser - browse the web from your armchair
Playing Movies and DVDs
MPlayer and Xine
There are two main linux movie players, MPlayer and Xine. I use MPlayer, but Xine works fine, too. I actually still use my trusty old DVD player fopr playing DVDs, as the picture is better, but this is probably just to do with the cables I'm using.
I use MPlayer for playing avi and mpg files downloaded from the internet or recorded with my digital camera. This is useful for situations where you accidentally delete an episode of Alias that you've recorded (D'Oh)! It took me a while to get mplayer to work without jumping. I also had to have the ALSA libraries available when compiling it:
apt-get install libpng3 libpng2-dev libgtk1.2-dev libasound2-dev ./configure --enable-xv make make install
Here's the command line which I use to get everything working:
mplayer -cache 10000 -autosync 35 -monitoraspect 16:9 -fs -vo xv -ao alsa:mmap:device=hw#0.1
Archiving Recorded Programmes to DVD
This currently can't be done from the standard MythTV menus, but it's pretty easy with a couple of scripts. I don't bother with DVD menus as they're a pain to generate automatically and look crap if you don't spend enough time on them. My scripts simply accept a list of .nuv files and burn them as a number of chapters to a blank DVD.
Note that the following works for stuff recorded with my Nova-T card, what else it will work for is not for me to say. It also use replex, which I had to compile from source.
MythLink
The first thing to do is get a list of recorded programmes. To do this, just run the mythlink script to generate symbolic links to all of your .nuv files. This was written by Dale Gass and looks in the mythconverg.recorded table to get the list of files. The version linked from this site has been slightly hacked by me to generate slightly better filenames and put them in a /home/mythtv/tv directory.
Writing to DVD
I've written a script called nuv2dvd which accepts a list of nuv files, replexes them to .mpg files, dvdauthors them into a DVD structure and uses growisofs to write them to DVD.
$ cd ~mythtv/tv $ mythlink Done RM Creating 05252159_Desperate_Housewives_Sunday_in_the_Park_with_George.nuv Creating 05240019_Alias_Hourglass.nuv Creating 02241759_The_Simpsons.nuv Creating 03090005_The_Texas_Chainsaw_Massacre.nuv Creating 02280004_South_Park.nuv Creating 03061759_The_Simpsons.nuv $ nuv2dvd 05240019_Alias_Hourglass.nuv 02241759_The_Simpsons.nuv
Writing to an ISO
I've also got a script called nuv2iso, which writes the files to an .iso for burning later. This does the same as nuv2dvd, but uses mkisofs to create the .iso file
Other Recommended Packages
aMule
aMule is the open source version of eMule and it works really well. The GTK2 user interface looks good and the speed of the downloads, especially when connected to the razorback2 server and copying a popular file, is stunning.
References and General Myth Links
- MythTV - Official site
- Myth TV on a Pundit-R - This site ;-)
- MythTV DVB Setup Guide - Invaluable resource for users in the UK, thanks to Martin Smith.
- Fedora Myth(TV)ology - By Jarod C. Wilson
- Pundit MythTV Frontend - By Matt Marsh
- Myth BOX - A UK site specialising on EPIA-based systems
The End
So, that's it. I hope that the information on this page has been helpful to somebody out there. If you have any questions, amendments, etc. please feel free to drop an email to Garry Parker. Cheers.