Practical MythTV

This tutorial would be presented by Michael Still and Stewart Smith. MythTV is a powerful opensource personal digital video recorder application, which can also play a bunch of other media formats as well as recording from TV.

This is now the final version of the homework for the tutorial.


Note that since the first official release of this homework, the following errata have been discovered:

  1. #1 The ffmpeg installation instructions needed to install more dependancies and have some configure flags. Please redo that section of the homework if you have already done it.
  1. Command "./ --dbhost localhost --norename --ext avi" will fail if you used non-default password. When this happen open file, go to line 68 (my $pass = "mythtv";) and change the password there.

Assumed Knowledge

We assume that you have the following before starting out on this tutorial. If you don't then we will try to accomodate you, but if it's a choice between boring the other people in the tutorial or providing you with personal help, we will help the other people.

  1. You know how to get your chosen distro installed, and how to configure filesystems and LVM without assistance
  2. An understanding of how to use sudo, and apt on Ubuntu, or their equivalents on your distribution
  3. How to work out what packages you need if you're not using Ubuntu
  4. How to download and install kernel modules like your capture card drivers and lirc all by yourself

Before the Tutorial

First off we need you to install MythTV. Complete these steps before the tutorial:

  1. Install the dependancies

sudo apt-get install mysql-server
sudo apt-get build-dep mythtv
  1. Check you have /usr/local/lib in /etc/ (and if not, add it and run ldconfig)
  2. Download (if needed) and install your capture card drivers. Michael's Hauppauge card uses the IVTV driver. Other cards will have different drivers. If you don't have a capture card yet and want to just play with MythTV before making a purchasing decision, then that's fine. Just ignore this step and accept that MythTV wont let you do any capturing without a configured capture card.
  3. If you have a remote control, and want to use it, then download and install lirc. We've had mixed success with the Ubuntu package, so you might be best off downloading the source from and using that.

  4. Grab the latest MythTV source code

wget "" (approx 12 mb)
wget "" (approx 17 mb)
wget "" (approx 14 mb)
  1. Extract, compile and install the main MythTV code

$ tar --bzip -xf mythtv-0.20.tar.bz2
$ cd mythtv-0.20
$ ./configure
...skipping 82 bajillion lines of output...
$ make
...skipping even more output...
$ sudo make install
...more skipped output...
  1. We also need to setup the MySQL database

You will find the scirpt to do this in the database subdirectory of the MythTV source code. You might want to edit database/mc.sql to fit your needs (perhaps a different password for the MythTV user for example)

  1. Then, run the SQL script:

$ mysql -u root < mc.sql
  1. Extract, compile and install the plugins

$ tar --bzip -xf mythplugins-0.20a.tar.bz2
$ cd mythplugins-0.20a
$ ./configure
Configuration settings:

MythArchive plugin will be built
MythBrowser plugin will be built
MythControls plugin will be built
MythFlix plugin will be built
MythDVD plugin will be built
MythGallery plugin will be built
MythGame plugin will be built
MythMusic plugin will be built
MythNews plugin will be built
MythPhone plugin will be built
MythVideo plugin will be built
MythWeather plugin will be built
DVD creation support will be included in MythArchive
Native Archive support will be included in MythArchive
OpenGL support will be included in MythGallery
EXIF support will be included in MythGallery
OpenGL support will be included in MythMusic
FFTW v.2 support will be included in MythMusic
SDL support will be included in MythMusic
AAC support will not be included in MythMusic
FESTIVAL support will not be included in MythPhone
  • Note here that not all plugins will be built. If a plugin isn't being built, then that will be because one of it's dependancies is missing. If you're missing something, then you can try installing the plugin package's build-deps:

    $ sudo apt-get build-dep mythbrowser mythdvd mythgallery \
    mythgame mythmusic mythnews mythphone mythplugins \
    mythvideo mythweather mythweb

    Remember to rerun ./configure if you do install more dependancies.

$ make
...skipping even more output...
$ sudo make install
...more skipped output...
  1. Now do the same thing for the MythTV themes:

$ tar --bzip -xf myththemes-0.20.tar.bz2
$ cd myththemes-0.20
$ ./configure
$ make
$ sudo make install
  1. Now configure MythTV

$ mythtv-setup
  • mythtv-setup might be called mythtvsetup on your distro

Select a language:

Selecting a language for MythTV to run in

You'll end up with a menu:

Setup menu

Now we need to setup the general settings for the MythTV back end. If we don't do this, then it wont work for our demonstrations. Select the "General" option and hit enter. You'll see these wizard screens:

MythTV general settings wizard

There is nothing to change on this first screen, assuming that you are running the back end on this machine, and don't have any others on your network. It's good enough for this homework.

MythTV general settings wizard

Make sure "Delete files slowly" is turned on if you're using ext3.

MythTV general settings wizard

Depending on your country a lot needs to change on this screen. The screenshot above has settings for Australia.

MythTV general settings wizard

The defaults should be fine here.

MythTV general settings wizard

The defaults are again fine.

MythTV general settings wizard

Again, the defaults should be cool unless you want to do wake on LAN for your MythTV machines.

MythTV general settings wizard

This screen defines how processing of videos occurs. Go with the defaults, because we will talk about user jobs and commercial detection during the tutorial itself.

MythTV general settings wizard

The defaults are fine here.

MythTV general settings wizard

Again, we'll setup user jobs during the tutorial.

This is the end of the general settings wizard. You'll be taken back to the main menu. Unless you have a capture card there really isn't anything else to do here. Setting up a capture card will be covered in the tutorial, so we can ignore this for now and just hit escape to exit. You'll probably get an error message about the recordings location not existing:

Directory not found!

Say you know what you're doing, and then go off and create that directory! Remember to change the owner of the directory to the user you intend to run MythTV as.

  1. We need some sample video to work with during the tutorial, so we're gonna download some * I recommend grabbing some ideos from Google Video, but I have an obvious bias in that regard. Any AVI which has MPEG2 or MPEG4 video should work though. Perhaps someone will suggest some smaller videos? Some videos if you need suggestions:

A Googly MySQL Cluster Talk -- Stewart Smith gives a talk about MySQL cluster at Google (210 mb)

Anatomy Of A Debian Package -- Jon Oxer gives a talk about Debian packaging at Google (317 mb)

Deconstructing The Xbox Security System -- Michael Steil, the guy behind xbox-linux gives a talk at Google (278 mb)

Ubuntu Linux -- Mark Shuttleworth talks about Ubuntu while attending the Ubuntu Developer Summit hosted at Google (416 mb)

For the Google Video videos you'll need to click on the Download button, having selected a Windows / Mac download. It's to the right of the screen:

Downloading from Google Video

  1. You then need to import the videos into MythTV. This would be trivial if we had a channel in the channel table, but because this is a fresh install we don't. Instead, we'll make one... First, make sure that you don't clobber an existing channel:

$ mysql -u mythtv -p mythconverg -e "select max(chanid) from channel"
Enter password:
| max(chanid) |
| 1001 |

If you don't have any channels, you'll instead get:

| max(chanid) |
| NULL |
  1. Now we can create a fake "Downloads" channel to own the recordings we're going to import:

$ mysql -u mythtv -p mythconverg -e \
"insert into channel (chanid, callsign, name, commfree) values (XXXX, 'Download', 'Download', 1)"
Enter password:

Where XXXX is either the maximum channel id + 1, or 1001 if the maximum channel id is NULL.
  1. Next we need to start the back end. This is done from the command line, although it is entirely possible to put it in an init script. Here's what a startup (without a tuner) should look like:

$ mythbackend
2007-01-07 10:09:56.961 Using runtime prefix = /usr/local
2007-01-07 10:09:56.978 New DB connection, total: 1
2007-01-07 10:09:56.987 Connected to database 'mythconverg' at host: localhost
2007-01-07 10:09:56.992 Current Schema Version: 1158
Starting up as the master server.
2007-01-07 10:09:57.003 New DB connection, total: 2
2007-01-07 10:09:57.004 Connected to database 'mythconverg' at host: localhost
ERROR: no valid capture cards are defined in the database.
Perhaps you should read the installation instructions?
2007-01-07 10:09:57.008 Main::Starting HttpServer
2007-01-07 10:09:57.012 New DB connection, total: 3
2007-01-07 10:09:57.014 Connected to database 'mythconverg' at host: localhost
2007-01-07 10:09:57.017 Main::Registering HttpStatus Extension
2007-01-07 10:09:57.025 mythbackend version: 0.20.20060828-3
2007-01-07 10:09:57.025 Enabled verbose msgs:  important general
2007-01-07 10:09:57.027 AutoExpire: Found 0 recorders w/max rate of 0 MiB/min
2007-01-07 10:09:57.028 AutoExpire: Required Free Space: 0.0 GB w/freq: 10 min
2007-01-07 10:24:49.738 MainServer::HandleAnnounce Monitor
2007-01-07 10:24:49.744 adding: mikal-vmware as a client (events: 0)
2007-01-07 10:24:49.753 MainServer::HandleAnnounce Monitor
2007-01-07 10:24:49.753 adding: mikal-vmware as a client (events: 1)
  1. Now we're ready to import the videos. Put the files you downloaded into /mnt/store, and then run myth.rebuilddatabase from the contrib directory of the MythTV source (thanks to for pointing this out to me). You'll need to install some dependancies beforehand:

$ sudo apt-get install libtimedate-perl libtime-format-perl
$ ./ --dbhost localhost --norename --ext avi

These are the files stored in (/mnt/store) and will be checked against
your database to see if the exist. If they do not, you will be prompted
for a title and subtitle of the entry, and a record will be created.

/mnt/store/1001_20061226094321.avi /mnt/store/AnatomyOfADebianPack.avi 
/mnt/store/DeconstructingTheXbo.avi /mnt/store/GuidovanRossum.avi 
/mnt/store/TheReiser4Filesystem.avi /mnt/store/UbuntuLinux.avi
Found a match between file and database
File: '/mnt/store/1001_20061226094321.avi'
Title: 'EngEdu'
Unknown file /mnt/store/AnatomyOfADebianPack.avi found.
  • Note that you are prompted once per unknown file, and your answers to the title, subtitle, and description questions here will differ from mine.

Do you want to import? [y]:
Enter channel [1001]:
... title [AnatomyOfADebianPack]: EngEdu
... subtitle: Anatomy of a Debian package
Description [Recovered file AnatomyOfADebianPack.avi]:
... start time (YYYY-MM-DD HH:MM:SS) [2006-12-25 23:59:05]:
... duration (in minutes) [60]:
Building a seek table should improve FF/RW and JUMP functions when watching this video
Do you want to build a seek table for this file? [y]: y
2007-01-01 19:22:48.624 Using runtime prefix = /usr/local
2007-01-01 19:22:48.669 New DB connection, total: 1
2007-01-01 19:22:48.683 mythcommflag version: 0.20.20060828-3
2007-01-01 19:22:48.683 Enabled verbose msgs: important

MythTV Commercial Flagger, started at Mon Jan 1 19:22:48 2007
Building seek table for: /mnt/store/1001_20061225235905.avi
0: start_time: 0.000 duration: 0.101
1: start_time: 0.000 duration: 0.129
stream: start_time: 0.000 duration: 3376.122 bitrate=787 kb/s
100%/ 1193fpsRebuilt

Finished commercial break flagging at Mon Jan 1 19:24:15 2007
  1. And now we have some videos in the user interface! To see them, run the front end:

$ mythfrontend

And then select "Media Library", then "Watch Recordings". There they are...

Videos in the user interface

  1. Finally, we need to setup ffmpeg. Do it like this:

$ sudo apt-get build-dep ffmpeg
$ sudo apt-get install subversion transcode mjpegtools libxvidcore4-dev libxvidcore4 libfaac-dev libfaac0 libid3-3.8.3-dev
$ svn checkout svn:// ffmpeg
$ cd ffmpeg
$ ./configure --enable-gpl --enable-xvid --enable-faac
$ make
$ sudo make install

Too lazy to do the homework?

Well, there is another option, but it is cheating. I've put a VMWare image of a machine with all the homework done online. Download it like this:

$ sudo apt-get install vmware-player
$ wget
$ tar --bzip -xvf lca2007.tar.bz2

(Ubuntu users will need the multiverse repository enabled)

You can then open the virtual machine with the free version of VMWare like this:

$ vmplayer

Now use the UI to select the directory you just extracted, and you should be good to go.

During the tutorial

We intend to cover the following topics during the tutorial itself:

  1. What are the moving parts?
  2. A 10 second demo of MythTV
  3. Commercial detection
  4. Cutlists
  5. DVD playback with builtin player
  6. Guide data
  7. User jobs
  8. Nuv export and transcoding for devices like iPod and PSP
  9. Mythtranscode
  10. Remote frontends
  11. Telnet and IM interfaces to your front end
  12. MythWeb setup and demo

MythTutorial (last edited 2007-01-13 23:09:36 by bimberi)

  • Immutable Page
  • Info
  • Attachments