Raspberry Pi DVR: Difference between revisions
Line 25: | Line 25: | ||
Find a perl program called Zap2XML, and put it in the pi home folder. Install missing perl libraries with <pre>sudo apt-get install libhttp-cookies-perl libjson-perl libwww-perl</pre>Test the script by creating the XML file of all the guide data using<pre>perl zap2xml -u yourusername@email.com -p password -o /home/pi/xmltv.xml</pre> | Find a perl program called Zap2XML, and put it in the pi home folder. Install missing perl libraries with <pre>sudo apt-get install libhttp-cookies-perl libjson-perl libwww-perl</pre>Test the script by creating the XML file of all the guide data using<pre>perl zap2xml -u yourusername@email.com -p password -o /home/pi/xmltv.xml</pre> | ||
Make a crontab -e entry to do this every now and then:<pre>10 00 * * * perl zap2xml -u yourusername@email.com -p password -o /home/pi/xmltv.xml</pre> | Make a crontab -e entry to do this every now and then:<pre>10 00 * * * perl zap2xml -u yourusername@email.com -p password -o /home/pi/xmltv.xml</pre> | ||
Find tv_grab_file script and edit it to point to the XML file you just made earlier (/home/pi/xmltv.xml). Place the edited tv_grab_file into the /usr/bin folder. Restart tvheadend. | |||
Tvheadend should now recognize tv_grab_file as a valid EPG grabber. Disable all the other grabbers and enable this one, then trigger the internal grabbers. If you look at the log, you should see some channel data was parsed from the xml file (but no programs, yet). | |||
Lastly, go into the configuration -> channels and select the EPG data stream you need for that channel from the dropdown, for each channel. This part takes the longest. When done, click the run internal EPG grabbers button again, and you should see that you can go over to the Electronic Program Guide tab and see programs listed there. | |||
Set the location to store recorded programs to wherever your hard drive is (eg, <code>/mnt/disk0</code> |
Revision as of 00:38, 18 May 2019
I am one of a few people whose main TV reception comes from regular old radio signals picked up with an antenna, just like those used over the last 60ish years. While the radio spectrum has remained pretty much the same, the signal has changed from an analog signal to high definition digital signal. Unfortunately, this means that our old way of recording TV such as the VCR no longer works as easily or smoothly as it once did, and even at that we would only get a standard definition signal anyways. There seem to be few options for recording live TV without paying somebody a subscription, either. However, it is very possible to do so.
At this point I should say that I really don't watch a lot of TV, and the fact that streaming is extremely and cheaply available these days makes this entire project moot. However, like many of my projects this one comes down to making things for the fun of it.
This all started when I picked up a modern digital tuner at a garage sale. Mine is a hauppauge wintv-hvr-950q. This is the main piece of the puzzle, all that the recording process does it take the de-multiplexed MPEG stream that is transmitted digitally over radio and write it to disk. We don't even need to decode the signal, because that only needs to happen when we play it back and need to see what the stream contains (which in my case is done on my laptop).
But, we need some other software tools to make it easier than this. I use one called Tvheadend, which runs as a server on a raspberry pi (you can access it with a web browser to make, schedule, and view recordings) and takes care of setting up the tuner and recording to disk.
General Setup Procedure
Install Raspbian. Add a blank SSH
named file in the boot partition to enable ssh server. Run rasppi-config
and go through all the usual setup stuff, but allocate more memory to the CPU (no need for GPU memory when headless).
Get an external drive and set it up with a linux file system (this is where recordings will go). Create mount point as empty folder /mnt/disk0
. Edit fstab located at /etc/fstab
and add line
UUID=34bc2462-9358-424a-b27a-fa1803efd097 /mnt/disk0 ext4 defaults,nofail 0 0
replacing with your disk's uuid. Now the drive will automatically mount to /mnt/disk0
on boot.
Install missing firmware for your tv tuner. For mine, I needed to get a file called
dvb-fe-xc5000-1.6.114.fw
and put it in /lib/firmware/
though I found it was already there in the newer raspbian releases. Check dmesg
to make sure the tuner is recognized after a reboot.
Do apt-get update and upgrade at some point, just cuz.
Install tvheadend using the procedures listed at https://tvheadend.org/projects/tvheadend/wiki/AptRepositories.
Upon reboot, go to <yourip>:9981 and enter the user/pass you specd in the tvheadend install. Go through the wizard, select the tuner, ATSC network, and scan for channels and stuff. At this point, you should have a working tuner setup and should be able to watch live tv if you click on a channel (in "Channels", I think).
EPG data
To get guide data for actcually scheduling programs, make an account at zap2it.com. Remember your username and password, and then star every channel you want data for.
Find a perl program called Zap2XML, and put it in the pi home folder. Install missing perl libraries with
sudo apt-get install libhttp-cookies-perl libjson-perl libwww-perl
Test the script by creating the XML file of all the guide data using
perl zap2xml -u yourusername@email.com -p password -o /home/pi/xmltv.xml
Make a crontab -e entry to do this every now and then:
10 00 * * * perl zap2xml -u yourusername@email.com -p password -o /home/pi/xmltv.xml
Find tv_grab_file script and edit it to point to the XML file you just made earlier (/home/pi/xmltv.xml). Place the edited tv_grab_file into the /usr/bin folder. Restart tvheadend. Tvheadend should now recognize tv_grab_file as a valid EPG grabber. Disable all the other grabbers and enable this one, then trigger the internal grabbers. If you look at the log, you should see some channel data was parsed from the xml file (but no programs, yet).
Lastly, go into the configuration -> channels and select the EPG data stream you need for that channel from the dropdown, for each channel. This part takes the longest. When done, click the run internal EPG grabbers button again, and you should see that you can go over to the Electronic Program Guide tab and see programs listed there.
Set the location to store recorded programs to wherever your hard drive is (eg, /mnt/disk0