How to set up MythTV on Ubuntu Linux using a DVB-T capture card
This guide is written for a Hauppauge Nova-T PCI DVB television card, but may be useful for other TV capture hardware. To follow these instructions you will need a fast Internet connection, unless you want to wait for hours while downloading installation packages. MythTV also works best on newer hardware (even though using up old components may be cheaper and more convenient).
I used the following guides extensively in writing this article:
Compiling a kernel with DVB drivers
Burn a DVD with the Ubuntu Hoary Hedgehog release for i386.
Reboot and run the installer using the 'server' option at the prompt.
Disk partitioning
The hoary hedgehog installer, unlike the warty warthog installer, can safely resize an NTFS partition, so any existing Windows installation can be left intact - This page may be helpful if you plan to resize an NTFS partition. Older Windows filesystems can also be resized. (The first time you boot into Windows after repartitioning, your file system may be checked for consistency.)
If you have more than one hard disk, you can set mount points for individual partitions using the manual partitioning feature of the installer. I have /myth set as the mount point for a large partition, so that recordings can be stored there. Both partitions are formatted with the ext3 filesystem. Note that you may need to set permissions manually for the mount point.
Follow the instructions of the installer, reboot and remove the installation DVD.
The rest of this guide will tell you how to
-
download and configure the kernel source so that you can compile a new kernel with the DVB-T drivers and any extra features you may require;
-
install the DVB device;
-
install MythTV from an APT repository;
-
set up the MythTV database;
-
configure MythTV and tune channels;
-
set up the Samba server to share recordings on a Microsoft Windows network with password protection;
-
set up Apache 2 and MythWeb, and install channel icons;
-
finish the configuration.
Once you have rebooted, enter your username and password.
You will need a fast Internet connection to perform the following steps.
Updating Ubuntu and downloading the kernel source and headers
Update Ubuntu:
sudo apt-get updateEnter your password at the prompt
sudo nano /etc/apt/sources.listUncomment the four lines ending 'universe' by removing their preceding '# '. Type the four lines below so that they are repeated, replacing 'universe' with 'multiverse'. This adds the universe and multiverse repositories.
Press Control-O, Enter, Control-X.
sudo apt-get update
sudo apt-get install xserver-xorg twm x-window-system-core buld-essential libncurses5-dev kernel-package
Type startx to check that the window manager has installed correctly. When you see an X cursor in the centre of the screen, click and hold down the left mouse button. Move to 'Exit' and choose 'Yes'.
The next step is to get the kernel source and configure it.
cd /usr/src
sudo wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.13.tar.bz2
sudo tar -jxvf linux-2.6.13.tar.bz2
sudo ln -s linux-2.6.13 linux
cd linux
sudo cp /boot/config-2.6.10-5-686 .config
make menuconfig
Scroll down the list using the arrow keys until you reach the option to load a configuration. Select this to load the .config file you just copied.
The features listed here can be added to the kernel in two ways: compiled into the kernel or added as modules. It is important to select the IDE and filesystem features to be compiled into the kernel.
Navigate the menus using the arrow keys, pressing the m key to install the feature as a module, y to include the feature in the kernel and n to exclude it. The escape key moves back to the upper level. When you press the escape key at the main menu you will be prompted whether to save the settings.
You will need the drivers for your IDE controller built into the kernel. Go to Device Drivers | ATA/ATAPI/MFM/RLL support and select the first two options (press Y). Select Include IDE/ATA-2 DISK support, IDE/ATAPI CDROM support, floppy support, generic/default IDE chipset support and Generic PCI IDE Chipset Support. The next step is to find out what IDE controller is being used. Switch to another console by pressing Alt+F2, login again and type dmesg | grep IDE. You should see some lines of output; press Alt+F1 to return to the first console and select the IDE chipset that was output (press Y at the closest matching item in the menu).
Go to File systems and press Y next to your chosen filesystems. (I chose Ext2 and
Ext3.)
If you have a hyperthreading or dual-core processor, select Processor type and features | Symmetric multi-processing support and press Y. For hyperthreading do the same with SMT (Hyperthreading) scheduler support.
If you wish, carefully disable any features that you definitely don't need probably PCMCIA and ISDN for example.
For the DVB drivers, go to Device Drivers | Multimedia devices and press M (not Y) next to Video For Linux, in Video For Linux next to DVB Support for cx2388x based TV cards and in Digital Video Broadcasting Devices next to DVB Core Support and in DVB Frontends next to the Conexant devices.
sudo make-kpkg --append-to-version=.ck001 kernel_imageThis will probably take a very long time. When compilation is finished:
cd ..
sudo dpkg -i ../kernel-image[press TAB]Before you reboot, you need to configure udev so that it creates DVB devices.
sudo nano /etc/udev/udev.rulesEnter the following into the file:
# DVB Support
KERNEL="dvb*", PROGRAM="/etc/udev/dvb.sh %k", GROUP="video", name="%c"We need to create the dvb.sh script.
sudo nano -w /etc/udev/dvb.shEnter the following into the file:
#!/bin/sh
/bin/echo $1 | /bin/sed -e 's,dvb\([0-9]\)\.\([^0-9]*\)\([0-9]\),dvb/adapter\1/\2\3,'Now make the script executable
sudo chmod a+x /etc/udev/dvb.shThen reboot:
sudo shutdown now -r
When your system boots, login and type lsmod -l | grep dvb to list the modules in your system which use dvb. (Note: You may need to modify your modules aliases to from the blackbird driver to the cx88_dvb driver.)
Setting up MythTV
sudo nano /etc/apt/sources.listAdd the following line:
deb http://dijkstra.csh.rit.edu/~mdz/ubuntu hoary mythtvThen update your apt repositories:
sudo apt-get updateNow to install the MythTV packages. Select 'y' when prompted to install packages without verification.
sudo apt-get install mythtv mythtv-backend mythtv-frontend mythtv-common mythtv-databaseWhen prompted for the MySQL password type a password of your choice. When apt has finished, press the up arrow and press enter to run the same command again - this will finish the installation of the packages.
mysql -u root
update mysql.user set Password=PASSWORD('put password here') where User='root';
flush privileges;The database now has a root password.
If you intend to have a remote frontend access the database on this machine, you will need to grant access to remote clients. Type the following in the MySQL client to grant access to other computers on the same subnet:
grant all on mythconverg.* to mythtv@"192.168.1.%" identified by "mythtv";
flush privileges;
You may have to replace 192.168.1.% by your own subnet. (The percent sign acts is a wildcard character.) You will also need to remove the skip-networking command in the configuration file (my.conf) for your MySQL server, and run mythtv-setup to change the host IP to the IP address or hostname of this computer rather than localhost (127.0.0.1).
It is also a good idea to set a password on the mythtv user account.
sudo passwd mythtvType a password for the mythtv user.
sudo apt-get install xterm xmltv-util
logout
Now login as the mythtv user and type startx. Run the xterm by clicking and holding the left mouse button on the desktop, going to Debian | X Shells | xterm. Type mythtv-setup.
Follow the instructions.
In general make sure you select the correct TV format (PAL in the UK) and the correct frequency table (probably not necessary for DVB).
In the capture card page, select Digital Video Broadcast card (DVB).
Create a new video source (e.g. called 'Main') and select the correct listings grabber. I'm using tv_grab_uk_rt.
The progress bar will move to 50% and stop. Click and drag the title bar to reveal the console window. You will need to enter the channels for your setup. The UK Freeview channels for the UK south-east are:
BBC1 South East
BBC2 South East
ITV1 Meridian
Channel 4
Five
ITV2
ITV3
BBC3
BBC4
Sky travel
UKTV History
E4
E4 +1
BBC News 24
Sky News
BBC Parliament
CBBC
CBeebies
ITV News
ABC1
QVC
MTV Hits
UKTV Bright Ideas
FtnSet up an input connection between DVB : 0 and Main.
On the channel configuration page, select Advanced and select (New Transport). The settings here need to be filled in for your transmitter. You can find these settings by following the instructions here, in the section about tzap. Note that for the UK Heathfield transmitter, there was no search script for the channels - I had to use PontopPike. Here are the settings for this transmitter:
Standard: DVB
Frequency: 578000000
Bandwidth: 8 Mhz
Inversion: Auto
Constellation: QAM 16
LP Coderate: 3/4
HP Coderate: 3/4
Trans. Mode: 2K
Guard Interval: 1/32
Hierarchy: NoneGo back to the channels page and select to scan for channels. Enter the same settings again.
You should see a list of channels which have been added to the database. The easiest way to modify this least is probably through the mythweb page once it has been set up, so leave this for now.
Press escape to exit the setup program. You will be asked to run /etc/cron.daily/mythtv-backend as root, so press Control+Alt+F3 to change to a text console. Login as your main user and type the following, to start the backend and configure the database:
sudo /etc/init.d/mythtv-backend force-reload
sudo /etc/cron.daily/mythtv-backendTV data will be downloaded from the Radio Times website and added to the database.
If you get an error saying that the request timed out, diagnose the problem by looking at /var/log/mythtv/mythbackend.log. (One possible problem is that the mythtv user doesn't have write access to the recordings location - rectify this by using sudo chmod o+w /myth where /myth is your recordings directory, specified in the mythtv-setup program.)
You can test whether television is working by going back to X (switch back to the X terminal by pressing Alt+F7 if it is already running, or login again as mythtv and run startx) and running mythfrontend in a terminal. Plug your 'speakers or headphones into the Line-out port on your sound device.
You may find information on keyboard shortcuts in Live TV from the MythTV howto useful.
Setting up Samba
These steps tell you how to set up the samba server so that you can access your recordings form a Windows PC on the network.
sudo apt-get install samba smbfs
sudo smbpasswd -a mythtv
sudo nano /etc/samba/smb
Put the following line in the new file: mythtv = "mythtv". This sets the Samba mythtv user to be equivalent to the system mythtv user.
Now to set up Samba to share the /mythtv directory (or your equivalent recordings directory, e.g. /var/lib/mythtv/).
sudo nano /etc/samba/smb.conf
Change the line "workgroup = MSHOME" to the correct workgroup. Find the line ; security = user. Uncomment this line by removing the '; '. Add the line 'username map = /etc/samba/smbusers' below this. You may wish to comment out (prefix the lines with '; ') the shares which are configured by default. Add the following at the end of the file.
[recordings]
comment = MythTV Recordings
path = /myth
public = yes
writable = no
create mask = 0777
directory mask = 0777
force user = nobody
force group = nogroupSave (Control+o) and exit (Control+X) to the console.
sudo testparmPress enter. You should see an entry for the MythTV recordings. Now restart the samba server.
sudo /etc/init.d/samba restart
You should now be able to open the shared folder on a Windows PC on your network: open an explorer window and go to \\hostname\recordings (replacing the hostname with the name of your MythTV computer, chosen at installation, and the name of the share). You should be prompted for a username and password enter the ones you chose at the start of this section.
Setting up channel icons
This section will probably only work for the Freeview channels in the UK. Download the channel icons:
cd ~
wget http://www.cs.man.ac.uk/~brejc8/dvb/icons.tar.gz
wget http://brej.org/dvb/uk_rt.sql
sudo cp icons.tar.gz /usr/share/mythtv/
cd /usr/share/mythtv
sudo tar -zxvf icons.tar.gz
rm icons.tar.gz
cd ~
nano uk_rt.sql
The three lines after the first need to be modified for regional channels. e.g. change north-west.bbc1.bbc.co.uk to digital.south-east.bbc1.bbc.co.uk. To find out which channel identifiers you are using, exit nano (Control+X) and type nano /home/.mythtv/Main.xmltv (replacing Main with the name you chose for the video source). You will see a list of xmltv identifiers. Remember the ones for BBC 1, BBC 2 and ITV, then exit (Control+X), open uk_rt.sql again and change these three lines.
mysql -u root -p < uk_rt.sqlYou will be prompted to enter your password.
Setting up mythweb
sudo apt-get install mythwebThe earlier instructions should have installed the mythweb package, so if you now open a web browser on a remote machine you should be able to go to either "http://[ip address]/mythweb/" or, if you configured samba, "http://[hostname]/mythweb/". The current setup is not password protected, so the next step is to make the server slightly more secure.
To disable directory listings for the root directory of the server, type sudo nano /etc/apache2/sites-enabled/000-default and remove "Indexes" from the line under <Directory /var/www>. You will need to restart the webserver: sudo /etc/init.d/apache2 restart.
You may wish to remove the default web content of the apache server. To do this, type sudo rm -R /var/www/apache2-default.
Now set a password for the Apache server.
.htaccess authenatication
This method authentication is documented but doesn't work for me. However you may wish to change the MIME type for downloads in the .htaccess file so it is worth doing anyway.
sudo nano /var/www/mythweb/.htaccess
Uncomment the first four lines. You may wish to uncomment (remove the prefix '# ') the first line starting AddType and comment out the next one (prefix with '# '), if you have a DVB-T card which outputs MPEG-2.
Apache authentication
This method involves modifying Apache's settings for the website.
sudo nano /etc/apache2/sites-enabled/000-default
Below the entry for /var/www put the following:
<Directory /var/www/mythweb>
AuthType Basic
AuthName "Mythweb"
AuthUserFile /var/www/htpasswd
Require user mythtv
</Directory>Save (Control+O) and exit (Control+X).
cd /var/www
sudo htpasswd2 -c htpasswd mythtv
Enter the password you want to use for MythWeb. Now restart apache: sudo /etc/init.d/apache2 restart.
MySQL remote access
You may wish to make your MythTV database accessible from other computers. This is useful if you decide to run a frontend on a different PC. Also, the DSMyth Windows filter can display information from the database in the properties dialog for a recording.
mysql -u root -p mythconverg
grant all on mythconverg.* to mythtv@"192.168.2.%" identified by "mythtv";
flush privileges;You may need to replace "192.168.2.%" by your network's subnet.
Backup MySQL database
To backup your database:
mysqldump -u root -p mythconverg -c > backup.sqlFinishing the configuration
You can add and remove channels from your setup by modifying the database. The easiest way to do this is using MythWeb select Settings and then Channels.
If you don't have channel icons visible in MythWeb, do the following:
sudo chmod a+w /usr/share/mythtv/mythweb/images/iconsThis gives the www-data user permission to write to that directory, so that the channel icons can be copied.
If you are missing icons for E4 and E4+1, these can be downloaded from the Freeview website.