MythTV with PVR-500 in New Zealand HOWTO
This guide below attempts to document compiling and installing mythtv with as minimal fuss as possible on a system with a PVR-500 Hauppauge tuner card for New Zealand TV.
It does not cover setting up the PVR-500 itself, or testing it. I assume you have read the other information at PVR-500 in New Zealand site first, and have the PVR-500 working.
It doesn't detail some of the more advanced options, such as distributed compiling or the real-time scheduling option. I highly recommend reading the MythTV HOWTO on this subject for more information.
It is assumed here that you are configuring a simple MythTV set up with only one system running MythTV. (It is possible to have multiple systems running MythTV performing different tasks).
If you have a tuner card other than a PVR-500, these instructions may still be useful, but some of the section on Configuring the backend won't be of much help.
If you are not in New Zealand, you may well be able to skip Step 2.
Step 1: Install Mythtv
Either install it through your distributions package manager, or (preferably) install it from source.
I can't go into the details on how to install MythTV from precompiled distribution packages, as there are so many distributions, and the prefered method is by source anyway.
From Source
To compile and install MythTV from source, first create a mythtv user, named, usually, "mythtv". Become that user (either login to that user account, or use su - mythtv. Go to the location of the mythtv tarball (it is assumed for this example, that you are installing MythTV version 0.18.1. If you are using a different version, you will obviously need to change the name of the tarball below.
# cd mythtv-0.18.1
# ./configure
At this point the configure script will run, if the script fails it should outline what dependancy it needs that you do not have. You should obviously then set out to install that dependancy, either via package management if your distribution has that program/library, or from source.
Once the configure script has run, you will be able to start compiling the source, as follows:
# make
It does take some time to compile MythTV, go away, have dinner, or if you have a really fast machine, coffee.
Once the compile has finished, you will need to install the compiled result. Normally you will need to become root at this stage, either using su as below, or your favourite root-becoming-program (eg sudo).
$ make install
$ exit
MythTV utilizes a MySQL backend, and you will need to configure MySQL for MythTV before you can continue. It is assumed here that your root user account has full access to MySQL, if not, replace root with whatever user has the ability to create users and databases in MySQL.
# mysql -u root < mc.sql
Assuming that completes without problems, onwards to the next step.
Step 2: Some small hacks
This step is needed for New Zealand users, as MythTV doesn't list New Zealand as having a TV grab script. If you aren't in New Zealand, you may be able to skip this, or taylor this step to your own country.
Electronic Program Guides (EPGs) allow the MythTV system to know that the Simpsons is on at 5pm weeknights as well as 7:30pm Wednesday on Channel 3. This is what makes MythTV so great, since you can just select "The Simpsons" and it will record it whenever its on.
Currently, there is now only one source for Electronic Program Guides in New Zealand. mr.geek.nz was shutdown, hairy.geek.nz's datafeed is now blank, and nz.ontv.uni.cc is down. The only feed left is a self generated feed using reven.co.nz's xmlTVNZ program. This program "screenscrapes" data from various websites.
These two scripts grabbed data from the respective feeds when they were working. They aren't working now, but I leave the links here incase they come back online, or someone wants to see them:
- OnTV. tv_grab_nz_ontv. (Not working)
- Mr.Geek.nz. tv_grab_nz_mrgeek. (Not working)
xmlTVNZ
To update the EPG data, after you have set up mythtv (see step 3), run the following (assuming xmlTVNZ has been installed in /home/mythtv)
# ./xmlTVNZ.exe tvguide.xml -days 5 tv1 tv2 sky_tv3 prime
# mythfilldatabase --file 1 -1 tvguide.xml --update
This script will need to be run routinely, and I set it up as a daily cron job.
This is obviously not the optimum way of doing this, and if anyone finds another source for EPG data, please let me know!
Step 3: Configure MythTV
As the mythtv user, run the following.
For first time setups, and if you want to start over again, answer Yes to both "Delete my card settings" and "Delete my channel settings".
Go through each of the 5 options in order.
1. General
On the first page, you can leave the defaults alone if you plan to only have one MythTV system.
On the 2nd page, Host-specific Backend Setup, setup the Directories as you see fit. Obviously if you have a partition that is very large, you should use that to store recordings and Live-TV buffers.
Next page, select your TV format, since this site is targetted towards PAL TV users (such as New Zealand/Australia), I'm assuming you are going to select PAL here.
The VBI format should again be PAL, and Channel frequency table should be set to your country (eg New Zealand).
Time offset should be set to your usual timezone offset (New Zealand is +1200).
The next few pages you can pretty much ignore for now, as you if you are reading this guide, you are trying to get things working for the first time, come back and visit this stuff much later.
2. Capture Cards
Now the fun stuff begins. Select "New capture card", to setup a new card. The card type should be "MPEG-2" Encoder card (PVR-250,PVR-350)" (its ok, the PVR-500 is similar to those cards). The video device should be set to /dev/video0, and the default input should be set to Tuner 0.
Now, since we are configuring a Hauppage PVR-500 card, we need to configure the second tuner/encoder on the card. PAY ATTENTION HERE.
The PVR-500 has two tuners and two encoders stuffed onto one card, the first card is /dev/video0 and Tuner-0, but the second card is: /dev/video1 and Tuner-0. Note that that is tuner ZERO. So now select "New capture card" again and put /dev/video1 and Tuner-0 in the applicable fields.
3. Video Sources
Video Sources define what is coming in the various tuner cards, for simple setups in New Zealand, this is probably a TV antenna connected to the tuner, and therefore its Free-to-air TV. If you have SkyTV or a cable TV setup, then it gets a touch more complicated, and I would suggest you setup free-to-air TV first, and work on SkyTV later.
Much like tuners, click "New video source". For the Video source name enter where the video input is coming from, eg "Free-To-Air".
As for the XMLTV listings grabber, since there is no current EPG source for New Zealand, just select Australia here, when you click Finish, it will produce an error, which you can ignore.
As you exit these settings, mythtv will attempt to download the EPG and will be prompted to run mythfilldatabase --manual. If you are following the howto, plan to use, and have installed reven.co.nz's xmlTVNZ.exe program, then at this stage, exit the setup program, and run the following in the mythtv home directory (assumed to be /home/mythtv here)
The script will prompt you for each channel it finds. Most of the settings should be straight forward, but when it asks you for channum, you need to enter the channel frequency number (see the Channels section on this site for how to obtain your regions channel numbers).
4. Input connections
This part is very straightforward, select /dev/video0 Tuner 0 and change the Video source to the source you named above, and do the same for /dev/video1 Tuner 0 (note; Tuner 0 not 1).
5. Channels
And now we reach the final part of setting this up.
Hopefully all the TV channels from your xml feed should already be here, if not, run the steps above again.
Go through each TV channel and tweak any details you like, note that the XMLTV ID is the name that the XML source uses to identify that channel. If you have selected the wrong frequency number for a given channel, change it on Page 2 of the channel settings (hit Next).
Step 4: Setting up the frontend
Coming soon
. Ok, so its been awhile... If someone wants to write a brief setup guide for the frontend, feel free to do so and email it to me.Troubleshooting
I am often asked for help on various problems with PVR-500 and PVR-150 cards. To fix things when they don't work, you need two things. 1) An understanding of how the thing is suppose to work and being methodical in your approach.
Step 1 - Signal Input
Check the signal input. If you are using a coax cable for signal, then plug a tv into the end of it and verify it can infact pickup good strong TV signals. If it can't then there is no hope of the system working!Step 2 - Back to basics
Disable mythtv from starting automatically, and remove any automatic module loading commands (eg from /etc/modules or elsewhere). Now try inserting the module in the order you believe is correct. (This site has a init script0 which loads each module with what I believe are the correct parameters for ivtv-0.3.6u on a PVR-500 card).
You should also initialize the card with ivtvctl as well. The commands I use are below:
ivtvctl -d /dev/video0 -p 6 -f width=720,height=576 -u 1 ivtvctl -d /dev/video1 -p 6 -f width=720,height=576 -u 1
Step 3 - Try reading directly from the card
Change the card to the correct TV channel. Here it may be a bit hit and miss, depending on your location, but see here for a list of TV channels, numbers and frequencies. Use this command to change the channel:
ptune.pl -f pal-newzealand --input /dev/video<num> -c <chan>
(Where <num> is the video number (eg 0 or 1) and <chan> is the channel.
Now try reading directly from the mpeg stream with this command:
cat /dev/video0 > /tmp/video0.mpg
(Hit Ctrl+C after 5-10 seconds)
And now play the mpeg file with your favourite mpeg player (such as MPlayer. If you have a good file, then it is working. Repeat the above tests (channel and read) with video1 as well and verify both tuners are working (assuming you have a PVR-500 card).
Step 4 - Start MythTV
Whilst you still have a working setup (eg before you reboot), start mythtv on the system and see if it works through MythTV.
If you are getting static/nosignal with MythTV, it may be because MythTV has the wrong channel number, or PAL/NTSC not set correctly. Both of these settings are in the MythTV config program.
Step 5 - Setup the system
Now you have a working setup (hopefully), set up the system so it loads the modules in the same order you did, with the same parameters. You may choose to use modules, however I simply used a shell script, and called that script before mythtv-backend starts up.
Now reboot the system, and see if it still works. If it doesn't, then there is something in your startup sequence which is affecting it.
Writing recordings to DVD
Intro
Writting DVDs can be a bit of a black art with MythTV. I had a reasonable ammount of trouble finding useful and correct information on the subject. I will start out this section with some background on why its harder than it might seem.
Tools
To export a mythtv recording to DVD, you will need the following installed on your mythtv master system (where the mythbackend process runs):
- Nuvexport - To export .NUV MPEG4 files from MythTV.
- DVD Author - To create the DVD file system.
- mkisofs - To create a DVD ISO (Your distribution should have a mkisofs package).
- cdrecord - To burn the DVD ISO to your DVD burner. (Your distribution should have a cdrecord package).
- mjpegtools - Required by nuvexport to handle the mpeg2 stream.
Background - MPEG2, MPEG4, Transcode, what?!
With a hardware MPEG encoder such as the PVR500, PVR150, PVR250 or PVR350, the TV card itself encodes the raw stream from the tuner into MPEG2 video. With MythTV, this mpeg stream is saved pretty much directly to disk with a .nuv extension. The important thing to remember here is, with a hardware encoder card, the initial recording, although stored with a .nuv extension is NOT an NUV file.
If you wish to record a raw TV capture straight to DVD with NO editting, then this is good news for you. You can skip the next few steps and move on to recording a MPEG2 stream to DVD.
However, most people don't want to record the raw capture to DVD without first editting out at least the cruft and the beginning and end, and probably the ads too. So now you will find out about this wonderful thing called transcoding.
Transcoding is where MythTV takes one stream in one format, and converts it to another format (eg MPEG2 -> MPEG4). MPEG4 is the prefered format for MythTV. When you remove the ads from any recording, it converts it to MPEG4. But thats not the end of it, due to how MythTV does this, it stores the MPEG4 stream in a NuppleNivdeo (NUV) file. Generally speaking, this file can only be played within MythTV (there were some patches to MPlayer and some codecs for Windows Media Player, but I haven't confirmed they work).
So how do you convert a MPEG4 stream embedded in a NUV file to DVD? We transcode it back, but not directly with MythTV (honest, you can't make this stuff up). This is where nuvexport comes in.
Step 1 - Edit/Trim
First, trim and edit the recording how you want it with MythTV (see the section on Editing Recordings previously), and flag it to transcode. Once the transcode session has run (check the System Information, Job Information menu), continue to the next step.
Step 2 - Nuvexport
Nuvexport is a tool written in perl to assist with exporting MythTV NUV recordings into other formats.Fortunatly, nuvexport was written with ease of use in mind, and it seems to work very well and is reasonably easy to understand, so I will run through a sample export with you.
Login to your mythtv system as the mythtv user (not root).
Change your local directory to a location that has a lot of disk space free (the location mythtv uses to save its streams is a good idea here).
Run nuvexport.
# nuvexport
Press 5 (Export to DVD) and enter. If Export To DVD is marked as (disabled) then you may be missing some of the requirements for nuvexport, go back to the setup of nuvexport step and check the requirements.
Select the show from the list, and then select the episode.
Once the program has run, it will have produced an MPEG-2 encoded file in the current directory with the name of the episode.
Step 3 - DVDAuthor
This file needs to be converted to DVD format, which is where dvdauthor comes in. DVDAuthor produces the DVD filesystem that needs to be written to the DVD.
The command to run is
Where epsisode-file.mpg is the name of the file that nuvexport created. This will create a DVD filesystem under the DVD directory.
Step 4 - Mkisofs
Sorry, I haven't yet done this section. I know the command to use, in theory, but in producing this how-to, I go through each step and verify it, so I'll provide you with what I believe to be the next command, but until I have time to actually go through all these steps and verify this command, I'll leave this warning here.
Step 5 - Burn
Burn this iso with your favourite burning tool (eg cdrecord, k3b, etc).
Done
And now you should have a DVD disc you can play in your DVD player. There are a couple of notes though. If you want DVD menus, you'll need to learn about them, they come in under the DVDAuthor step. I will eventually have a set of instructions for producing DVD menus too.
Not all DVDs, DVD burners, and DVD players are created equal. For example, my DVD player does not "like" playing my DVD-R's. (The box on the DVD player says its supports DVD-Rs, but when I play them, the DVD player makes lots of funny noise, and the DVDs "jam" up whilst playing).
Common Problems, Tips, and Hints
This section has some random tips and hints that may help you with your mythtv setup. As with the rest of this howto, these tips are New Zealand centric, but may apply to the rest of the world.
All the shows are off by 12 (or 13) hours!
Quick fix:
- Shutdown the mythbackend.
- Run mythtv-setup
- Goto General
- Under global backend, change the Time Offset field to +1200 (or +1300) if daylight savings. If the field already was +1200 or +1300, then set it to none.
- Restart the backend.
One show runs for 12-13 hours
One show on one channel runs for many hours (in one case, 13 hours).
UNKNOWN. Not sure what causes this, the xml data is fine. If you have an answer, please let me know.
[Up]
Contact me: zaf@nrc.co.nz with any updates or suggestions, or maybe questions if they are intelligent ones.