Greg
Greg's MythTV on FreeBSD HOWTO page
Greg's home page
Greg's diary
HOWTO home
Greg's photos
Greg's links
Google
Status: Draft. This page is (hopefully) under construction. The sections in grey are known to be out of date and need correction.
I've spent an inordinate amount of time trying to set up MythTV, an application for watching TV on a computer running Linux or possibly FreeBSD. It seems that just about everybody who has installed MythTV has had significant problems, and my main concern is that I might install it, get it to work, and then have to go through the same pain next time I try to install it. This page is intended to remind me of the steps. It's mainly for my own reference, but it may help others.

Installing MythTV on FreeBSD

This is the easy part:
# cd /usr/ports/multimedia/mythtv
# make install

This installs a user mythtv if it doesn't exist, and gives it an unknown password. To use the user name, you must first set a password as root:

# passwd mythtv
Changing local password for mythtv
New Password:
Retype New Password:

You'll probably want to run a remote control as well. In this case, install lirc:

# cd /usr/ports/comms/lirc
# make install

I'll document how to set up lirc some other time.

Setup

  1. Set up audio if necessary. This is usually a matter of loading the correct kld for your audio hardware. In case of doubt,

    # kldload snd_driver
    
  2. >Install an analogue tuner that understands V4L. Currently (7 March 2007) this is only the unreleased pvrXXX driver for the Hauppauge PVR cards.

  3. Create a directory for storing video, and give it to user mythtv:

    # mkdir /spool/video
    # chown mythtv /spool/video
    # chmod 777 /spool/video
    

    I have my doubts about setting the permissions to 777, but that's what the MythTV HOWTO says.

  4. Ensure that all multimedia devices belong to mythtv after boot.
  5. Installing the MythTV port also installs MySQL if necessary and installs the MythTV database, mythconverg. It sets permissions for the user mysql@localhost to access mythconverg. The password is mythtv. If you're going to access the database via the network (even from the same system), you'll need additional permissions. For each system that wants to access the server,
    mysql> GRANT ALL ON mythconverg.* TO mythtv@cvr.example.com IDENTIFIED BY "different-password";
    Query OK, 0 rows affected (0.35 sec)
    
    mysql> GRANT CREATE TEMPORARY TABLES ON mythconverg.* TO mythtv@cvr.example.com
           IDENTIFIED BY "different-password";
    Query OK, 0 rows affected (0.03 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.02 sec)
    
    

    For the sake of security, don't use the default password mythtv here.

  6. Run mythtvsetup, which has its own quirks:
    • It doesn't seem to like displaying on displays with a resolution of higher than 1280x1024; it drives the colours crazy.
    • It's very slow. On my 1.8 GHz machine it uses about 30 seconds of CPU time before it does anything useful, and just about any cursor movement takes seconds.
    Using it is supposed to be self-explanatory. Here are some explanations:
    • The cursor works, but is invisible. If you're a real mouse addict, you may still be able to work out where the cursor is. After you've got mythfrontend running, you can select to display the cursor in the settings.
    • The area towards the bottom sometimes displays a text explaining the field with focus. The test is frequently truncated.
    • You will be positioned on the bottom line of each menu page. Right arrow moves left, left arrow moves right. The highlighted box is the slightly brighter one.
    • In the "Global Backend Setup", select “TV format” by moving the cursor until the text on the bottom line reads “The TV standard to use for viewing TV”. This means that the top line (“TV format”) has focus. Don't hit Enter! If you have PAL-BG, like most of the world, decide whether to select PAL or PAL-BG..
    • In VBI format, select “PAL Teletext” if any channel in your area offers it. Presumably you would select NTSC Closed Caption if you use NTSC.
    • In Capture Card Setup, make sure to set the Default Input field, which on my system was set to S-Video 0. It's easy to miss this one, since it doesn't get highlighted. You select this one with the left and right arrows. For a tuner, select Tuner0
  7. This section needs revision

    When you've got this far, exit mythtv-setup, start the server, then run mythfilldatabase:

    === mythtv@tv2 (/dev/ttyp4) ~ 9 -> mythbackend &
    [1] 2225
    2007-02-27 15:27:36.001 Using runtime prefix = /usr/local
    2007-02-27 15:27:36.285 New DB connection, total: 1
    2007-02-27 15:27:36.320 Connected to database 'mythconverg' at host: localhost
    2007-02-27 15:27:36.342 Current Schema Version: 1158
    Starting up as the master server.
    2007-02-27 15:27:36.378 New DB connection, total: 2
    2007-02-27 15:27:36.381 Connected to database 'mythconverg' at host: localhost
    2007-02-27 15:27:36.421 EITHelper: localtime offset 10:30:00
    2007-02-27 15:27:36.446 TVRec(2) Error: Start channel invalid, setting to '0' on input Tuner 0 instead.
    2007-02-27 15:27:36.466 Channel(/dev/cxm0)::Open(): Can't open video device, error "No such file or directory"
    ERROR: no valid capture cards are defined in the database.
    Perhaps you should read the installation instructions?
    2007-02-27 15:27:36.481 Main::Starting HttpServer
    2007-02-27 15:27:36.498 Main::Registering HttpStatus Extension
    2007-02-27 15:27:36.945 mythbackend version: 0.20.20060828-3 www.mythtv.org
    2007-02-27 15:27:37.098 Enabled verbose msgs:  important general
    2007-02-27 15:27:37.102 AutoExpire: Found 0 recorders w/max rate of 0 MiB/min
    2007-02-27 15:27:37.106 AutoExpire: Required Free Space: 0.0 GB w/freq: 10 min
    === mythtv@tv2 (/dev/ttyp4) ~ 10 -> mythfilldatabase
    2007-02-27 15:28:01.026 Using runtime prefix = /usr/local
    2007-02-27 15:28:01.082 New DB connection, total: 1
    2007-02-27 15:28:01.096 Connected to database 'mythconverg' at host: localhost
    2007-02-27 15:28:01.135 New DB connection, total: 2
    2007-02-27 15:28:01.138 Connected to database 'mythconverg' at host: localhost
    ...  (much stuff omitted)
    2007-02-27 15:28:20.940 Marking episode last showings.
    2007-02-27 15:28:20.943     Found 0
    2007-02-27 15:28:20.955 Grabbing next suggested grabbing time
    2007-02-27 15:28:22.192
    ===============================================================
    | Attempting to contact the master backend for rescheduling.  |
    | If the master is not running, rescheduling will happen when |
    | the master backend is restarted.                            |
    ===============================================================
    2007-02-27 15:28:22.208 Connecting to backend server: 192.109.197.177:6543 (try 1 of 5)
    2007-02-27 15:28:22.235 Using protocol version 30
    2007-02-27 15:28:22.237 MainServer::HandleAnnounce Monitor
    2007-02-27 15:28:22.238 adding: tv2.lemis.com as a client (events: 0)
    2007-02-27 15:28:22.242 MainServer::HandleAnnounce Monitor
    2007-02-27 15:28:22.242 adding: tv2.lemis.com as a client (events: 1)
    2007-02-27 15:28:22.256 mythfilldatabase run complete.
    === mythtv@tv2 (/dev/ttyp4) ~ 11 ->
    
    
    Check the end of the output: the connect to the backend server could fail with a message like this:
    ===============================================================
    | Attempting to contact the master backend for rescheduling.  |
    | If the master is not running, rescheduling will happen when |
    | the master backend is restarted.                            |
    ===============================================================
    2007-02-27 14:24:06.099 Connecting to backend server: 192.109.197.177:6543 (try 1 of 5)
    2007-02-27 14:24:06.101 Connection timed out.
                            You probably should modify the Master Server
                            settings in the setup program and set the
                            proper IP address.
    
    

    Despite what the message says, the most likely cause for this particular “timeout”, where the backend server is specified as an IP address, is because the user mythtv doesn't have remote login permissions for this system. See above for details.

  8. Next select Video sources and select a grabber. From the MythTV HOWTO:
    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 mythtv-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. You may need to switch from the MythTV setup program to the console it was run on to interact 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.

  9. Next do the input connections. Again, from the MythTV HOWTO:

    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.

    On the connection pane there is a "Scan for channels" button, if you are configuring a digital source such as a DVB card, you need scan for channels and you must do this before pressing the "Fetch channels from listings source" button. You may scan for analog channels on an analog input, but this is not needed.

    The other button is called "Fetch channels from listings source". As long as you have a real listings source you should fetch channels from them for analog channels. You can do this for digital sources as well (unless the listing source is transmitted EIT data). If you are using XMLTV, you may need to switch from the MythTV setup program to the console it was run on to interact with XMLTV after pressing this button. It is possible to fetch the channels on the command line using mythfilldatabase. But if you need to do this, you will probably need to re-enter the MythTV setup program to configure the "Starting channel" setting for this source->input connection.

    O nce 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: If you have a Hauppauge PVR-500, you must think of it has two PVR-150's on a single PCI card. For example, if you have a single PVR-500 card, it will appear as /dev/video0 and /dev/video1. Each /dev/video device will have a Tuner input.

    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.

    My experience:

    • Select /dev/tuner0 -> FOO
    • Set Video Source to Antenna (I think this is the name I gave above).
    • Select Fetch channels from listings source.

      This starts another run of mythfilldatabase. In my case, it also produces a large number of error messages about missing programme information.

  10. That should be all you need to do. You can check that the channel editor, which should now show your local channels. If not, something has gone wrong.

On leaving mythtv-setup, I got a message saying:

Image

This is completely baffling in this case, since there is only one card, and nothing points at a channel 3 (which, indeed, doesn't exist). Replying “Yes” here makes the screen go blank for 52 seconds, during which mythtv-setup consumes 34 seconds of CPU time, but doesn't seem to do anything else. After that, it returns to the main menu.

Gave up on mythtv-setup and used mysql instead:

=== mythtv@tv2 (/dev/ttyp1) ~ 6 -> mysql -u mythtv -p mythconverg
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
...

SHOW TABLES showed that there's a table called capturecard, with a plethora of columns, most of them unused. The interesting ones are:
mysql> SELECT cardid, videodevice, cardtype, defaultinput, hostname FROM capturecard;
+--------+-------------+----------+--------------+---------------+
| cardid | videodevice | cardtype | defaultinput | hostname      |
+--------+-------------+----------+--------------+---------------+
|      2 | /dev/cxm0   | MPEG     | Tuner 0      | tv2.lemis.com |
+--------+-------------+----------+--------------+---------------+
1 row in set (0.00 sec)

OK, so that's our card alright, and it really has the number 2 for some reason, probably because the colum is set to auto_increment. But there's no default channel information. That must be in one of the other 45 tables in the database, and I don't know of any documentation. Looking at the names, settings seems to be a likely one, and indeed his has 292 rows with all sorts of interesting stuff. Rather than searching, decided to guess:

mysql> SELECT * from settings WHERE data = 3;
+-----------------------------+------+---------------+
| value                       | data | hostname      |
+-----------------------------+------+---------------+
| JobQueueMaxSimultaneousJobs | 3    | tv2.lemis.com |
| OSDProgramInfoTimeout       | 3    | tv2.lemis.com |
| AutoExpireDayPriority       | 3    | NULL          |
| DefaultTVChannel            | 3    | tv2.lemis.com |
+-----------------------------+------+---------------+
4 rows in set (0.01 sec)

So there it is. How am I supposed to set it? I don't know, and I don't care too much. This works much faster and more clearly:
mysql> UPDATE settings SET data = 28 WHERE value = "DefaultTVChannel";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> SELECT * from SETTINGS WHERE value = "DefaultTVChannel";
+------------------+------+---------------+
| value            | data | hostname      |
+------------------+------+---------------+
| DefaultTVChannel | 28   | tv2.lemis.com |
+------------------+------+---------------+
1 row in set (0.00 sec)

2007-03-01 16:10:45.954 Finished recording The Food Lovers' Guide to Australia: channel 1000
2007-03-01 16:11:20.623 TV Error: LiveTV not successfully started
2007-03-01 16:11:20.636 DPMS Reactivated.
2007-03-01 16:11:47.061 XMLParse::LoadTheme using /usr/local/share/mythtv/themes/G.A.N.T./ui.xml
2007-03-01 16:11:49.037 GuideGrid:
                        You don't have any channels defined in the database.
                        Guide grid will have nothing to show you.
Segmentation fault: 11 (core dumped)
=== mythtv@tv2 (/dev/ttyp1) ~ 11 ->
2007-03-01 16:12:15.775 Expiring The Food Lovers' Guide to Australia from Thu Mar 1 16:00:00 2007, 23 MBytes, forced expire (LiveTV recording)

A message in the MythTV log explains the background, and also the obvious, that it shouldn't segfault, but doesn't appear to fix it.
+--------+---------+--------+----------+-------------------+-------------------+---------------------------------------+----------+--------------+-----------------------------+---------+
| chanid | channum | freqid | sourceid | callsign          | name              | icon                                  | finetune | videofilters | xmltvid                     | visible |
+--------+---------+--------+----------+-------------------+-------------------+---------------------------------------+----------+--------------+-----------------------------+---------+
|   1000 |         | NULL   |        1 | SBS               | SBS               | /home/mythtv/.mythtv/channels/sbs.png |     NULL |              | free.Adelaide.SBS.d1.com.au |       1 |
|   1001 |         | NULL   |        1 | ABCSA             | ABC SA            | /home/mythtv/.mythtv/channels/abc.png |     NULL |              | free.Adelaide.2.d1.com.au   |       1 |
|   1002 |         | NULL   |        1 | CHANI             | Channel Nine      |                                       |     NULL |              | free.Adelaide.9.d1.com.au   |       1 |
|   1003 |         | NULL   |        1 | CHASE             | Channel Seven     | /home/mythtv/.mythtv/channels/7.png   |     NULL |              | free.Adelaide.7.d1.com.au   |       1 |
|   1004 |         | NULL   |        1 | NETTE             | Network TEN       | /home/mythtv/.mythtv/channels/10.png  |     NULL |              | free.Adelaide.10.d1.com.au  |       1 |
|   1005 | 0       | 46250  |        1 | Adding Channel 0  | Adding Channel 0  | none                                  |     NULL |              |                             |       1 |
|   1006 | 1       | 57250  |        1 | Adding Channel 1  | Adding Channel 1  | none                                  |     NULL |              |                             |       1 |
|   1007 | 2       | 64250  |        1 | Adding Channel 2  | Adding Channel 2  | none                                  |     NULL |              |                             |       1 |
|   1008 | 3       | 86250  |        1 | Adding Channel 3  | Adding Channel 3  | none                                  |     NULL |              |                             |       1 |
|   1009 | 4       | 95250  |        1 | Adding Channel 4  | Adding Channel 4  | none                                  |     NULL |              |                             |       1 |
|   1010 | 5       | 102250 |        1 | Adding Channel 5  | Adding Channel 5  | none                                  |     NULL |              |                             |       1 |
|   1011 | 5A      | 138250 |        1 | Adding Channel 5A | Adding Channel 5A | none                                  |     NULL |              |                             |       1 |
|   1012 | 6       | 175250 |        1 | Adding Channel 6  | Adding Channel 6  | none                                  |     NULL |              |                             |       1 |
|   1013 | 7       | 182250 |        1 | Adding Channel 7  | Adding Channel 7  | none                                  |     NULL |              |                             |       1 |
|   1014 | 8       | 189250 |        1 | Adding Channel 8  | Adding Channel 8  | none                                  |     NULL |              |                             |       1 |
|   1015 | 9       | 196250 |        1 | Adding Channel 9  | Adding Channel 9  | none                                  |     NULL |              |                             |       1 |

If you're in Australia, see the page on setting up tv_grab_au_reg


Greg's home page Greg's diary Greg's photos
Valid XHTML 1.0! $Id: mythtv-on-FreeBSD-setup.html,v 1.6 2007/03/05 14:31:50 root Exp $