Getting EIT To Work

There is quite a bit of mythology in the various wikis and blogs about what it takes to get over-the-air guide data working, using the EIT information. Most of them state that the only way is to allow MythTV to scan for channels on the input source and let it build the dtv_multiplex and channel tables. For example:

     http://ubuntuforums.org/showthread.php?t=1410407

We can categorically state that this isn't true. We've built channel lineups entirely from scratch, including setting up the dtv_multiplex table and the channel table with information made up from a scan by a television set. Follow these notes and you can do it too.

In North America, the most important information, from the EIT scan point of view, is the ATSC major and minor channel numbers. The atsc_major_chan and atsc_minor_chan fields must be set in the channel table or EIT scan will not work. This is because the data in the EIT must be matched back up to the channel it belongs to, so that it can be incorporated into the guide data, and this is where these two fields come in. That's swell because the tables we've seen generated by scte65scan don't have those fields set. And, apparently, importing a channels.conf file from scan fails to set these fields. So, EIT no workee.

Meanwhile, in Europe, the above statement about needing some way to convert the information in the EIT into a channel ID that MythTV can use to store the data is still relevant. Only, for Europe, the channel ID is looked up using serviceid, networkid and transportid. So, if those fields are not set in your database you're going nowhere fast.

Another thing to consider is that EIT scan only scans the first sub-channel (called a program or service) that is mapped to the multiplex frequency. For true over-the-air channels, this isn't usually a problem, since each multiplex frequency contains only the programs from a single broadcaster and the lowest sub-channel is almost always a real channel that you're interested in. But, for HDTV channels, transmitted by your favorite cable provider, you may find more than one real channel under a single multiplex frequency. For example, in our neck of the woods, Comcast is currently broadcasting the following on one multiplex frequency:

     WCVB HD   5_1     serviceid=1
     WHDH HD   7_1     serviceid=2
     This TV   7_2     serviceid=3

This means that, if we want to see EIT data from channel 7_1, we have to turn it on for channel 5_1 (hey, that's intuitive). Even more intuitive is the fact that EIT may need to be turned on for all of the sub-channels in the multiplex frequency for it to be used by any of them. But, knowing this, we can now construct a set of channel entries for our example:

     insert into channel set chanid=1051, channum='5_1', freqid=113, sourceid=1,
       callsign='WCVB-HD', name='WCVB HD (ABC)', serviceid=1, mplexid=113,
       useonairguide=1, atsc_major_chan=5, atsc_minor_chan=1;
     insert into channel set chanid=1071, channum='7_1', freqid=113, sourceid=1,
       callsign='WHDH-HD', name='WHDH HD (NBC, Boston)', serviceid=2, mplexid=113,
       useonairguide=1, atsc_major_chan=7, atsc_minor_chan=1;
     insert into channel set chanid=1072, channum='7_2', freqid=113, sourceid=1,
       callsign='This', name='WHDH This TV', serviceid=3, mplexid=113,
       useonairguide=1, atsc_major_chan=7, atsc_minor_chan=2;

Pay attention to the fact that the atsc_major_chan and atsc_minor_chan fields (or, in Europe, that the, serviceid, networkid and transportid fields), along with the useonairguide field are set. Even if the visible field is set to zero, the useonairguide field should be set on.

There is nothing unusual that needs to be done for the dtv_multiplex table except that the multiplex ID must be set in the mplexid field. Mind you, without this field being set, you won't be looking at any picture or hearing any sound so this is a no-brainer.

The next thing to do is make sure that active EIT scan is turned on for each of the DVB cards that you want to use for active EIT scanning (you could just allow passive scanning but this means that you actually have to view each of the channels before its guide data will show up). You'll want to have at least one card that is mapped to each input source but you can have more since the scan knows how to effectively use multiple cards. You can do this from the Capture Card section of the Myth Backend configuration application or you could try something like this:

     update capturecard set dvb_eitscan=1 where cardtype='DVB';

Finally, you need to turn on EIT scanning for the input source in question. You can do this from the Input Sources section of the Myth Backend configuration application, at the same time you turn on active EIT scan, or you could try something like this:

     update videosource set xmltvgrabber='eitonly', useeit=1 where sourceid=1;

You may need to recycle the backend on each of the machines that actually have the capture cards that will do the EIT scanning installed, although launching the Myth Backend configuration application takes care of this for you.

Note that, if over-the-air guide data via EIT still doesn't work, once you've done all this, you should enter the following SQL command:

     select channum, min(chanid), mplexid
       from channel, cardinput, capturecard, videosource
       where cardinput.sourceid=channel.sourceid
         and videosource.sourceid=channel.sourceid
         and capturecard.cardid=cardinput.cardid
         and channel.mplexid is not null and useonairguide=1 and useeit=1
         and channum!='' and cardinput.cardid=1
       group by mplexid
       order by cardinput.sourceid, mplexid, atsc_major_chan, atsc_minor_chan;

Change the cardid value from "1" to the actual card number of the capture card that's to do the EIT scanning. You should see a table that looks something like this:

     +---------+-------------+---------+
     | channum | min(chanid) | mplexid |
     +---------+-------------+---------+
     | 27_1    |        1271 |      82 |
     | 10_1    |        1101 |      83 |
     | 68_1    |        1361 |      99 |
     | 7_2     |        1051 |     113 |
     | 25_1    |        1041 |     114 |
     | 2_1     |        1021 |     115 |
     | 38_1    |        1381 |     116 |
     +---------+-------------+---------+

If you don't you've messed something up. Keep checking things until such a listing appears. Then, check the channel table entries for each of the channel IDs shown. They, at least, must have their ATSC major and minor numbers set (or, in Europe, their service ID, network ID and transport ID values set). But, it wouldn't hurt to set the ATSC major and minor numbers for all of the channels that have the same multiplex ID as those listed.

If you're still having problems and you can figure out what channels you want ATSC EIT data for, the returned EIT data must match this select:

     select chanid, useonairguide from channel
       where atsc_major_chan=xx and atsc_minor_chan=yy
         and sourceid=1;

Where xx and yy are the ATSC major and minor numbers and 1 is the source number (typically 1). If the select doesn't find anything, your EIT data won't get stored.

Alternately, if you're in Europe and you're still having trouble with DVB-T, for instance, the returned EIT data must match this select:

     select chanid, useonairguide from channel, dtv_multiplex
       where serviceid=xx and networkid=yy and transportid=zz
         and channel.mplexid=dtv_multiplex.mplexid;

Where xx, yy and zz are the service ID, network ID and transport ID. Again, if the select doesn't find anything, no EIT data for you.

Also note that the scan optionally adds this to the where clause, if the sourceid is set:

     and channel.sourceid=1

Where 1 is the source number (typically 1).

Either way, Europe or North America, there doesn't seem to be much magic involved. You can take a look at the applicable code in eitscanner.cpp and eithelper.cpp (both in libs/libmythtv) if you still can't get it to work but it looks fairly straightforward. There is some special case stuff, supposedly for special EIT data from the German provider Premiere for the optional channels Premiere Sport and Premiere Direkt, but other than that, it looks like: read the EIT data; resolve the channel number; parse the data; stuff the data in the database.

One final note. Your friends at your favorite cable company may strip the over-the-air guide data from your local HDTV channels. This is definitely the case with Comcast in our area, for example. Whereas the EIT data from a terrestrial broadcast of WCVB includes program names, episode titles and extensive episode descriptions for the next 18-20 hours, the EIT data from WCVB on Comcast cable only includes the program names, and only for the next 8-10 hours. Not that it matters from the scheduler's point of view, mind you, since guide data changes due to EIT scanning are reflected immediately but you will be missing the extended program information such as episode titles and descriptions.