MythTV Walkthrough

From ArchWiki
Revision as of 18:58, 1 April 2007 by Paulr (Talk | contribs)

Jump to: navigation, search

About this document

What is MythTV ?

MythTV is a Linux based Personal Video Recorder. It acts as an intelligent combined television and video recorder. There are many plugins for it which expand its basic functionality.

MythTV is unusual in that it is split into two. The "back end" and the "front end". The back end receives and records the video, the front end shows it and controls the back end. This allows you to seperate the two.

Why two entries in the Wiki ?

There already exists a wiki entry for installing mythtv. However, it does lack detail for the less experienced user. I wanted to write a "from beginning to end" installation guide for mythtv ; to do that would require editing the original MythTV HOWTO pretty drastically, and would lose it's advantage of brevity and simplicity. I would recommend reading both guides.

The downside to my approach is that the instructions are 'specific' for my hardware and my location. What I do will only work if you live near me, and have my hardware. But I hope to give enough pointers to make the document helpful for anyone who wishes to install MythTV anywhere.

The document is deliberately quite systematic ; do something, check that's worked, then go on to the next step. If you can't figure it out from the instructions it should help you understand where to look for the right answers, and what part of the set up is being problematic.

Localisation and Hardware variations

MythTV can cope with a wide variety of hardware. There are two main things that change from system to system which require significant setting up.

Firstly, the video capture card. There are many of these and they are often subtly different. MythTV does a pretty good job of detecting and configuring hardware.

Secondly, the location. MythTV has an Electronic Program Guide (EPG) built in, so that programmes can be recorder and viewed easily. There is a common way of setting this up using a program called XMLTV, which extracts data from web sites or other data providers. Some devices (for example DVB-T cards) also require transmitter information.

Some digital systems can use the EPG which is part of the signal. This is currently in development.

My personal information

This guide is written 'as I do it'. However, this is for my hardware in my location, and you are almost certainly different. I will offer suggestions for alternatives where appropriate. It is always worth reading installation guides for other machines ; the process of installation does not vary significantly. If you have a common video capture card, you can find help in most cases ..... somewhere. The MythTV website is a good place to start.

My Hardware

I'm running Arch Linux 0.8 (Voodoo) with an Nvidia card. The "important" piece of hardware though is my DVB-T capture card. DVB-T is known in the UK as "Freeview" ; it is digital television transmitted down the 'standard' aerial.

Other alternatives are the old analogue system, DVB-S (satellite) and DVB-C (cable),

The capture card I am using is a Hauppauge WinTV "NOVA" model, which fits internally in one of the PCI expansion slots. It is highly recommended for DVB-T reception and it is pretty cheap.

My Location

I live in Norfolk in England, and my nearest transmitter is in Tacolneston. Fortunately this is about 5 miles away which means I can "get away with" an indoor aerial, normally DVB=T requires an outdoor aerial. It is rather like FM radio ; you either get a good signal or none at all.

Setting up the hardware

Fortunately my hardware is autodetected by the Arch 0.8 Kernel, or almost completely. It does not install the cx88_dvb module which is required for my system.

Checking it exists

if you do either

lspci

or

lsusb

it will list all the devices connected to the PCI bus or the USB bus respectively. You should see something which roughly describes your hardware. In my case, lspci produces

02:01.0 Multimedia video controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder (rev 05)
02:01.2 Multimedia controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder [MPEG Port] (rev 05)
02:01.4 Multimedia controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder [IR Port] (rev 05)

you can also look at the boot log by typing

dmesg | less

this shows what the system is doing as it 'boots up' ; somewhere you will hopefully see text which describes your card. In my case, a part of the log is

Linux video capture interface: v2.00
cx2388x cx88-mpeg Driver Manager version 0.0.6 loaded
CORE cx88[0]: subsystem: 0070:9002, board: Hauppauge Nova-T DVB-T [card=18,autodetected]
TV tuner 4 at 0x1fe, Radio tuner -1 at 0x1fe

there is a great deal more descriptive information, but this is very hardware specific.

Putting in the module

To force the Kernel to load the cx88_dvb module I changed my rc.conf file so the "MODULES" line reads as follows

MODULES=(r8169 cx88_dvb)

This will force the kernel to load the module at start up. The r8169 module is my network card and is likely to be different on your system.

You can reboot it ; if you don't want to, load it yourself, just this once, with

modprobe cx88_dvb

Checking it works

The simplest way to check it works initially, and that the system has recognised it is to check for the existence of the video device(s) in linux.

ls /dev/v4l

checks for analogue devices and

ls /dev/dvb

checks for digital devices. In both cases you should see a list of device links (like a directory listing). If these are present then linux has probably recognised the card, and it might work.

The next stage is to try and see if it is picking up any signal.

Getting the first digital signal

This part is very specific to DVB-T. For a standard analogue card, you have to do very little ; for DVB-C and DVB-S I do not know.

The first thing to do is to install linux-dvb-apps.

pacman -S linuxtv-dvb-apps

What transmitter do I use ?

Each transmitter transmits DVB-T signals on a different frequency. You need to find a file which describes your local transmitter frequencies.

The simplest way in the UK is to use the WolfBane website at http://www.wolfbane.com. If you click on "UK digital TV reception predictor" you can enter your postal code (what we call the "zip code") and it will tell you what tranmitters are available.

The next stage is to find the "ukxxxx" file.

What is the ukXXXX file ?

The ukxxxx file is the file that describes how your transmitter transmits DVB-T data. For my transmitter, Tacolneston, it looks like this :-

# UK Tacolneston
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
T 730166670 8MHz 3/4 NONE QAM16 2k 1/32 NONE

I have no idea what it means either, if it's any consolation. Not that it matters much, as long as it works.

How do I find it ?

Unfortunately there is no central repository of these - as far as I know anyway (!). If you have installed linuxtv-dvb-apps (i.e. you're following the instructions) you should find a listing of these in the /usr/share/dvb-utils/scan/dvb-t directory.

There's about 30 listed here from various countries (including Australia, the UK and the Netherlands). If your transmitter is not listed here, as uk-Tacolneston wasn't, then you have to hunt on the web ; I googled for things like "DVB-T Transmitter MythTV Tacolneston" and the like, and found a gentleman called Adam Bower had already done the work for me ; thanks, Adam.

What is channels.conf ?

Having acquired your transmitter information (in my case, in the file uk-Tacolneston, you now query your local transmitter to see what channels it has to offer. These contain things like channel details and the tuning frequencies, go in a file commonly called "channels.conf". Once you have this, it should be easy to get your system watching television using mplayer.

Generating the channels.conf

You may be able to find a channels.conf for your transmitter already. If you can't, to create our channels.conf we use a program called 'scan' (part of the linux-dvb-apps we installed earlier)

scan uk-Tacolneston >channels.conf

This should print out reams of gobbledegook, hopefully without error messages. If there are error messages, check your signal strength (do you need a better aerial ?) and your frequencies, which may be wrong.

If you open channels.conf in an editor it should look something like this (lines truncated slightly here !)

Five:730166670:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2 (etc)
Five Life:730166670:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC (etc)
Five US:730166670:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1 (etc)

except there will be more of it (one line for each channel). The first things on each line should be recognisable as the channels available on your local service. The names are often truncated.

Getting the first picture

This part is again only applicable to DVB-T transmissions. The next part is to check the card is working by - watching some television.

Install and run Mplayer

My preferred viewer is mplayer (though you can do this with xine as well - the process is identical, where I say mplayer you put xine !). To view the television in mplayer, firstly install it once and run it.

pacman -S mplayer
mplayer

It is run once to create the .mplayer subdirectory in your home directory, which will contain your channels.conf file.

Making Mplayer work with DVB-T

To make mplayer work with DVB you have to tell it about the channels it can read. The simplest way of doing this is to copy the channels.conf file into your .mplayer directory

cp /aux/arch/channels.conf /home/paulr/.mplayer

(Your command may vary depending on your login name and the directory you put the channels.conf file)

You should now be able to watch TV. Look at one of the channels in your channels.conf. I shall choose the TV channel BBC1. The line from channels.conf looks like this.

BBC ONE:810000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4 (etc).

to watch BBC1, you use the name of the channel - the line as far as the first colon. In this case

mplayer dvb://"BBC ONE"

Replace BBC ONE with the channel you wish to watch. With a bit of luck, if everything has worked, that should open a window and start playing the channel in glorious LinuxColour ; in this case , BBC1.

If not ... search the internet checking error messages :) If the previous stage worked (getting the uk-xxxxx and channels.conf) it's a bit puzzling that it doesn't work.

If you've got this far you can be pretty sure you will get MythTV to work properly - eventually. There's a bit more setting up to be done yet. It is not that difficult to get MythTV working, recording, display video, and so on. The hard bit - in my experience anyway - is getting the EPG working.

But it *is* worth it. MythTV watching is a whole new way of looking at television ; it's a whole new way of thinking about television. Without DRM.

"I think this is getting needlessly messianic." (Fook, Hitch Hikers Guide to the Galaxy)

Installing XMLTV

What does XMLTV actually *do* ?

Any good PVR system needs to know when to record. Systems like VideoPlus in the UK, where numbers encode start and stop times, have made programming easier, but it's much easier to just look at an EPG and click on the programme you want to record.

However, there is no central system for acquiring TV programme data, at present, so that's where XMLTV comes in. XMLTV's job is to take program data off the internet and convert it to a standard format for PVRs like MythTV and FreeVO.

Why XMLTV is so problematical

The problem with XMLTV is it is grabbing data from places that weren't really designed to supply it. It kind of "screen scrapes" - it looks at a web page containing TV information like this, http://www.bbc.co.uk/cgi-perl/whatson/search/grid.cgi?MEDIUM=tv and tries to rip the text off it and convert it into an easy to use format. Things can go wrong with this ; if the website decides it's going to reformat its text, then it will cease to work properly or indeed at all.

What about the DVB-T EPG ?

DVB-T, aka Freeview here, has programme guide information embedded in it ; any UK Freeview set top box has an EPG. It seems to be problematic getting this to work in MythTV, as it is currently "in development". When it does work, this will make it much easier as XMLTV can be abandoned, for DVB-T anyway (still needed for analogue, which is sound and video only)

One downside of the DVB-T EPG is that it only goes 7 days into the future, whereas XMLTV does 14 days. This is useful if you want to record when you are on holiday.

What about the AUR

XMLTV is in the AUR, both in 'normal' form, and in CVS form. I personally haven't had much luck with this, so I'm going to compile it from scratch. This isn't difficult, the "hard" part is the "perl dependencies" (XMLTV is a Perl application) and getting them right.

Download and first compile

You first need to obtain the current version of XMLTV ; this can be downloaded from Sourceforge http://sourceforge.net/projects/xmltv ; the current version as I write is 0.5.45

After having downloaded it, create a working directory somewhere and untar the source into it.

cd /aux/arch/mythtv
tar xjvf tar xjvf /home/paulr/Desktop/xmltv-0.5.45.tar.bz2 
cd xmltv-0.5.45

this will create a directory xmltv-0.5.45 in the saved directory with the source code in it, then change to it. Now, we're going to install some basic dependencies. In spite of the long list, there's not actually very much code downloaded here.

pacman -S perl-archive-zip perl-date-manip perl-html-tableextract perl-http-cache-transparent perl-io-gzip perl-io-stringy perl-term-progressbar perl-unicode-string perl-www-mechanize perl-xml-twig perl-xml-writer

and next, we will attempt to compile the program

perl Makefile.PL

This should produce a listing that looks like this.

XMLTV.pm library and the filter programs such as tv_grep and tv_sort
are installed by default; here you choose grabbers for different
countries and front-ends for managing listings.
Grabber for Brazil (tv_grab_br)                                    [yes]
Grabber for Brazil NET Cable (tv_grab_br_net)                      [yes]
Grabber for Switzerland (tv_grab_ch_bluewin)                       [yes]
Alternative grabber for Britain (tv_grab_uk_rt)                    [yes]
Fast alternative grabber for the UK (tv_grab_uk_bleb)              [yes]

.... and so on. Find your country in the list and hopefully it will be marked "yes". If not, try installing perl-tk-tablematrix using Pacman, break with Ctrl+C and run the perl command above again. If it still doesn't work, try installing perl-soap-lite from AUR.

Fortunately for me, it has found the tv_grab_uk_rt grabber for the UK that I am going to use. Make a note of its name, because I will refer to mine (tv_grab_uk_rt) throughout ; whereas you may need, for example, tv_grab_br

It now asks "Do you want to continue with this configuration ?" ; you actually don't need all those grabbers, but what the heck, just press RETURN for yes.

Now compile and install the program with

make
su (then enter your password)
make install
(Press Ctrl+D to get back to non superuser mode)

Configuring XMLTV

Next we need to configure XMLTV. To do this run

tv_grab_uk_rt --configure

Now, for this grabber, you can individually select whether or not you want each channel. We aren't going to do this yet, and we aren't going to do it this way anyway - it's mindless. So type

all

And it will configure itself to download every single channel it can.

Checking XMLTV actually works

To check it, simply run it.

tv_grab_uk_rt

If all is well, it should churn out reams and reams of channel programme data. It should look like this

<programme start="20070330035500 +0100" stop="20070330042000 +0100" channel="abc1.disney.com">
   <title>8 Simple Rules for Dating My Teenage Daughter</title>
   <sub-title>Rory's Got a Girlfriend</sub-title>
   <desc lang="en">Sitcom in which a father has his hands full when his wife returns to work and he is left to supervise their teenage daughters. Paul has to face the fact that his son wants to start dating girls, and Kerry envies her sister.</desc>
   <credits>
     <actor>John Ritter</actor>
     <actor>Katey Sagal</actor>

except there'll be pages of it.

You can have it all, but you don't want to

If you let it run through to the very very end it will take a long time. Normally you don't want to do this ; you want just the channels that there are on your system. On the tv_grab_uk_rt listings there are 271 channels, but DVB-T Freeview only has about 50 odd.

We will cut this down later and make the tv grabber run faster.

Installing MythTV

Installing MySQL

To start with, we install MySQL, the open source database. This is used to store information for mythtv. These three lines install it, start it running, and set the password to 'root' (change as you wish). You will need to use 'su' to get into superuser mode first.

su
pacman -S mysql
/etc/rc.d/mysql start
mysqladmin -u root password root

You should also edit your /etc/rc.conf file to start it up automatically, by adding mysqld to the list of daemons. The daemons line should now read something like:

DAEMONS=(syslog-ng network netfs crondi gdm @cups @hal @alsa @openntpd @mysqld)

The '@' prefix starts it in the background.

To check it works okay, enter

mysql -u root -p

and when it asks you for the password, type in whatever you set the password to above (in this case, root). It should start up the command line interface to MySQL. To exit, type Ctrl+D.

Installing MythTV

Installing MythTV is easy. This command will install the MythTv program and the themes that go with it.

pacman -S mythtv myththemes

Creating the Database

Finally, we need to initialise the SQL Database that MythTV uses. There is a script to do this.

mysql -u root -p </usr/share/mythtv/mc.sql

Again, you will need to enter the root password.

Setting up MythTV

Press Ctrl+D to leave superuser mode. Type the following command to set up mythtv.

mythtv-setup

Select your preferred language

Select the preferred language (in my case, English(British)) and press Return to go to the next screen.

Section 1. General

  • "host specific backend setup" : allows you to use a specified directory to store your recordings.
  • "Global Backend setup" : I had to set the TV format to "PAL" and the Channel Frequency Table to "Europe-West" ; these may vary depending upon which country you are in.

For all the other pages, you can simply leave the defaults as they are. You can always change them later.

Section 2. Capture Cards

This is where you specify your capture card. Select "New Capture Card" and change the type to whatever your card type is. For my WinTV NOVA, it is "DVB DTV Capture Card (v3.x)".

Mythtv should hopefully identify what your capture card is. Select Finish to store the new capture card, and then press ESC to return to the setup menu.

Section 3. Video Sources

Select "New Video Source" and enter a name (like DVB Card, for example). Then change the entry "XMLTV Listings Grabber" until it matches the name of the grabber you set up in the XMLTV section.

It will now configure this in the background. Again, we can skip this configuration for the time being. When you click on finish, the bar goes to 50% and stops. You will need to Alt-TAB to find the terminal window again. As before, you can select "all", because we will fix it all properly later.

Then press ESC to return to the main menu.

Section 4. Input Connections

Select the Video Source you just created, and bring up the 'Connect Source to Input' Dialog.

Give it an appropriate name ; in the UK it is known as "Freeview". For the Video Source, select the Capture Card

For DVB-T cards like mine, Tab down to and select "Scan for Channels", then TAB to "Scan Type" and switch this to "channels.conf". We are going to use the channels.conf we created earlier to configure mythtv. When you click on "finish" for this, it will display "Adding ....." for all the channels you found before.

If you don't have a DVB card but use something like an analogue card, you may need to scan for channels and label them yourself.

Click on Finish twice, then ESC to return to the main setup menu.

Section 5. Channel Editor

You can look at this, but we are going to configure it in a minute.

First run of MythTV

Start up the Myth BackEnd (this is the bit that does all the recording and so on) as follows.

su
/etc/rc.d/mythbackend start
(Press Ctrl+D)

When it's working you can put mythbackend in your DAEMONS line as we did for MySQL above. You may get an authentication error, which I think is something to do with QT, which I believe can be ignored. Now run the front end by typing

mythfrontend

If you go to "Watch TV" you can (errmmm....) Watch TV, you can change channel with your up and down keys, and it all works quite nicely.

You can also simply run

mythtv

This is just a "TV Watching" application with no other facilities.

Rats ! It doesn't seem to be working.

Yes, it's only about half there. The TV playing now works fine. What doesn't exist is the EPG - it doesn't tell you what is on the channel, and if you look at the EPG in the Recording section there's no data.

What we have to do now is to make the XMLTV Data work with MythTV.

Linking XMLTV and MythTV

The shotgun wedding

There is a problem to fix. We have to get the XMLTV data and the MythTV working together.

If you look at the channels.conf file, which says what channels are on MythTV, it looks like this :

Five:730166670:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2 (etc)
Five Life:730166670:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC (etc)
Five US:730166670:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1 (etc)

If you look at the XMLTV file DVB Card.xmltv it looks like this :

channel channel5.co.uk
channel life.channel5.co.uk
channel us.channel5.co.uk

The problem is getting the two to work together. We have to tell MythTV that the channel5.co.uk matches up to the channel called "Five", the life.channel5.co.uk matches up to the channel called "Five Life" and so on.

This is one of those quite difficult computing problem. To a human brain, it is pretty obvious. To a computer, that sort of pattern matching is really quite difficult.

What you are trying to do, technically

run the following

mysql -u root -p 
(then enter the password)
(then enter these commands into the MySQL client)
use mythconverg;
select name,xmltvid from channel;

this will query the MythTV database and show the names of the channels, and the name of the associate xmltv channel. It will now look like :

+----------------+---------+
| name           | xmltvid |
+----------------+---------+
| Five           |         | 
| Five Life      |         | 
| Five US        |         | 

but with many more channels. We need to get the channel data from the above table in there, so that for the name row the xmltvid value is channel5.co.uk. That way MythTV knows where to look. There are also columns which allow you to set the icons, which at present I am not doing.

Using MythTV

You can do this using the Channel Editor section of MythTV. This is not difficult, but very slow and boring.

Using XMLTVDruid

In AUR there is a program called XMLTV Druid which provides a better GUI for doing this. I haven't tried it. I'm not even sure if it does this 'marriage' of XMLTV and MythTV.

Doing it by MySQL Script or similar

My method of doing it involves using a text file containing the channel name and the xmltv channels together, which when run creates two files ; an SQL file which sets up the data in the MythTV database, thus doing the "shotgun marriage", and also creates a replacement "DVB Card.xmltv" which doesn't require *all* the channels to be checked, only the ones we are actually using.

That's why I suggested not bothering with selecting the channels in use earlier ; we are going to replace them now.

This is my control file, the name of the file should be mythtv.config. On the left hand side is the name of the channel from channels.conf ; on the right hand side is the channel source from XMLTV.

#
# XMLTV Matchup Source File
#
Five:channel5.co.uk
Five Life:life.channel5.co.uk
Five US:us.channel5.co.uk
QVC:qvcuk.com
abc1:abc1.disney.com
bid tv:bid-up.tv
TCM:sky-three.sky.com
UKTV Style:uk-style.flextech.telewest.co.uk
UKTV Gold:uk-style.flextech.telewest.co.uk
price-drop tv:price-drop.tv
Teachers' TV:dvb.teachers.tv
Eurosport UK:british.eurosport.com
BBC ONE:east.bbc1.bbc.co.uk
BBC NEWS 24:news-24.bbc.co.uk
CBBC Channel:cbbc.bbc.co.uk
BBC TWO:east.bbc2.bbc.co.uk
ITV1:anglia.tv.co.uk
ITV2:itv2.itv.co.uk
ITV3:itv3.itv.co.uk
CITV:citv.itv.co.uk
Channel 4:channel4.com
E4:e4.channel4.com
More 4:more4.channel4.com
Film4+1:plus-1.filmfour.channel4.com
ITV4:itv4.itv.co.uk
BBC Parliament:parliament.bbc.co.uk
CBeebies:cbeebies.bbc.co.uk
E4+1:plus-1.e4.channel4.com
UKTV History:ukhistory.tv
SKY THREE:sky-three.sky.com
Sky Spts News:news.sports.sky.com
Sky News:sky-news.sky.com
Ideal World:idealworld.tv
f tn:ftn.tv
UKTV Br'tIdeas:ukbrightideas.tv
Film4:filmfour.channel4.com

The only changes a UK user will need to make are to BBC1, BBC2 and ITV1 ; in this file they are set up for the eastern region (BBC East and Anglia Television) ; in different parts of the country different sources are required.

This is the perl script that takes that file and generates an SQL file match.sql and also outputs a replacement DVB Card.xmltv file.

(to be written)

Save this file as match.pl, then run the command :

perl match.pl >DVB.xmltv

Then you have to copy the new DVB file into the correct place

cp DVB.xmltv /home/paulr/.mythtv/DVB\ Card.xmltv

Then you have to run the SQL script to insert the data into the SQL Database.

mysql -u root -p <match.sql

Checking that it's worked

The simplest check is to repeat the query on the MythTV database ; if it has worked then many, but probably not all, of your IDs should be matched up.

mysql -u root -p 
(then enter the password)
(then enter these commands into the MySQL client)
use mythconverg;
select name,xmltvid from channel;

Running mythfilldatabase

(to be written)

Now go and play

Now, when you run mythfrontend, it should display the program information, and the EPG should be complete in the recording section.