Tip #3: Importing downloaded TV shows into MythTV

Situation


Last week, I upgraded my kernel. Unfortunately, after a re-boot, my DVB drivers failed to load. The net result is I went three days without recording a single show. Now my only option is downloading the TV shows, and watching them manually, somehow (usually mplayer). WAF definitely goes down.

How to Get the Shows Into MythTV


It turns out, that importing the shows into MythTV is easy. The issue is it's not terribly simple. I'll describe below how to import a show into MythTV. Some of the metadata is 'optional'.

Let's get to it!



Not entering the optional data will get your show into MythTV, but the Meta-Data about the show will not be imported (Meta data like Show description, the correct date/time of the show, subtitle, etc...)
Prerequisites:

  • the show must be in mpeg-4, or mpeg-2 format. If it is not, you can use mencoder, or transcode to convert it.
  • You need to know the name of the show
  • You need to know the channel ID of the show's recordings (see script below)
  • Optional:The original date/time of the episode
  • Optional:The Subtitle of the episode (see tv.com for this stuff)
  • Optional:The description of the show (tv.com is your friend)


I wrote a little shell script to list the channels in my channels table:
mysql --host -umythtv -p -e 'use mythconverg; select chanid, name, callsign from channel where visible=1'

Let's say I missed an episode of E-Ring

  1. Download the show from your favorite source (fine by me if you use torrents).
  2. Move the file to your recordings directory (in my case /video/recordings)
  3. run myth.rebuilddatabase.pl --ext avi (if your file has the extension avi)


    These are the files stored in (/video/recordings) and will be checked against
    your database to see if the exist. If they do not, you will be prompted
    for a title and subtitle of the entry, and a record will be created.

    Non-nuv file /video/recordings/E-Ring.11-16.Delta.Does.Detroit.avi found.
    Do you want to import? (y/n):y

  4. Enter 'y'
  5. You will be prompted for several pieces of information, and when you are done, myth.rebuilddatabase.pl should ask you to rebuild the seek table (critical!). If it does not, then when the script exists execute the following command:

$ mythcommflag --rebuild --file .nuv
This will rebuild the seek table, but will not commercial flag the recording. Commercial flagging is probably not necessary as your downloaded file probably does not contain commercials.

Final Note


Sometimes when viewing imported AVI files with MythTV's internal player I will notice problems with the screen refreshing when I skip around. This is usually due to the fact the many shows are encoded with key frames far and few between. Wait a couple seconds (usually a scene change) and the screen will clear up.

Good Luck!

6 comments:

Anonymous said...
4:11 PM

You mention in this article that you're using DVB cards. Are you using an antenna or QAM? I ask because I have a pcHDTV HD-3000 and I'm having reception issues with my antenna. I'd like to use QAM but haven't had any success. I happen to live in Vancouver as well and have Comcast. Any advice is appreciated.

Thanks,
Jake

John said...
4:19 PM

Hey Jake,

I use three pcHDTV 3000 cards, OTA. I use the Zenith Silver Sensor antenna in my attic and get *great* reception.

--
John <><

Anonymous said...
9:14 PM

I just drop my downloaded video files / missed tv shows into the mythvideo directory. .20 scans for new videos automagicly, so you are good to go.

John said...
8:16 AM

That's true, but if you want to view a show in your "Recorded Programs" section then you still need to import it.

For my family, it's a matter of WAF. For instance, if we have five or six shows from a series that we're behind on, it's easier for me to import them than to try and explain to my wife that when she gets to show five, she can find that in the 'MythVideo' section.

cyberwizard said...
5:23 PM

Excellent tutorial! This seems to be the only one on the 'Net that clearly explains the usage of the myth.rebuilddatabase.pl script.

You didn't mention if there was anything needed to allow MythTV to display the imported files. myth.rebuilddatabase.pl seems to be working OK for me, the data gets added to the recorded table in mysql, and the seek table gets updated, but files don't get displayed under Watch Recordings until about 10 minutes after a backend reboot. That makes me think that there might be an added step missing from your steps.

cyberwizard said...
9:56 AM

Me again. It turns out that myth.rebuilddatabase.pl MUST be run with your PWD as the location of the files to be imported. Strangely enough, if it's run from elsewhere it gives every appearance of working, it finds the files in the recordings directory, it requests meta data, it adds the provided data to the MySQL tables, but it doesn't work. Once I started running the script from within the recordings directory it worked like a champ.

Again...great article! This is really what got me going with using myth.rebuilddatabase.pl.