Streaming General Conference from MythTV

Every 6 months, the Church of Jesus Christ of Latter-day Saints broadcasts on television a series of meetings called General Conference.  There are usually 6 meetings, each 2 hours long, each meeting consisting primarily of talks by about 6 people.  On General Conference weekends, members of the Church watch the conference instead of attending local meetings.

I like to use MythTV to record the public sessions from KSL, a local TV station.  That way, I get a pristine, high definition picture that I can review anytime I like.

Two of the meetings are on Saturday.  During the Saturday meetings, I prefer to multitask while listening to conference.  I want my wireless laptop to play the audio and a miniature version of the video.  I finally figured out how to do that.

I started with the directions on parker1.co.uk.  That page describes how to use VideoLAN to stream a video even as it’s being created.  Unfortunately, those directions seem to be out of date, as is the mythlink script the page links to.   So here is my version of the mythlink script (with the database password replaced with ‘fakepw’):

#!/bin/sh

# mythlink.sh - Symlinks mythtv files to more readable versions
# by Dale Gass

if [ ! -d /tv/links ]; then mkdir /tv/links; fi
rm -f /tv/links/*

echo "Done RM"
mysql -umythtv -pfakepw mythconverg -B --exec "select chanid,starttime,endtime,title,subtitle from recorded;" >/tmp/mythlink.$$
perl -w -e '
        my $mythpath= "/tv";
        my $altpath= "/tv/links";
        if (!-d $altpath) {
                mkdir $altpath or die "Failed to make directory: $altpath\n";
        }
        <>;
        while (<>) {
                chomp;
                my ($chanid,$start,$end,$title,$subtitle) = split /\t/;
                $start =~ s/[^0-9]//g;
                $end =~ s/[^0-9]//g;
                $subtitle = "" if(!defined $subtitle);
                my $ofn = "${chanid}_${start}.mpg";
                do { print "Skipping $mythpath/$ofn\n"; next } unless -e "$mythpath/$ofn";
                $start =~ /^(............)/;
                my $nfn = "$1_${title}";
                if ($subtitle) {$nfn="${nfn}__${subtitle}"}
                $nfn =~ s/ /_/g;
                $nfn =~ s/&/+/g;
                $nfn =~ s/[^+0-9a-zA-Z_-]+/_/g;
                $nfn = "${nfn}.mpg";
                print "Creating $nfn\n";
                unlink "$altpath/$nfn" if(-e "$altpath/$nfn");
                symlink "$mythpath/$ofn", "$altpath/$nfn" or die "Failed to create symlink $altpath/$nfn: $!";
        }
' /tmp/mythlink.$$
rm /tmp/mythlink.$$

This handy script generates links to make it easy to find recorded TV programs on the filesystem. After running the script, I started a VLC streaming server like this:

vlc 200904041400_LDS_General_Conference.mpg --sout \
'#transcode{vcodec=mp4v,vb=2048,scale=0.25,acodec=mp3,ab=128,channels=2}:std{access=http,mux=ts,dst=:8081}'

I learned what options are available from the VLC streaming documentation.  The command I used creates a 2 megabit per second streaming server using the MPEG-4 and MP3 codecs, with the video scaled from high definition (1920×1080) to 480×270. Then I launched the client on my laptop:

vlc http://tiger:8081

This worked very well. Both the video and audio were very clean and never stalled.  The MythTV server has an AMD 5200+, which is more than fast enough to simultaneously record the high definition stream to a hard drive, play it back with scaling, transcode down to 480×270, and send the transcoded stream to multiple clients.

Of course, this will all be much easier when MythWeb gains the ability to generate Flash videos.

NewEgg, You Amaze Me

Last week, an important desktop computer used by my family died. The connection between the power supply and motherboard fried somehow. I’ve never seen a connection fail like this before: all of the connections attached to red wires had burned the surrounding plastic within the connector. It was difficult to detach the connector, and even when I cleaned up the motherboard and used a new power supply, the motherboard refused to power on. Nothing else was damaged.

I suspect the motherboard was drawing too much current and the connector failed over time. Newer motherboards have separate 12V connectors which could solve the problem.

Anyway, I immediately found a better motherboard (PCCHIPS A15G (V1.0) AM2+ MCP61P) and a faster, lower power CPU (AMD|A64 X2 5200 2.7G AM2 65N R) on NewEgg for a total of $108 including shipping. The computer will be better than ever. NewEgg sure knows how to keep me as a customer.