MythTV

This document explains how to configure MythTV, a free Linux application that turns a computer with the necessary hardware into a network streaming digital video recorder, a digital multimedia home entertainment system, or Home Theater Personal Computer. It can be considered as a free and open source alternative to TiVo or Windows Media Center. -- MythTV

MythTV consists of three parts:
 * 1) A MySQL database, which stores all settings, metadata, and temporary information
 * 2) A Back-End, which drives the video capture device to record shows and manage various other addons
 * 3) A Front-End, which is mainly a remote-control and viewer

Both parts can run on a single computer. However, the intent is for you to run a distributed system, with the back-end sitting on a server somewhere out of the way, and the front-end running on a small HTPC, another Linux desktop, or even an OSX or Windows machine. More in depth information can be found on the executive overview.

MythTV Versions
This guide applies to the following versions of the software:

Prerequisites
Hardware:
 * Configured network adapter (gigabit recommended)
 * A video capture device (Supported Cards)
 * A sound card (not required to record)
 * A supported IR capture device and a remote control of your choice (front-end only)
 * Decent video adapter - nVidia is recommended

Software:
 * A working Gentoo installation
 * MySQL installed and configured, see Gentoo.org howto wiki
 * NTP
 * X.Org
 * Qt 4

Kernel config
As with any Gentoo install you will need to spend some time making sure the kernel is properly configured for your system. Obviously this is going to be largely specific to your hardware and choice of set up, however there are a few kernel config options worth pointing out:


 * If you want to watch DVDs you will need UDF file system support:

UDF_FS [=y] | -> File systems -> CD-ROM/DVD Filesystems


 * If you are installing IVTV-Utilities when using a x86_64-bit kernel, you will find that even though you've correctly selected all options as modules, it still gives you the "CONFIG_KMOD must be set" error. Basically, CONFIG_KMOD is responsible for automatic loading of modules, and it only applies to 32-bit kernels it seems (2.6.29.x series).

The easiest way to bypass this whole thing is to simply edit the kernel by hand and insert the line "CONFIG_KMOD=y", then emerge/build ivtv-utils, then go back and yank the line out.

Use flags
Before you do any more compiling it is a good thing to get your use flags set up correctly, this prevents you from having to re-compile things later on

The following command will display all the use flags you have in place, the total of your profile, the files(s), and your :

For example, here is a working example set of use flags for a MythTV front and back-end on Gentoo 2008:

USE="3dnow 3dnowext X a52 aac acl acpi alsa amd64 apache2 avahi berkdb bindist bluetooth branding bzip2 cairo cdb cddb cdparanoia cdr cli cracklib  crypt css cups daap dbus dri dts dvb dvd dvdr dvdread eds  emboss encode esd evo exif fam ffmpeg firefox flac fortran gdbm gif gpm  gstreamer gtk hal iconv ipv6 isdnlog java javascript joystick jpegldap  libnotify lirc latin1 lm_sensors mad mdnsresponder-compat midi mikmod mmx  mmxext mp3 mpeg mudflap multilib mysql ncurses nls nptl nptlonly  nsplugin ogg opengl openmp oss pam pcre pdf perl png posix ppds pppd  python qt3 qt3support qt4 quicktime readline reflection rss samba sdl  server session spell spl sqlite sse sse2 sse3 ssl startup-notification  svg sysfs tcpd tiff transcode truetype type1 unicode usb v4l vcd vorbis  wifi wma xcomposite xine xml xorg xv xvid xvmc zlib"

Set your profile to the Gentoo 2008 'Desktop' profile using eselect (emerge eselect if you don't have it installed):

These are the extra flags you would need in addition to the 'Desktop' profile to achieve the above:

You may wish to run this command after changing your profile and adding/removing useflags

This will re-build myth and your entire system with lots of useful features. It's probably worth taking this time to highlight a few individually:


 * Make sure you add this use flag if you plan on using the TV output on a PVR-350 card.


 * If you will be using any Firewire devices.


 * To support Direct Graphics Address.


 * To support the x264 free software library for encoding H.264/MPEG-4 AVC video streams.

MySQL
If you haven't already, emerge MySQL and then run mysql_install_db (via emerge --config), which will create a default database for you:

Follow the instructions on setting your MySQL root password and then start it:

Now run the following command:

Once you provide the password, you should see a mysql prompt:

Now issue the following to see a list of configured databases:

If you see this output, MySQL is running and ready:

Finally, tell MySQL to start on boot:

For more info check the MySQL Startup Guide

IVTV
The only thing you need to install is ivtv-utils. Please check the above link for instructions. Once installed, there is an easy test you can run to ensure that both IVTV and your video capture device is operational:

This changes the channel to channel #22 for us-cable:

You should see the following output if everything worked:

/dev/video0: 169.250 MHz (Signal Detected)

Of course your MHz may differ, depending on your cable provider.

There is one more test you can perform to see if your tuner actually works:

Once you issue the command, the prompt will just sit there while the device captures the signal directly to an mpeg file. After 30s or so, break the operation (Ctrl-C) and copy your file to a location where you can play it. It should your cable channel 22 with sound and video.

X.Org
MythTV backend requires X and Qt 4 for myth-setup to run. Outside of importing an existing setup from another system directly, there is currently no way around not having X.Org installed to properly configure and test Myth at this time. The mythtv-setup X application can be forwarded over SSH to a machine with a graphical frontend. This allows configurations with X installed locally on the mythbackend machine. You need to enable X Forwarding for this to work. The The reason for this is a common question of whether X is actually required.

This article will not go into details about how to configure X with your favorite video card driver. You must do this before attempting to configure Myth. You can test your setup by invoking X.Org and making sure your video driver works properly. You should consider installing OpenGL-version to speed things up! (this is not a hard requirement).

Installing MythTV via Portage
Adding the following to your package.keywords file will enable you to have the most recent version of MythTV:

Then run this command to install, you can add or remove various parts of MythTV if you wish:

Once complete, you need to set up inject the main database dump into MySQL:

Test to make sure the database made it ok (the password is mythtv):

mysql> show databases; ++ ++ ++ 3 rows in set (0.00 sec)
 * Database          |
 * information_schema |
 * mythconverg       |
 * test              |

Note the presence of the mythconverg database.

In case you wish to run your backend as mythtv, you need to add that user to the video group:

Installing XMLTV (Optional)
Now that the basics are complete and myth compiled and installed correctly, you are ready to install XMLTV. This is an external Perl-based set of packages that allow you to grab TV listings from an external source and inject them into the MythTV channel database. In US and Canada the TV listings are no longer free (as they used to be with Zap2It), so before you install this, be sure to spend the $20.00 and purchase a Schedules Direct annual subscription which works wonderfully with MythTV.

Again, there are 70 or so packages that will be installed. Albeit small, these still take some time.

Once XMLTV is installed, you are ready to fire up X and begin the basic configuration process.

Configuring MythTV Backend
Invoke X.Org as you (not root) and open a terminal window.

Issue the following command and follow the on-screen instructions:

This is the first screen you will see when you start the setup. You will need to go through each of the five options and carefully inspect each screen. At the risk of running a bit off topic, we'll take you through some of the setup options.

General
This section deals with the general setup of MythTV. There are some settings you must correct in order to get the system to work.


 * IP address: Set the field to your external IP address. Some setups require '127.0.0.1' set here to correctly start and connect to backend (while setting the external IP in the Master Server IP Address section below)
 * You can leave the ports alone. It is best not to change that.
 * Master Server IP address: Set to the same one as above.

''If you have DHCP set on your MythTV backend, this may cause issues for you. You are best to affix a static IP and key it in directly here''

Click next when complete.

This screen sets the directory where your recorded shows are stored. Make sure you select a place with at least 5 gigabytes of hard disk space available. Also, be sure to run the following command to set the group ownership to mythtv:


 * TV format: If you are in North America you want NTSC.
 * VBI format: None if you are not doing digital.
 * Channel frequency table: Again, if you are in North America, and have your tuner hooked up to a us-cable provider, you want us-cable.

You can leave all these as default.

You can leave all these as default.

Troubleshooting

 * 1) A working system suddenly got this messages: Error: No valid capture cards

The scheduler in 0.24 now has a sanity check that any properly configured system will have a capture device available at all times. The master backend must have such a device installed and configured, or else it will terminate. Completley tunerless systems existing only for video playback, and low power master backends with no local tuners, are not supported at this time.

Note that nearly all settings in the database are keyed off the system hostname. Should a user choose to change hostnames, the database backup utility offers the option to migrate all information from an old hostname to a new one.

Frontends

 * MythWeb