Next Previous Contents

9. Configuring MythTV.

By this point, all of the prerequisites have been installed, mysql is running and has had its initial database setup. It's now time to configure MythTV.

9.1 Configuring the master backend system.

Open a shell and decide where you will store your video files. By default, MythTV will assume that you will be using /mnt/store/, but if this directory doesn't exist, or it exists and you don't have write privileges to it then MythTV will fail when you attempt to make a recording. The following example is specific for /var/video, but the same instructions would apply if you want to keep the default but don't have the directory structure setup yet. See the Advanced Partition Formatting section for hints on creating a partition for MythTV.

If you create a /var/video subdirectory, change /mnt/store/ to /var/video/ in the setup screens.

$ su
# mkdir /var/video
# chmod a+rwx /var/video
# exit

The first thing to configure is the master backend system. If you are running multiple backend systems, the master backend will make all decisions about which programs will be recorded on which tuners. If you have only one backend, then it will be its own master.

The master will always choose the first available tuner in the same order as you add cards through "setup". In other words, the second card you add will only be used when there are two overlapping recordings, the third when there are three, and so on. Therefore, you will want to have your largest disk space on the master because the tuner on the master will always be the first choice. You will then want to add your other backends in the order of your preference for recording.

See Advanced Backend Configurations for information on configuring multiple backend systems in various ways.

Because MythTV now uses a database to store most configuration variables, part of the bootstrap of MythTV is to indicate the location of the MySQL database server. If the frontend, backend and MySQL database server are all going to be running on the same box, you can continue to the next step. If not, you'll need to edit the /usr/local/share/mythtv/mysql.txt file and change the first line to the IP address of the database server. All other configuration is within the MythTV GUI screens.

NOTE: Users that have been running the frontend and the backend on different machines using Red Hat Linux 8.0 have stated that they have been having issues with remote access to the MySQL database. The following instructions may or may not work. Add the following to /etc/my.cnf on the backend machine and restart MySQL.

skip-innodb
set-variable=thread_stack=256k

Switch to the setup directory and run the setup program:

$ cd setup
$ ./setup

The backend setup program will start and offer you a number of choices. It is strongly recommended that you go through them in order.

The first question will ask if you wish to clear out your existing configurations for your capture cards. Initially, you should say "YES" so that there are no surprises later.

The next question will ask you if you wish to clear out your video source information. You should answer "YES" to this as well.

Once the graphical setup starts, you'll see that there are four choices.

  1. General
  2. Capture Cards
  3. Video Sources
  4. Input Connections

Use the arrow keys to move around, and press the space bar to select which option you wish to configure.

General

The first screen of the General configuration deals with IP addresses of the system that you're running setup on and any master backend you may have. If you've only got one machine, then the default values are fine and you can move to the next page by pressing the space bar. If you need to move around the screen, use the arrow keys to move focus between settings, not the mouse.

If you will have multiple backends, then do not use the "127.0.0.1" IP address.

It is very strongly discouraged that you make any changes to the port settings from the defaults.

Once you're satisfied with the values, move the focus down to Next and hit the space bar.

The next screen details the Host-specific Backend setup. This is where you will set the specific directory paths for this particular backend. Make sure that you've followed the steps at the beginning of this section and created a directory that exists and that MythTV will have write privileges to. When you're done, press Next to continue, taking you to the Global Backend Setup.

On the Global Backend Setup configure your backend with the appropriate settings. Use the left and right arrow keys to iterate through the choices available on each setting, and the up and down keys to move between settings. Move to Finish when you're done and press the space bar, taking you back to the main configuration screen.

Capture Cards

You should have no capture cards defined, so the highlight will be on (New Capture Card). Press space to begin.

Choose the appropriate settings for your particular tuner. Use the arrow keys to move around and to make your choices, and press RETURN when complete. Pressing RETURN will take you back to the Capture Cards screen; if you have additional capture cards in this machine, press the space bar when the highlight is on the (New Capture Card) row to define another card. Once you have no additional cards to setup, press ESC.

Video Sources

When you start, the highlight should be on (New Video Source). Press the space bar to begin. The first field asks for the name of the video source. You may choose something easy to remember, like "Antenna" or "Cable". Once you've chosen a name, press the down arrow to move to the next field. If you're in North America, move to the Zip/postal code field and put in the appropriate value.

If you're outside of North America, then some manual interaction will be required with XMLTV.

NOTE: If you are in North America, and you enter your Zip/postal code and nothing seems to happen for a very very long time, it is possible that XMLTV is waiting for you to provide some input. Use ALT-TAB or whatever key combination your window manager uses to switch programs and look for a terminal window running XMLTV that may be waiting for input.

Once you have chosen your provider, press RETURN to continue. XMLTV will now begin collecting the initial data for your location. The screen may blank for a few seconds to several minutes, depending on the load of the listings provider and the speed of your connection to the Internet. Be patient!

You will then be returned to the Video Sources screen. If you have multiple video sources available, such as Antenna, Cable, etc, go ahead and define them all, even if they're not all going to be physically connected to the master backend server. Once you're done, press ESC to return to the main screen.

Input Connections

The final configuration item is Input Connections. On this screen, you will associate the various video sources you defined earlier with a physical input to a encoder card. It's entirely possible that you have multiple tuners, and each tuner has a different input, so on this screen you let MythTV know which device will connect to which input source.

When you start this screen, you should see a listing of the various input connections available on each of the Capture cards you defined earlier. For example, you may have a capture card with a tuner, a SVideo and a Composite connection. If you wanted to associate the tuner (a.k.a., "Television") with an "Antenna" source you defined in Video Sources, you would move to the /dev/videodevice (Television) -> line and press the space bar. Using the left and right arrow keys will show you the various choices you have already created for video source. In our case, you would use the left/right cursor keys until "Antenna" was shown in the Video Source field. Press down to move to the next setting, all of which should be self-explanatory.

Once you're done, press RETURN to go back to the Input Connections screen. You would then finish associating the video sources to any other hardware devices you have available.

NOTE: Don't add a video source to a hardware input if you don't actually have anything connected there. For example, adding "Cable" to the Tuner and to the Composite inputs without having something connected to Composite will lead to blank recordings.

Press ESC to return to the main menu, and press ESC again if you have no further items to configure, thereby returning you to the command line.

9.2 Post-configuration.

Run the mythfilldatabase program as directed. The master backend will obtain guide data for all the video sources you defined during setup.

Once mythfilldatabase has finished, start the master server before continuing.

$ mythbackend

mythbackend will print information about connections and what it's doing to the console. If you'd like to see the options that are available for mythbackend, type mythbackend -h for help.

As of 2003-10-03, the available options are:

$ mythbackend -h
Valid options are:
-l or --logfile filename       Writes STDERR and STDOUT messages to filename
-p or --pidfile filename       Write PID of mythbackend to filename
-d or --daemon                 Runs mythbackend as a daemon
-v or --verbose debug-level    Prints more information
                               Accepts any combination (separated by comma)
                               of all,none,quiet,record,playback,
                               channel,osd,file,schedule,network
--printexpire                  List of auto-expire programs
--printsched                   Upcoming scheduled programs

Running mythbackend as a daemon and using the logfile option will allow you to have mythbackend automatically start up during the boot process. For example, you may add this to your rc.local file, or you can follow the steps outlined in the section called I'd like to automatically start mythbackend at system boot time.

9.3 Configuring a non-master backend.

Configuration of a non-master backend follows the same general procedure as that of the master backend, with the exception that you skip over the "Video Sources" step. All possible video sources need to be defined on the master backend system; only the master backend will query a listings provider to obtain guide data for all the slave backends.

Make sure that the IP addresses on the General setup screen are accurate. If the slave backend can't communicate with the master backend due to IP address misconfiguration then MythTV will not function properly.

Ensure that you've granted access to the master MySQL database for remote backends as discussed in the section titled Modifying access to the MySQL database for multiple systems and that you've edited the /usr/local/share/mythtv/mysql.txt file and put the correct IP address for the database server.

NOTE: Do not run mythfilldatabase on a non-master backend.

9.4 Configuring and running mythfilldatabase.

NOTE: mythfilldatabase might take a while to complete, depending on any number of factors, most of which you can't control. It's best to just let the program run to completion.

mythfilldatabase --manual is another option; the manual option will allow you to fine tune channel frequencies and specify which channels will be added to the database. If you are not using the tv_grab_na grabber, you must use the --manual option.

mythfilldatabase --file is an option if there isn't an XMLTV grabber for your country, but you do have an XML formatted listings file created by some other program.

mythfilldatabase --xawchannels is an option if you have used xawtv to fine-tune your channels and would like to import the fine tuning offsets into MythTV.

Setting mythfilldatabase to run from cron

In order to keep your database filled, mythfilldatabase should be run once a day.

There are two ways to accomplish this: either as a user-based cron job, or as a system based cron. If you use a user-based cron, you can select the time that the cron job will be run. A system-based cron job will run at the same time as any other system cron jobs.

If you are a Mandrake 9.0 user and wish to use a system cron job, you can perform the following steps:

$ cd configfiles
$ su
# cp mythfilldatabasecron /etc/cron.daily

If you want to know what time your job will run, you can do the following:

# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root nice -n 19 run-parts /etc/cron.hourly
02 4 * * * root nice -n 19 run-parts /etc/cron.daily
22 4 * * 0 root nice -n 19 run-parts /etc/cron.weekly
42 4 1 * * root nice -n 19 run-parts /etc/cron.monthly
# exit
$ 
We can see from the display that the cron.daily job will run at 0402 every morning.

If you wish to specify a custom time, then the user-based cron job is the better method.

The default configfiles/mythcrontab file will run the mythfilldatabase program every day at 0430. Placing a copy of the default configfiles/mythcrontab into your ~/.mythtv directory will allow you to edit your copy and maintain the original if you get into trouble. To change the time used to start the mythfilldatabase process, open the ~/.mythtv/mythcrontab file in your favorite editor and modify it as you like. Once you're satisfied with the time that mythfilldatabase will run, save and exit, and return to the shell prompt.

$ cp ~/mythtv/configfiles/mythfilldatabasecron ~/.mythtv
$ cp ~/mythtv/configfiles/mythcrontab ~/.mythtv
$ cd ~/.mythtv
$ crontab mythcrontab
$ crontab -l  NOTE: this is a lowercase L.
# The following will run the mythfilldatabase shell script at 0430
# every day.  Format is
# minutes hour day_of_month month day_of_week
# man 5 crontab for more information
# Need to use a shell script because the QTDIR environment variable isn't
# being honored by crontab?
# The next text should be all on the same line.
30 04 * * * /bin/bash $HOME/.mythtv/mythfilldatabasecron
$ 

As you can see, mythfilldatabase will now be run at 0430 every day.

If you decide to alter the time that the mythfilldatabase runs, you can use the crontab command to open your existing job and edit it in place.

$ crontab -e

The crontab -e command will allow you to edit the existing crontab. NOTE: By default, the crontab will use vi as your editor. If you don't like to use vi, make sure that you've set VISUAL to something other than vi.

$ export VISUAL=/usr/bin/joe
$ crontab -e

This will cause crontab to use joe, a visual editor that uses the Wordstar command sequence. You may use emacs, or any other editor that you're comfortable with. You may also add the EXPORT command to your .bashrc or to the /etc/profile.d/mythtv.sh file.


Next Previous Contents