Table of Contents

  1. Documentation
  2. System Architecture
  3. Hardware and Operating System
  4. Sound
  5. Disk Partitions
  6. Program Guide
  7. LAME
  8. IVTV
  9. MySQL
  10. Compiling MythTV
  11. Setting up MythTV
  12. Getting Composite Video Out
  13. IR Remote Control
  14. Automatic Startup
  15. Codec Libraries
  16. Ogle
  17. Transcode
  18. MPlayer
  19. Compiling MythPlugins
  20. The Myth Transcode Daemon
  21. MythWeather
  22. MythVideo
  23. MythDVD
  24. MythGames
  25. MythWeb
  26. MythMusic
  27. MythGallery
  28. Maintenance

Related

  1. Linux Links
  2. Sound Installation
  3. DVD Ripping

A MythTV Home Media System

Introduction

These are my personal notes and links about using MythTV to satisfy my family's desire for a distributed personal video recorder. I chose it for number of factors: stability, features, distributed architecture, large user community. MythTV is an open source software project started and led by Isaac Richards and contributed to by many other people. MythTV is currently stable, and supports various languages and video standards, including HD. Its developers can be very proud of their work !

I'm happy to report 26 months of reliable PVR operation! I've recently upgraded to MythTV 0.20.2 on the home system. --9/13/07

Simpler Alternatives

For a simple taste of MythTV, you could try the Knoppix version (Wiki). I've never used it myself, though. Ubuntu (an up-to-date distribution of Debian) provides MythTV as a prebuilt package, making it an attractive option for playing around (see other guides). Installing MythTV from scratch, while providing features not available in precompiled distributions, requires a non-trivial amount of software installation, as detailed in this page.

DVD Ripping

One great enhancement to Myth is the MythVideo plug-in, which provides for playing back movies and video clips from various sources, found in your media library. Now you can rip your DVDs and not worry about the kids scratching them any more, as well as providing easy access to those home videos you've edited with iMovie. While the accompanying MythDVD plug-in provides a means of ripping DVDs, I prefer dvd::rip. This is a Perl application which provides an graphical interface (for an X display) to the transcode application.

Documentation

There is now a single main source of information about MythTV, the Wiki, at www.mythtv.org/wiki. The two primary sources of installation information are the Installation Manual and the Wiki Installation Page. Someone has been doing a great job updating the User's Manual, and I recommend it for information about using your MythTV system once setup.

There is an official mailing list for users of MythTV, which has a searchable archive. There is also searchable archive for the MythTV development mailing list.

There are a growing number of HOWTO documents being written. Here are a select few:

Other sites describing MythTV installs include:

Email me if you find userful sites that I have missed

System Architecture

I started with a distributed design in mind, hence one of the reasons I chose MythTV as my PVR software. I wanted a box in the basement, with at least two tuners and lots of storage, accessible from any number of network-connected TVs and computers around the house.

Master Media Server

In the MythTV terminology, a machine in the basement is my master backend server. It runs the MySQL database containing the program guide and all pending recordings. All video recorded on slave backend servers is transferred to it.

TVs with Slave Mediaservers

For now, a regular TV will use a "heavy" networked video client which combines a video capture device with a video output capability. In the MythTV terminology, this is a slave backend server (supporting the video capture) and a front-end interface.

Personal Computers

Several of the TV clients around the house are Apple Macintosh Minis, eMacs (800MHz+ PowerPCs, w. 256 MB of memory), or the occasional PowerBook. They work nicely, except for a problem with Mac Mini's driving over twelve feet of Cat5 cable at 100Mbps. Use a switch/hub near the Mini to fix the problem). You can compile your own MythTV front end, or use a precompiled binary. It is currently available for Mac OS X Tiger (10.4). Of course, any Linux computer may be a TV client. Windows machines can use WinMyth (although poor performance has resulted in competition).

TVs with Thin Clients

My goal is to eventually support the Hauppauge MVP and its like as thin frontend client to MythTV. These would support the cheap ($80) interface of TVs to the system.

Hardware & Operating System

I strongly recommend using hardware encoders. The PVR-150/250/500 series from Hauppauge is a rock solid and cheap solution at this time for analog NTSC (terrestrial broadcast and cable in the US). Using hardware encoders means that you can use older equipment as the video server, and support many tuners.

How many tuners ? The rule of thumb I've developed is that you want at least 1 + N tuners, where N is the number of TV which are simultaneously watched in a home. If PIP is used heavily, this becomes 1 + 2N. You can add additional tuners in thick clients if N is large. This rule minimizes the number of times that a recording has to be cancelled due to a shortage of tuners.

My main home mediaserver is a Pentium III Celeron running at 900MHz (with 256 MBytes of 100MHz SDRAM on an i815 based ATX motherboard), and a 200 GByte Western Digital disk. It has two Hauppauge PVR-250 PCI cards, each providing a cable TV tuner, digitizer and hardware MPEG-2 encoders.

One dedicated remote client (and secondary mediaserver) is an AMD Sempron (K7) 2500 (with 512MB of 133MHz SDRAM) on an MSI KM4M-V mATX motherboard, and a 40 GByte local disk. It uses an nVidia GeForce4 MX4000 based graphics card for NTSC/S-Video video output. It has a single Hauppauge PVR-250 card for video input (and encoding) and does software decoding for display. It works very well, and also performs transcoding and commercial detection for the system with its idle processing power.

I have used several generations of Shuttle computers as MythTV servers/clients. These are compact, powerful little machines which recently have gotten quiet as well! (Shuttle Related Issues)

All mediaservers are running the Debian distribution of the Linux operating system. They are currently running a testing release with a custom 2.6.14 kernel, but the standard 2.6.8 kernel is fine. You will need to use GCC 3.3. While MythTV itself appears to be GCC 4.0 compatible, some of the codecs and support applications that you will want available in MythVideo and transcode do not compile with GCC 4.0 (or 3.4).

If you install a newer system, you can indicate your preference for a system compiler by replacing the gcc and g++ links in /usr/bin with ones to older versions:

sudo apt-get -y install gcc-3.3 g++-3.3
pushd /usr/bin
sudo ln -s gcc-3.3 gcc
sudo ln -s g++-3.3 g++

This is not an ideal situation, as some of the development libraries are provided by Debian and are compiled using the default, newer, compiler. You should probably have apt configured to support pinning, using both the stable and testing packages.

Required Packages

Required packages include:

sudo apt-get install unzip mysql-server mysql-client libqt3c102-mt \
    libqt3-mt-dev/stable qt3-dev-tools/stable libqt3c102-mt-mysql \
    freetype2-dev libasound2-dev libxinerama-dev libxxf86vm-dev

Optional Packages

Optional packages are used by Myth plug-ins. Unless you are building just a barebones MythTV-only system you should install these:

sudo apt-get install automake autoconf libtool libtiff4-dev libcdaudio0-dev \
   liboggflac-dev libid3tag0-dev libmad0-dev kdelibs4-dev libdvdread3-dev \
   libgtk-dev lirc lirc-modules-source libxaw6-dev libmagick9-dev \
   libdts-dev libcdparanoia0-dev fftw3-dev libxml-simple-perl libwww-perl

If you are running an older Debian, you might need libmagick6-dev instead of libmagick9-dev.

Sound

If you are going to use a Debian machine to run a front end, make sure that sound is working correctly. If it isn't, see some of my installation suggestions.

Disks and Partitioning

My MythTV machines all use a single disk for power consumption and reliability reasons. I used to suggest some fancy partitioning where unkempt log files couldn't shut down the system, but I've given up... They are divided into three partitions:

  • A system partition (the root partition). At least 8 GBytes.
  • A swap partition (at least four times the physical memory). If you need more than 2 GBytes of swap, use multiple partitions each limited to 2 GBytes.
  • A video storage partition (which conceivably could be a separate disk). This is mounted as /storage, with video files being stored in /storage/video/ and live video buffering occurring in /storage/livebuffer.

Use cfdisk to partition a disk, then mke2fs and mkswap to initialize the partitions. I considered using XFS, but there is SOME performance impact and a recording that gets interrupted by a crash (yet to happen...) has bigger issues than a few lost blocks at the end.

Program Guide

The program quide for MythTV is obtained from Schedules Direct, a non-profit distributor of such information to open source projects. It does cost money, unlike earlier MythTV program guide suppliers, but it is relatively cheap ($15 per six months). You will need to open an account with Schedules Direct --- the username and password will be entered into mythtv-setup for downloading your program guide information (my member ID is wad451 and my password is the ML hardware mailing list).

The guide information needs to be downloaded periodically. This is best left to the MythTV software. There is a check box somewhere in the configuration maze for disabling the automatic download by the master backend server (it was handled by a cron job in older installations), but I recommend against it.

You can check on the status of your subscription from a MythTV top-level menu by selecting Information, then System Status, or using MythWeb (status page, at the bottom).

LAME

Lame is an open source MPEG layer 2 audio encoder. It is needed for MythTV to function, and must be installed through source code on Debian systems. Download and install the latest version using:

wget http://umn.dl.sourceforge.net/sourceforge/lame/lame-3.96.1.tar.gz
tar xfz lame-3.96.1.tar.gz
pushd lame-3.96.1
./configure
make
sudo make install

IVTV

IVTV is the wonderful piece of open source driver software which allows us to use the readily available Hauppauge MPEG compression cards (PVR-150, PVR-250, PVR-350, and PVR-500) with MythTV.

The Debian Way

One approach is to pull the sources from a non-Debian repository, and compile and install them using the module assistant tool. Take a look at the Debian How-To. (Let me know how this approach works for you...)

Manual Installation

You can download the driver source for your kernel (check the download page, currently 0.4.7 for pre-2.6.15 kernels and 0.8.0 for post-2.6.17 kernels) and compile it against your kernel source to produce a driver suitable for your system. This requires that you have either compiled up your local kernel or have the appropriate kernel-headers or kernel-source package for your kernel installed.

wget http://dl.ivtvdriver.org/ivtv/archive/0.4.x/ivtv-0.4.7.tar.gz
tar xfz ivtv-0.4.7.tar.gz
pushd ivtv-0.4.7 ; make
wget http://dl.ivtvdriver.org/ivtv/archive/0.4.x/ivtv-0.8.0.tar.gz
tar xfz ivtv-0.8.0.tar.gz
pushd ivtv-0.8.0 ; make

At this point, you should move some drivers provided with the kernel which conflict with those provided with IVTV:

pushd /lib/modules/`uname -r`/kernel/drivers/media/video/
sudo mv msp3400.ko msp3400.ko.old
sudo mv tuner.ko tuner.ko.old
sudo mv tveeprom.ko tveeprom.ko.old
sudo mv tda9887.ko tda9887.ko.old
popd
sudo make install

NB: Make sure that you are using exactly the same compiler as was used to compile the kernel. If you've upgraded the compiler (even from 3.3.5 to 3.3.6), you will need to recompile the kernel again...

Firmware

The open source drivers do not include the microcode firmware needed operate the encoder/decoder chip. It must be extracted from drivers provided by Hauppauge. You will need to download these drivers (or get them from the CD included with the card), then extract the firmware using a tool provided with the ivtv driver (utils/ivtvfwextract.pl). These instructions must be executed from the ivtv source directory (/opt/mythtv/ivtv-0.4.3/ in this installation).

wget ftp://ftp.shspvr.com/download/wintv-pvr_150-500/inf/pvr_2.0.24.23035.zip
unzip pvr_2.0.24.23035.zip
sudo cp HcwMakoA.ROM /usr/lib/hotplug/firmware/v4l-cx25840.fw
sudo cp HcwFalcn.rom /usr/lib/hotplug/firmware/v4l-cx2341x-enc.fw
wget ftp://ftp.shspvr.com/download/wintv-pvr_250-350/inf/pvr_1.18.21.22301_inf.zip 
sudo utils/ivtvfwextract.pl pvr_1.18.21.22301_inf.zip
sudo rm /lib/modules/ivtv-fw-enc.bin
sudo mv /lib/modules/ivtv-fw-dec.bin /usr/lib/hotplug/firmware/v4l-cx2341x-dec.fw
sudo cp v4l-cx2341x-init.mpg /usr/lib/hotplug/firmware

This will place the extracted firmware in the location where the current version of the ivtv driver expects to find it (/usr/lib/hotplug/firmware/). Versions earlier than 0.40 of ivtv store the firmware in a different location (/lib/modules/) and use different filenames than earlier versions.

Testing

You can test the drivers by simply typing:

cat /dev/video0 > scratch_video.mpg

and stopping it with ^C after a while. There should be roughly 256 to 512 KBytes of data in scratch_video.mpg for each second that cat was running. For a better test, type the following to set capture parameters (test_ioctl is in the utils/ subdirectory of ivtv) :

/usr/bin/test_ioctl -u 0x3000
/usr/bin/test_ioctl -p 4
/usr/bin/test_ioctl -f width=720,height=480     

Now cat some data from /dev/video0 and you should be able to watch it using MPlayer.

Loading at Startup

This section is no longer needed, due to more intelligent /dev systems in newer kernels.

You will need to establish a relationship between the driver module and the /dev filesystem entry. This is done by adding this file to /etc/modutils and running update-modules. The drivers are loaded by calling this script, which should be placed in /etc/init.d/ivtv, and links to it placed in the appropriate runlevel directories (/etc/rc3.d).

MySQL

MythTV relies heavily on the MySQL database for operation. You only need to install the MySQL database server on your master backend machine, but will need client libraries on all machines. MythTV uses MySQL v.4.

To setup the mysql database initially:

pushd mythtv-0.20.2/database
mysql < mc.sql

If you get an error like: ERROR 1045: Access denied for user: 'wad@localhost' (Using password: NO) you need grant yourself privileges:

sudo mysql -u root
mysql> grant all on *.* to 'wad'@'localhost' with grant option;
mysql> flush privileges;
mysql> quit

In a distributed system the front ends must be able to access this database remotely. I make no attempt to secure the SQL database at this time.

Achieving this may require several steps. The first (definitely required) is to tell MySQL to grant priviledges to outside users of the mythtv database:

mysql -u root mythconverg
mysql> grant all on mythconverg.* to mythtv@"192.168.1.%" identified by "mythtv";
mysql> flush privileges;

Most installations of MySQL make some attempt to default to a a semi-secure state by disallowing remote access. A second step is to enable this remote access. Look in the default configuration file (/etc/mysql/my.cnf in Debian) for some attempt to disallow remote access, like skip-networking, or bind-address localhost, and disable them.

Undeletable Recordings

One bug in earlier versions of MythTV (0.18.1 and earlier) was that it was impossible to delete recordings for which no accompanying file could be found. This can be fixed by directly manipulating the MythTV database as follows:

mysql -u mythtv -pmythtv mythconverg
mysql> select title, starttime, chanid from recorded;

Now, for each show that you want to delete, you might want to chant a more specific query:

mysql> select title, starttime from recorded where title = 'Arthur';  

Then delete the show using the program name and starttime to uniquely identify it:

mysql> delete from recorded where title = 'Arthur' and starttime = '2006-02-08 07:00:00';

Compiling MythTV

Now you've installed enough libraries and services to compile and run a limited version of MythTV (it won't have any frontend plugins or transcoding support.)

First, you need to set some environment variables (these commands are for the bash shell on Debian, YMMV):

export QTDIR="/usr/share/qt3"

Download and configure the mythtv source:

wget http://ftp.osuosl.org/pub/mythtv/mythtv-0.20.2.tar.bz2
tar xfj mythtv-0.20.2.tar.bz2
pushd mythtv-0.20.2
./configure

If your video card supports it, you probably want to synchronize your video drawing to the vertical retrace of your display. This is specified using the --enable-opengl-vsync flag to configure.

If you are ready to use a remote control with native LIRC support, also specify --enable-lirc to configure.

qmake mythtv.pro
make; sudo make install

At this point, install the myththemes package:

wget http://ftp.osuosl.org/pub/mythtv/myththemes-0.20.2.tar.bz2
tar xfj myththemes-0.20.2.tar.bz2
pushd myththemes-0.20.2
./configure
qmake myththemes.pro
sudo make install

Initial Setup and Operation

At this point you are ready to go. You just need to configure the system and initialize the program guide information.

Make sure to create the media storage directories needed by MythTV (/storage/video/ and /storage/livebuffer are what I use). I'm sure they don't have to be world-writeable at this point, but I don't care enough to figure out who needs write permissions...

mkdir /storage/video /storage/livebuffer
sudo chmod a+w /storage/video/ /storage/livebuffer

Then run mythtv-setup and go through each top level menu item in turn. If setting up anything more than a standalone system, you will need to set the IP address of the master backend server. You will need to describe your video hardware (IVTV must be up and running), and configure the program guide fetch (you must have registered with Zap2it.)

mythtv-setup

Note: You should re-run mythtv-setup after changing PVR cards. The system may not detect the change in hardware, but will nevertheless not function properly (e.g. it won't be able to change channels). When running it, delete all existing video cards, then add them back. You will then have to re-establish the input connections between program info and card inputs. You can run mythtv-setup at any time --- it doesn't have any side-effects injurous to a working system --- although you must ensure that the backend server isn't running at the time.

If you haven't run MythTV recently on this system, after running mythtv-setup you should download the latest program guide information. This is done by running mythfilldatabase.

mythfilldatabase

You should now start the backend server:

sudo /etc/init.d/mythtvbackend start

Now start the front end:

mythfrontend

Enjoy!

Getting Composite/S-Video Out

While VGA output from your MythTV clients is fine if you have a newer flat panel TV, composite or S-video output allows you to keep using your old TV, and dump videos to VCR (although at current hard drive prices, a two-hour movie encoded with MPEG2 at high quality (640x480,4Mb/s) costs slightly more than a dollar to store, beating VHS tapes in price !)

If using a graphics card with an nVidia chip, simply follow the directions on their web site to get configure the main display for NTSC. My X config file is an example.

Another approach if using an nVidia system is the nVidia TV Out software project.

IR Remote Control

The first remote control I used was an IR keyboard/trackball combo, which just plugs into the existing keyboard and mouse ports on the client machine and isn't too bad... This is a description of what it took to get a "real" IR remote control working.

Installing LIRC

Installing the Linux Infrared Remote Control (LIRC) package using Debian is a little frustrating right now, as it doesn't work with 2.6 kernels. We go ahead and do it, however, as "installing" it will mark that it is installed and performs a number of tasks for us:

sudo apt-get install lirc lirc-modules-source

The configuration process triggered by installing lirc-modules-source will ask you if you want it to compile the source. Say "no". If you say yes, it will repeatedly tell you that you don't have a valid kernel source tree installed, even if you just comipled and installed the kernel! That package is for a 2.4 kernel. (See http://ubuntuforums.org/archive/index.php/t-20952.html for typical experiences.) If you want to re-run the configuration process again, just use dpkg-reconfigure

Now it is time to download the real source and compile it. Note: Make sure to install the Debian lirc package as indicated above before doing this.

wget http://umn.dl.sourceforge.net/sourceforge/lirc/lirc-0.8.0.tar.bz2
tar xfj lirc-0.8.0.tar.bz2
pushd lirc-0.8.0
./configure

There is a nice configuration dialog where you select the appropriate hardware drivers and configure the software. If using the Hauppauge Remote Control, you will need to change the Driver to be "Hauppauge TV Card"; and under "Software Configuration" you will probably want to redirect log messages to syslog. I recommend reading the Installation Guide, then:

make
sudo make install

If for some reason you didn't install the Debian LIRC package first, you might run into a error when compiling MythTV with --enable-lirc. (I think the following command might help get out of this situation, but my notes are a little vague at this point... Don't run it if you aren't having problems !)

sudo rm /usr/lib/liblirc_client*

The driver module for the Hauppauge PVR-250 modules is lirc-i2c

You should now be able to manually load the appropriate lirc driver:

sudo modprobe lirc-i2c

Note: If you have upgraded your kernel, be sure to either make clean or delete the lirc build directory and start fresh.

lircd

lircd is a daemon that interprets the serial signal arriving from the IR sensor and translates it into a command. You will need to configure it with information about your remote. The configuration file is at /etc/lirc/lircd.conf. and the best place to obtain the proper one for your remote is repository at lirc.org. I use this file which supports all Hauppauge remotes in a consistent manner.

wget http://watlington.homelinux.org:8000/wad/mythtv/lircd.conf
sudo mv lircd.conf /etc/lirc/lircd.conf

Some older versions of LIRC keep their config files in /etc instead of /etc/lirc.

You will need to arrange for automatic startup of lirc and a related daemon, lircmd. If you installed the Debian package (see above), this should be taken care of. Look for links to /etc/init.d/lirc in /etc/rc3.d.

You can get lircd to reload its configuration file by typing:

sudo /etc/init.d/lirc reload

Configuring MythTV and MPlayer for your Remote

There are two ways of driving MythTV with the signals from the remote. The first is to use irxevent, which translates the incoming commands into X events. The second is to take advantage of the fact that MythTV and MPlayer now natively supports LIRC, and tell them how to interpret the incoming remote control keypresses. I use this latter method.

First, you should go back and reconfigure and recompile mythtv with --enable-lirc. You will also need to reconfigure MPlayer (it should automatically detect the LIRC installation) then recompile and reinstall it.

Second, you need to install a configuration file mapping your remote keys to MythTV commands in the home directory of any user running mythfrontend.

pushd ~
wget http://watlington.homelinux.org:8000/wad/mythtv/lircrc
mv lircrc .mythtv/lircrc
ln -s .mythtv/lircrc .lircrc

MythTV looks for its remote control configuration file at ~/.mythtv/lircrc, but MPlayer looks for it at ~/.lircrc. As shown, I use a single configuration file and make a link to it for MPlayer to find.

IR Sensors

You can build your own IR receiver, or use one provided through the PVR-250 cards.

You can find information about configuring LIRC to support your homebrew hardware in /usr/share/doc/lirc/html/configure.html, after installing the code.

lircc

Previously, in order to control mplayer (or any other video player you use for MythVideo) with a remote, you needed to install lirccd. This no longer appears to be necessary!

Device File Wrangling

The following instructions were needed for earlier kernels, but newer ones (at least 2.6.14 and newer) don't need these steps.

If using udev You will need to copy the appropriate rules into the udev config directory:

sudo cp contrib/lirc.rules /etc/udev/rules.d/

If not using udev If you are using a normal /dev filesystem, you will probably need to change the permissions of the device driver:

sudo chmod a+rw /dev/lirc

Next, you will need to add the following declaration to any file in /etc/modutils, possibly the lirc file installed by the debian package, so that the module can be found:

alias char-major-61 lirc-i2c

After you add this, you need to run sudo update-modules to incorporate your new declarations into the /etc/modules.conf file.

Automatically Starting the Backend

The MythTV backend should be started automatically when a mediaserver (or client/slave server) is turned on. This is done with a startup script. On a debian system, this script should be placed in /etc/init.d/mythtvbackend, and links to it placed in the appropriate runlevel directories (/etc/rc3.d on my systems --- I like to keep runlevel two as an TTY interface, server-free, maintenance level, with runlevel three being the normal one.) ).

Host specific definitions may be placed in /etc/default/mythtv. See the startup script for details.

You can easily manually start/stop the backend using the script (which must be run as root.) The options to the script are:

start
Starts the MythTV back-end server running.
stop
Stops the MythTV back-end server.
restart
Stops, then restarts the MythTV back-end server.
status
Reports the status of the MythTV back-end server.

Note: It is important that the user as whom the mythtvbackend (or mtd) daemon is being run has a valid MythTV configuration for your system. This isn't as important on the master server, but on slave servers you might need to copy your configuration into root's home directory (after you do the initial configuration!):

sudo cp -r ~/.mythtv ~root/

The symptoms of this being necessary are that the daemon refuses to start upon reboot, with an error message as shown below (or none, in the case of the mtd daemon, which obtains its log information from the configuration) when it starts fine manually.

2005-08-17 22:02:26.930 Unable to connect to database!
2005-08-17 22:02:26.931 Driver error was [1/2002]:
QMYSQL3: Unable to connect
Database error was:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
2005-08-17 22:02:26.932 Failed to init MythContext, exiting.

Optional Codec libraries for Transcoding

The following are a number of libraries, which while not required for an outstanding MythTV experience, help minimize disk usage....

One alternative to compiling all these packages is to attempt downloading the versions provided by Christian Marillat at: http://debian.video.free.fr ( Mirror, Mirror ). If you try this and it works well for you, send me your directions and I will post them. I've used M. Marillat's Debian repository in the past with OK results --- I now want to be have more control over my installation.

What I did do was write a script to automate the installation of the codecs, MPlayer and transpose, since it can get pretty tedious. This script will install all the codecs listed below, with the exception of faad. You can provide it with the software packages it needs, or let it fetch them over the net. You will need to manually install the faad2 library first, then you can let this script do the rest. If the install_codecs script completes succesfully you can skip to compiling the MythTV plugins.

faad2

The Freeware Advanced Audio Decoder and Coder libraries are needed for FFmpeg (hence transcode) to support MP4. Get them from http://www.audiocoding.com.

faad2 requires some work to get it to compile, due to confusing errors caused by it being in DOS text file format. I suggest:

wget http://umn.dl.sourceforge.net/sourceforge/faac/faad2-2.0.zip
unzip faad2-2.0.zip; pushd faad2
for i in `find . -type f`; do mv $i $i~; tr -d '\r' < $i~  > $i; rm $i~; done

At this point, remove the build commands for an rpm out of faad2/Makefile.am (or fetch the example). Then configure and build the library as shown below. (BTW, this is a very broken way to use the automake and autoconf tools. End users shouldn't have to install them !)

wget http://watlington.homelinux.org:8000/wad/mythtv/Makefile.am.faad2-2.0.txt
mv Makefile.am.faad2-2.0.txt Makefile.am
aclocal -I .
autoheader
libtoolize --automake --copy
automake --add-missing --copy
autoconf
./configure --with-mp4v2
make
sudo make install

Ignore any errors from automake about source file 'foo.h' is in subdirectory. (See Davesource for another example compilation, including xmms, but note that his DOS format fix doesn't work.)

If you are building mythmusic, you will need to fix a problem with the faad2 installer:

sudo cp faad2/common/mp4ff/mp4ff_int_types.h /usr/local/include/

faac

faac has the same problem with DOS text file format, but since it doesn't generate actual errors upon compilation, it is handled by the codec install script.

You can manually install, unpack and compile it using:

wget http://umn.dl.sourceforge.net/sourceforge/faac/faac-1.24.zip
unzip faac-1.24.zip; pushd faac
for i in `find . -type f`; do mv $i $i~; tr -d '\r' < $i~  > $i; rm $i~; done
chmod a+x bootstrap; ./bootstrap
./configure
make
sudo make install

Ogg and Vorbis

MythMusic (and Transcode) support the Vorbis codecs. You will need to download tarballs for libvorbis, libogg, and libao:

wget http://downloads.xiph.org/releases/ao/libao-0.8.6.tar.gz
wget http://www.vorbis.com/files/1.0.1/unix/libogg-1.1.tar.gz
wget http://www.vorbis.com/files/1.0.1/unix/libvorbis-1.0.1.tar.gz

Compile them manually. They compile fine using the normal:

./configure
make
sudo make install

Theora

Transcode supports the Theora video codecs. You might want to download and install libtheora :

wget http://downloads.xiph.org/releases/theora/libtheora-1.0alpha5.tar.bz2
tar xfj libtheora-1.0alpha5.tar.bz2
pushd libtheora-1.0alpha5
./configure
make
sudo make install

DTS

What is DTS ? It is an audio codec which I just encountered (11/05) on three different DVDs I was moving to hard disk. mplayer (and some consumer DVD players) don't have any audio during playback, and dvd::rip just hangs. Look for the dts logo!

The good news is that transcode and mplayer both support the DTS Coherent Acoustics codec. The open source libdts used has been legally attacked by DTS, Inc. (partially owned by Steven Spielberg). It changed it's name to libdca, and was unavailable for some time but is now available for download again. It is also part of the debian distribution. If you just encountered this problem, install the DTS library using:

sudo apt-get install libdts-dev

Then reconfigure and recompile both mplayer and transcode. If you have been following these directions, you installed it much earlier and it will automatically be configured in when you compile mplayer and transcode later.

Xvid

This is an open source MPEG4 Simple Video profile codec which I use for almost all video. It provides good results (in two-pass mode) at bitrates of 700 - 1400 kbits/sec.

Install and compile it using the Debian model:

wget http://downloads.xvid.org/downloads/xvidcore-1.1.0-beta2.tar.bz2
tar xfj xvidcore-1.1.0-beta2.tar.bz2
pushd xvidcore-1.1.0-beta2
dpkg-buildpackage -rfakeroot
sudo dpkg -i ../libxvidcore4_1.1.0-0beta2_i386.deb
sudo dpkg -i ../libxvidcore4-dev_1.1.0-0beta2_i386.deb

Unless you've done this before, you will probably need to install the following Debian packages:

sudo apt-get install debhelper fakeroot nasm

NOTE: (2/23/06) If you are using GCC 4.0 as your default compiler, you need to use the .final version of this library. Unfortunately, it doesn't include the debian build directory. You can copy the debian directory from a beta release, making sure to add an entry in the changelog reflecting the different version (example new changelog).

Here's a kludgy script for doing the aforementioned:

wget http://downloads.xvid.org/downloads/xvidcore-1.1.0-beta2.tar.bz2
wget http://downloads.xvid.org/downloads/xvidcore-1.1.0.tar.bz2
tar xfj xvidcore-1.1.0-beta2.tar.bz2
tar xfj xvidcore-1.1.0.tar.bz2
pushd xvidcore-1.1.0
cp -r ../xvidcore-1.1.0-beta2/debian .
wget http://watlington.homelinux.org:8000/wad/mythtv/xvidcore_changelog_1.1.0.txt
mv xvidcore_changelog_1.1.0.txt debian/changelog
dpkg-buildpackage -rfakeroot
sudo dpkg -i ../libxvidcore4_1.1.0-1_i386.deb
sudo dpkg -i ../libxvidcore4-dev_1.1.0-1_i386.deb

AVIFile

This is a library which allows you to read/write files using the overused M$ avi file format.

The 0.7.45 release requires gcc 4.0 or above, while an earlier 0.7.43 release works fine with gcc 3.3.

wget http://umn.dl.sourceforge.net/sourceforge/avifile/avifile-0.7-0.7.45.tar.bz2
tar xfj avifile-0.7-0.7.45.tar.bz2
pushd avifile-0.7-0.7.45
#  Not necessary with 0.7.45
# ./autogen.sh
./configure
make
sudo make install

You will probably need to install the following debian packages:

sudo apt-get install libsdl1.2-dev

FFMpeg

There are many ways of obtaining the FFmpeg libraries, such as mplayer, or directly from CVS. One reasonable approach is to download them from Sourceforge:

wget http://umn.dl.sourceforge.net/sourceforge/ffmpeg/ffmpeg-0.4.9-pre1.tar.gz

After configuring it, make sure to check for errors ! You will need to manually install the libavcodec library, it is not installed by the top level makefile. Configure, compile, and install FFmpeg with commands like:

./configure --enable-shared --enable-pthreads \
  --enable-libvorbis --enable-libogg --enable-libtheora \
  --enable-libmp3lame --enable-libfaac --enable-libfaad --enable-gpl

for the latest version checked out from subversion, or

./configure --enable-shared --enable-pthreads \
            --enable-vorbis --enable-mp3lame \
            --enable-faac --enable-faad --enable-gpl

for version 0.4.9pre1. In both cases, follow with:

make
sudo make install
pushd libavcodec; sudo make install
pushd ../libavformat; sudo make install

libmpeg2

Download the latest tarball for mpeg2dec, and install it using the usual ./configure, make, and sudo make install routine. It installs libmpeg2 as a side effect.

Note: This is probably a good time to point out that some of the software packages being installed do not properly install themselves for the debian default pkg-config installation. Copy the .pc files for libao (ao.pc) and libmpeg2 (libmpeg2*.pc) from /usr/local/lib/pkgconfig to /usr/lib/pkgconfig to correct the problem.

Recent versions of transcode

A recent version of transcode (1.0.2) has problems compiling against the CVS version of FFMpeg. This is due to it needing the pkg-config information but being unable to find it as transcode uses obsolete package names and version defines. Copy libavformat.pc into FFMpeg.pc (adding -lavutil to the libraries), and libmpeg2.pc into mpeg2dec.pc. You will also need to add:

#define FFMPEG_VERSION "0.4.9pre1 build xx.xx.xx"

to ffmpeg/avcodec.h

libdv

This is an open-source DV codec used by libquicktime and transcode. Download and compile it using:

wget http://umn.dl.sourceforge.net/sourceforge/libdv/libdv-0.104.tar.gz
tar xfz libdv-0.104.tar.gz; pushd libdv-0.104
./configure
make
sudo make install

In order for other software to auto-detect the libdv installation, copy the libdv.pc file from /usr/local/lib/pkgconfig to /usr/lib/pkgconfig after installation:

sudo cp /usr/local/lib/pkgconfig/libdv.pc /usr/lib/pkgconfig/

LibquickTime

This library provides support for the quicktime format, using a number of codecs which we have already compiled up !

You will need to make sure you have the development version of the libxaw package (libxaw6-dev) installed.

wget http://umn.dl.sourceforge.net/sourceforge/libquicktime/libquicktime-0.9.10.tar.gz
tar xfz libquicktime-0.9.10.tar.gz; pushd libquicktime-0.9.10
./configure
make
sudo make install

I tried and tried to get libquicktime to recognize the libavcodec installation, and haven't succeeded yet. I got closest by adding this file as /usr/lib/pkgconfig/avcodec_acl.pc.

In order for other software to auto-detect the libquicktime installation in some installations, it was necessary to copy the pkgconfig configuration:

sudo cp /usr/local/lib/pkgconfig/libquicktime.pc /usr/lib/pkgconfig/

MJPEGTools

These are used by transcode. Install it using the regular routine:

wget http://umn.dl.sourceforge.net/sourceforge/mjpeg/mjpegtools-1.6.3-rc2.tar.gz
tar xfz mjpegtools-1.6.3-rc2.tar.gz; pushd mjpegtools-1.6.3-rc2
./configure
make
sudo make install

And in order for other software to auto-detect the mjpegtools installation:

sudo cp /usr/local/lib/pkgconfig/mjpegtools.pc /usr/lib/pkgconfig

If using a newer version of the quicktime libraries, you will have to fix a problem in the released versions of mjpegtools/lavtools, which gives an error of "dereferencing pointer to incomplete type" in file lav_io.c around line 1370 or so. You should change the offending reference to:

#ifdef HAVE_LIBQUICKTIME
        case 'q':
                res = lqt_fileno((quicktime_t *)lav_file->qt_fd);
                break;
#endif

Ogle

Ogle is a standalone open source DVD reader, which includes support for interpreting the DVD menus ! What we really need here is the dvdread library, but we might as well pull down Ogle, it comes from the same folks. Since we are running Debian, we can directly install it:

sudo apt-get install ogle-mmx libdvdread3-dev

Make sure that you and mythtv (and anyone else you like) is a member of the cdrom group (edit /etc/group). You will have to exit and start a new shell (terminal window) for the changes to /etc/group to take effect.

If you aren't running udev, you will have to change the group on your DVD-ROM device (if connected using IDE, it will be something like /dev/hdc, or /dev/hdb) to cdrom. You will also need to manually make a symlink between /dev/dvd and the real device:

sudo chgrp cdrom /dev/hdc
sudo ln -s /dev/hdc /dev/dvd

You might want to install and run regionset to make sure that your region has been set. If it hasn't, the DVD library will fail.

sudo apt-get install regionset
regionset

You can test that Ogle (and your DVD ROM subsystem) is working by inserting a DVD into your drive and running it:

ogle

Finally, you will need to configure each frontend to use Ogle as its DVD player. This is done from within mythfrontend.

Transcode

This feature, so useful to have, requires a fair amount of compiling. Download the actual transcode source from here. Prerequisites include FFMpeg and libmpeg2.

If you want the quicktime codecs supported, you will need to add a link:

ln -s /usr/local/include/lqt /usr/local/include/quicktime
wget http://www.kraymer.mynetcologne.de/transcode-1.0.2.tar.gz
tar xfz transcode-1.0.2.tar.gz; pushd transcode-1.0.2
./configure --enable-v4l --enable-sdl --enable-oss \
            --enable-ogg --enable-vorbis --enable-theora \
	    --enable-libxml2 --enable-imagemagick --enable-freetype2 --enable-gtk \
	    --enable-libdv --enable-avifile --enable-mjpegtools \
	    --enable-libquicktime \
            --with-libquicktime-includes=/usr/local/include/quicktime \
            --with-libquicktime-libs=/usr/local/lib

make
sudo make install

Now that you've got transcode compiled and installed, you might want to use it for something other than MythTV. The Wiki is THE documentation. You can download a static version for offline access. There is also an online version of the man page, which is the best description of the command line arguments.

MPlayer

MPlayer is the original movie player for Linux. Due to its ignoring any intellectual property claims on codecs it cannot be distributed by the Debian organization. While precompiled versions exist for Debian, I recommend downloading and compiling the latest source:

wget ftp://ftp5.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc1.tar.bz2
tar xfj MPlayer-1.0rc1.tar.bz2; pushd MPlayer-1.0rc1
./configure
make; sudo make install

MPlayer's configuration script is pretty good at figuring out what you have already installed and using it. You will, however, want to download two additional software packages: some binary Windows codecs (only useful on x86 platforms, for oddball Windows-only movie formats):

wget ftp://ftp5.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
pushd /usr/local/lib/
sudo tar xfj /opt/mythtv/essential-20061022.tar.bz2
sudo mv essential-20061022 codecs

and the onscreen fonts used (you can choose a size different than the 18pt one selected here):

wget http://ftp5.mplayerhq.hu/mplayer/releases/fonts/font-arial-iso-8859-1.tar.bz2
tar xfj font-arial-iso-8859-1.tar.bz2
sudo mkdir -p /usr/local/share/mplayer/font
sudo cp -r font-arial-iso-8859-1/font-arial-18-iso-8859-1 /usr/local/share/mplayer/font

If upgrading from an earlier version of MPlayer, be aware that the font format has changed and you will need to download new ones.

Skins for the GUI are now available, if you use MPlayer outside of MythTV.

RTC

If you are getting an warning message when you run MPlayer along the lines of "Failed to open /dev/rtc: No such file or directory", then you need to check the Linux Real-Time Clock kernel module. This is not loaded automatically, if not compiled directly into the kernel, requiring you to add it to /etc/modules.

Once you do have the RTC module loading, MPlayer might respond with an error message like, "Linux RTC init error in ioctl (rtc_irqp_set 1024): Permission denied". You can fix this by adding a file containing the following command to /etc/init.d, and linking to it from /etc/rcS.d.

echo 1024 > /proc/sys/dev/rtc/max-user-freq

or

wget http://watlington.homelinux.org:8000/wad/mythtv/rtc
sudo mv rtc /etc/init.d/rtc
sudo chmod a+x /etc/init.d/rtc
pushd /etc/rcS.d
sudo ln -s ../init.d/rtc S56rtc

Compiling MythTV Plug-Ins

Now you've installed enough libraries and services to compile and run a a full version of MythTV.

wget http://ftp.osuosl.org/pub/mythtv/mythplugins-0.20.2.tar.bz2
tar xfj mythplugins-0.20.2.tar.bz2
pushd mythplugins-0.20.2
./configure --disable-all --enable-transcode --enable-opengl \
            --enable-mythdvd --enable-mythvideo \
	    --enable-mythmusic --enable-fftw --enable-aac --enable-sdl \
	    --enable-mythgallery --enable-exif \
            --enable-mythgame

After running configure with whatever options you, just:

qmake mythplugins.pro
make; sudo make install

Beware ! I've yet to figure out how to remove plugins after configuring and installing them once.

There are also a number of unofficial plugins, not included in the official Myth plugins tarball.

MythVideo

MythVideo is a must-have, due to MythTV's native inability to play video recorded elsewhere (in its designer's defense, this also makes it much, much easier to install !). MythVideo simply hands over the playback of the video file to a helper application such as MPlayer or Xine. If you've succesfully run the codec install script, MythVideo should just work, using MPlayer.

The best documentation for MythVideo seems to be the README file accompanying the source code.

You will need to create directories in which to store your movies and associated metadata (images and subtitles). Unfortunately, the metadata must be stored separately to avoid MythVideo assuming that it is a video file. I use /storage/library for the movies and /storage/movieposters and /storage/subtitles for the metatdata. The first two of these directories need to be specified in the MythVideo management interface.

Note that the helper application (MPlayer or Xine) must be separately configured to use an IR remote. This is already handled by the forementioned lircd configuration files.

If you have trouble fetching information from IMDB, make sure that you have the following libraries installed:

sudo apt-get install libxml-simple-perl libwww-perl

A frequent problem (40% of our DVDs) is the lack of a movie poster on IMDB. My work-around is to look up the DVD on Amazon, save the larger version of the DVD cover image and crop it to produce a "movie poster".

Subtitles are handled by specifying a complete command line to be executed in the "Player commands" parameter (this is a pain!) For example:

mplayer -zoom -fs -vobsub /storage/subtitles/Blue /storage/library/Drama/Blue.avi

MythDVD

MythDVD is used to both play a DVD and rip a DVD for later viewing with MythVideo. It relies on a "helper" program for both of these functionalities.

Note:You must have MythVideo installed in order to use MythDVD

MythGame

MythGame is a front-end for MAME, which includes simulators for both a large number of arcade games and some Ninetendo games. You have to install the MAME software, then obtain the ROMs from other locations and install them yourself.

Still working on getting this one working.

MythWeb

MythWeb provides a web-based interface for scheduling recordings and managing your system. It is surprisingly useful and much more friendly than the MythTV interface designed for remote use. For example, it allows you a way to edit movie descriptions, or perform complex searches through the upcoming programs.

Warning: No one claims that MythWeb is secure enough for use on the open internet. Use with care! I recommend using ssh tunneling to access it remotely, using something like:

ssh your_gateway -L 7999:your_mediaserver:80

Infrastructure

To install MythWeb, you will need recent version of both Apache and PHP. Thankfully, these are provided by Debian:

sudo apt-get install apache2 php4 php4-mysql php4-cgi

Be careful when installing php4-mysql. It depends on v5.0 of the mysql-common package, which seems to work fine with mysql v.4, but will try to upgrade your /etc/mysql/my.cnf file to one incompatible with v.4. When prompted whether to overwrite /etc/mysql/my.cnf or to keep the installed version, keep the installed version.

Web Server Configuration

You should edit /etc/apache2/apache2.conf to add the following near the end of the file:

<Directory /var/www/mythweb/>
  AllowOverride All
  Options +ExecCGI
  Options +Includes
  Order allow,deny
  Allow from all
</Directory>

You probably want to add a ServerName declaration to apache2.conf as well:

ServerName "your-hostname"

If you are taking your chances on the open Internet (not something I recommend, I am looking into proxiing the SQL lookups through my firewall to my home media server) you can use something like the following. It allows password free access from some internal networks, and allows the use of a .htaccess file to control password access.

<Directory /var/www/mythweb/>
  AllowOverride All
  Options +ExecCGI
  Options +Includes
  Require valid-user
  Order allow,deny
  Allow from 192.168.0
  Allow from 172.24.0
  Allow from 172.16.0
  Satisfy any
</Directory>

Use the htpasswd command to setup a .htaccess file. See the man page for help.

Installation

Copy MythWeb into place (there is no compiling!):

sudo cp -r mythplugins-0.20.2/mythweb /var/www
sudo chgrp -R www-data /var/www/mythweb
sudo chmod -R a+w /var/www/mythweb

Configure Apache a little more, then restart it:

pushd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/rewrite.load rewrite.load
sudo /etc/init.d/apache2 reload

MythMusic

MythWeather

Unfortunately, MythWeather has been dropped from the default install as it no longer works. One of these days....

One of my favorite MythTV plugins is MythWeather. Be sure to try it --- it doesn't require any special libraries or extra configuration ! The Install Guide is also the best User's Guide available.

Myth Transcode Daemon

As of version 0.20, the Transcode Daemon is no longer a separate application.

The Myth Transcode Daemon (mtd) is used by a number of MythTV modules. As its name implies, it does conversions from one format to another. It is also used by MythDVD to rip the DVD.

You have already compiled up the daemon, but you need to test it and set it up to automatically start on machines hosting either a backend or frontend server. Try running it manually:

mtd -n

It should respond with some information, including a line like:

<time>: mtd is listening on port 2442

Once you get it to succesfully run manually, you should install a script in /etc/init.d, such as mythtranscode. and place links to it in the appropriate runlevel directories (/etc/rc3.d on my systems). You must make sure that the user the daemon runs as has a valid MythTV configuration

The Myth Transcode Daemon places it's log file (mtd.log) in the directory you specify for temporary storage of DVD files while they are being transcoded. (I tend to use /storage/dvdbuffer.)

MythGallery

Maintenance

OK. You've finally got everything that you want up and running, and configured to your liking. Unfortunately, Murphy's law has a way of intervening, identifying the components most critical to the operation of your finely tuned system and causing them to go "poof". How can you prepare for some of these eventualities ?

Disk Full ?

You might want to occasionally check to see if any server disk partitions are filling up (use the df command). Experience has shown, however, that the most common method of failure is a user configuration error which slowly fills up the main disk storage with shows which cannot be deleted, which then rapidly fills the partition containing /var with error messages about said disk full issue making the system unusable. The solution is to shut down mythtv, clean out the log files and delete one or two recordings. Then restart mythtv. It should run fine. Now go in and mark more shows (both recorded and yet-to-be recorded) as allowing auto-expire.

Database Backup

The User Manual has a section on periodic maintenance, where they mainly discuss how to back up the crucial information in your MythTV system: the SQL database. They don't discuss how to discard the 95% of this database which is useless (the guide info for upcoming weeks), but the remaining 5% is useful. Note that this doesn't do anything about saving the media files referenced by the database. It just maintains a lot of system state and your log of recorded shows for eliminating duplicates, etc.

The suggestion is to run a cron job (see my script) which periodically makes a backup copy of the SQL database and copies it to a remote server (rsync server, in my case).

The database could be reconstructed using the following commands: (mythsql_backup.sql is the saved SQL database dump, and the mc.sql file should come from the same version of MythTV that created the database --- even if that is not the version that will be using it!)

mysql -u root -e "drop database mythconverg;"
mysql -u root < /opt/mythtv/mythtv-0.20.2/database/mc.sql
mysql -u root < mythsql_backup.sql

After reinstalling the database, you should probably run mythtv-setup.

Keep a backup disk

A complementary technique --- essential in my opinion, given the time invested in installing the OS, drivers, codecs, and supporting applications --- is to copy the system drive of the main server onto a backup drive. This backup drive should be in offline storage (to prevent destruction in case of catastrophic power surge.)