MythTV and the UK Digital Switchover

We had part one of the Digital Switchover in our area on Wednesday, so I finally had to bite the bullet and do a proper DVB channel re-scan on my MythTV box.

When I first set up DVB on my Myth box (previously I'd only used an S-Video capture card to record from my Sky satellite box) I had a 'mare of a job setting the channels up.  Admittedly that was years ago now, and MythTV's scanning has moved on since then (but the channel editor's still a bit of a PITA), but it scared me off doing scanning from within Myth till just now.

Instead, I did the occasional scan with dvb-apps' scandvb (with MythTV stopped) to generate a channels.conf file, then I had a small perl script which would look in that for channels that I had in my Myth SQL database that were on the frequencies used by my local transmitter, then generate the SQL updates and correct the channels, frequencies and channel numbers directly.

With the wholesale changes about to happen, that wasn't going to cut the mustard, so a full scan was on the cards.  This is, to be honest, what pretty much everyone on the mailing list was recommending anyway.

Before the change, I did a test scan (after backing up the database!) to see what sort of things would happen.  It didn't go well:  a full scan from MythTV  picked up loads of superfluous copies of channels that could be just about seen from other transmitters.

I restored the database, and instead did a scan on existing transports, a Myth option that only scans the frequencies it already knows about (so correctly limiting it to the local transmitter).

That seemed to work out OK, so I tidied up the new channels it had added and waited for Wednesday.

Anticipating problems, I wrote a couple of small perl scripts to store & restore some important channel information (such as my own name for them as opposed to the callsign that is transmitted as an ID, and the xmltvid which is used to link to Radio Times TV listings).

After some serious playing after the changeover, what I ended up doing was this:

Dump the channel data I wanted to keep:

  1. #!/usr/bin/perl -w
  2.  
  3. use DBI;
  4.  
  5. my $dsn = 'DBI:mysql:mythconverg:hostname';
  6. my %dbattr = ( PrintError => 1, RaiseError => 0 );
  7. my $dbh;
  8.  
  9. $dbh = DBI->connect($dsn, 'user', 'password', \%dbattr);
  10. $dbh->{RaiseError} = 1  if defined($dbh);
  11.  
  12. {
  13.     my $querystr = qq`SELECT channum,callsign,name,icon,xmltvid,useonairguide,visible,commmethod FROM channel WHERE sourceid=1`;
  14.     my $query = $dbh->prepare( $querystr );
  15.     $query->execute();
  16.  
  17.     while (my $hashref = $query->fetchrow_hashref())
  18.     {
  19.         print join("\t", (
  20.                 $hashref->{channum},
  21.                 $hashref->{callsign},
  22.                 $hashref->{name},
  23.                 $hashref->{icon},
  24.                 $hashref->{xmltvid},
  25.                 $hashref->{useonairguide},
  26.                 $hashref->{visible},
  27.                 $hashref->{commmethod} ) )
  28.             . "\n";
  29.     }
  30. };

Note that this updates items for sourceid=1, which is my Freeview set. If you use this, you'd have to check which sourceid you have DVB on.

Update the local transmitter frequency table to remove the now defunct channel and add the new mux (from data gleaned from the excellent resource UKFree.TV).

Then I stopped Myth, and did a channel scan:

scandvb ~/etc/dvb-t-uk-BluebellHill > /tmp/channels.conf

I found it was moving on to a non-existent channel and a duplicate (slightly different frequency) for some reason (I think channels can have hints in them that other frequencies should be checked), so I just deleted the duplicate channel entries from the bottom of the file.

In mythtvsetup, went to the channel editor, selected Freeview and deleted all those channels (not my Sky ones), then chose a “scan from channels.conf”, which reads the manual scan file above, and checks each of the channels listed in it).

I then quit out and restored the custom data I'd kept back:

  1. #!/usr/bin/perl -w
  2.  
  3. my $nums = 0;
  4. if ($ARGV[0] and $ARGV[0] eq '-n')
  5. {
  6.     $nums = 1;
  7.     shift(@ARGV);
  8. }
  9.  
  10. open( CHANNELS, "<$ARGV[0]" ) or die "failed to find channel file '$ARGV[0]'\n";
  11. while (defined( my $channel = ))
  12. {
  13.     chomp($channel);
  14.     my @data = split("\t",$channel);
  15.     my %data = (
  16.         channum         => $data[0],
  17.         callsign        => $data[1],
  18.         name            => $data[2],
  19.         icon            => $data[3],
  20.         xmltvid         => $data[4],
  21.         useonairguide   => $data[5],
  22.         visible         => $data[6],
  23.         commmethod      => $data[7],
  24.     );
  25.  
  26.     my $channum = ($nums ? qq`,channum=$data{channum}` : '');
  27.     print qq`UPDATE channel SET name="$data{name}",icon="$data{icon}",xmltvid="$data{xmltvid}",useonairguide="$data{useonairguide}",visible="$data{visible}",commmethod="$data{commmethod}"$channum WHERE sourceid=1 AND callsign="$data{callsign}";\n`;
  28. }

Then finally back into mythtvsetup to tart up new channels it had found (mostly disabling non-free & grot ones it had added).

I restarted Myth, and lo-and-behold, it was all working!  All that needed to be done was another TV-listings fetch, to refresh the now-deleted listings for the old channel entries.

Sweet!

Roll on next fortnight when the final change happens, and all the broadcast powers are finally maxed.


Advertisement


About fnx

PSN: the_phoenix
This entry was posted in Software, Tech and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*