Raspberry Pi DVR: Difference between revisions

From Alnwlsn - Projects Repository
Jump to navigation Jump to search
(Created page with "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 radi...")
 
 
(11 intermediate revisions by the same user not shown)
Line 8: Line 8:


==General Setup Procedure==
==General Setup Procedure==
Install Raspbian. Add a blank <pre>SSH</pre> named file in the boot partition to enable ssh server. Run <pre>rasppi-config</pre> and go through all the usual setup stuff, but allocate more memory to the CPU (no need for GPU memory when headless).
Install Raspbian. Add a blank <code>SSH</code> named file in the boot partition to enable ssh server. Run <code>rasppi-config</code> 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 <pre>/mnt/disk0</pre>. Edit fstab located at <pre>/etc/fstab</pre>
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 <code>/mnt/disk0</code>. Edit fstab located at <code>/etc/fstab</code> and add line <pre>UUID=34bc2462-9358-424a-b27a-fa1803efd097 /mnt/disk0 ext4 defaults,nofail 0 0</pre> replacing with your disk's uuid. Now the drive will automatically mount to <code>/mnt/disk0</code> on boot.
 
Install missing firmware for your tv tuner. For mine, I needed to get a file called
<code>dvb-fe-xc5000-1.6.114.fw</code> and put it in <code>/lib/firmware/</code> though I found it was already there in the newer raspbian releases. Check <code>dmesg</code> to make sure the tuner is recognized after a reboot.
 
Do apt-get update. May want to upgrade too.
 
Install tvheadend using the procedures listed at https://tvheadend.org/projects/tvheadend/wiki/AptRepositories.
 
Upon reboot, go to <raspiip>: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 <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>
 
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 <code>/usr/bin</code> 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> Do a test recording and make sure the file can be written to the disk; if not, check permissions first.

Latest revision as of 01:42, 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. May want to upgrade too.

Install tvheadend using the procedures listed at https://tvheadend.org/projects/tvheadend/wiki/AptRepositories.

Upon reboot, go to <raspiip>: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 Do a test recording and make sure the file can be written to the disk; if not, check permissions first.