Next Previous Contents

9. Configuring MythTV.

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

NOTE: If you're running Debian unstable and you have compiled MythTV from source, you will need to install an additional package before you will be able to run MythTV. Execute the following to install the MySQL driver for QT.
$ su -
# apt-get install libqt3c102-mt-mysql
# exit

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 backend 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 the greatest amount of disk space on the Master backend because its tuner will always be the first choice. You will then want to add your other backends in the order of your preference for recording.

NOTE: It is possible to not have the cards on the Master backend be the first ones used. However, if you are new to MythTV it is easier to configure the Master backend first before moving on to the Slaves, at least until you become more familiar with the MythTV system. See Advanced Backend Configurations for information on configuring multiple backend systems in various ways.
Because MythTV now uses a database to store all 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 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 five choices.

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

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, or if your backend is on one system and you're running the frontend on another machine 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, change the grabber to "DataDirect", then continue pressing the down arrow to move to the next field. Fill in the username and password that you have established with DataDirect, then move to the "Retrieve Listings" button and press the space bar.

NOTE: You need wget version 1.9.1 or higher to use DataDirect.

The setup program will contact the Zap2It servers and get your account information. Once you're done, you may click the Finish button and skip the next few paragraphs in this document since they only apply to users that are using the external XMLTV script to get their guide data.

If you wish to continue using the XMLTV grabber, then 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.

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.

Channel Editor

The channel editor is used to globally alter channel information, including items like hue, contrast, finetuning and others. Users in North America shouldn't run the channel editor until after completing initial setup and running mythfilldatabase at least once to populate the database.

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.

NOTE: If you are using DataDirect and watching the output messages on the console or the log file it is normal to see a "401 Unauthorized" error followed by a "200 OK" when the connection to Zap2It is being established.

From : Sun Jun 13 05:00:00 2004 To : Mon Jun 14 05:00:00 2004 (UTC)
--02:58:01--
http://datadirect.webservices.zap2it.com/tvlistings/xtvdService
           => -'
Resolving datadirect.webservices.zap2it.com... 206.18.98.160
Connecting to datadirect.webservices.zap2it.com[206.18.98.160]:80...
connected.
HTTP request sent, awaiting response... 401 Unauthorized
Connecting to datadirect.webservices.zap2it.com[206.18.98.160]:80...
connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/xml]

    [    <=>                              ] 114,125       63.57K/s

02:58:03 (63.53 KB/s) - -' saved [114125]

Your subscription expires on 08/20/2004 12:00:00 AM
Grab complete.  Actual data from Sun Jun 13 05:00:00 2004 to Mon Jun 14
00:00:00 2004 (UTC)

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 Automatically starting mythbackend at system boot time.

9.3 Configuring a non-master backend

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.

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.

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 non-master backends.

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 --help will give a full listing of the options available.

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.

mythfilldatabase --refresh-today will only pull guide data for today (in case of late-breaking changes to the schedule).

Periodically running mythfilldatabase

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

There are three ways to accomplish this: use the built-in capability of MythTV to run the mythfilldatabase program, 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.

Using the built-in method.

To use MythTV's built-in capability, you'll need to run the mythfrontend Setup option. From the MythFrontend, enter the Setup>General screen and advance to "Mythfilldatabase", the fourth screen. Select the checkbox, then complete the options as you see fit. The mythbackend program will now run mythfilldatabase at the times you specify.

NOTE: Don't use the built-in and cron methods at the same time. If you switch to the native method, ensure that you've removed any user or system cron jobs that you may have been using.

Using the cron method.

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.

9.5 Grabbing channel icons for DataDirect users

While the DataDirect TV listings service has several advantages, it does not support grabbing logo icons for the stations you receive. However, there are utilities provided with MythTV which you may use to grab your initial set of icons and to keep them updated if your lineups change.

First, you need to generate or obtain an XML file with the information for your stations.

If you have XMLTV software installed, there is a perl script in MythTV's contrib/ directory which will generate this file for you. Run the command:

$ perl mkiconmap.pl

You will be asked for your zipcode and the service that you use. If there are no errors, the iconmap.xml file that you need for the next step will be created.

If you do not have XMLTV software installed and do not want to install it for the sake of this minor task, there is a generic contrib/master_iconmap.xml which you can copy and use but this may not be as complete as using the specific information for your service.

Once you have an iconmap.xml file, add the icon information to your database and grab any new icons with the command:

$ mythfilldatabase --import-icon-map iconmap.xml --update-icon-map


Next Previous Contents