Saturday, 15 June 2013

rPi + tvheadend + shepherd

My home TV setup involves a file server (FreeNAS), a Mac Mini running XBMC and a Raspberry Pi running TVHeadend.

In setting up the rPi side of this, I came across a lot of scattered instructions so I thought I'd bring them together. Nothing is particularly difficult but I suspect I'll be doing this again at some stage in the future so for the sake of myself and others...

Edit: It's actually pretty easy to use rasbian and build tvheadend from head now. This will save you messing with raspbmc's init scripts and the kernel modules mentioned below are now in the stock rasbian kernel so your job there also just got easier. Finally, tvheadend does such an awesome job at EIT OTA tv guide data that I have dropped shepherd completely and live happily with guide information that only gives me about a weeks notice of upcoming programming.


  1. Download raspbmc (kernel 3.6.11 at time of writing). At the time of writing the network boot version was looping, failing to install modules so I went with the standalone image.
  2. dd if=<file> of=/dev/sdX
  3. Boot pi.
  4. ssh pi@<ip> (password raspberry)
  5. Setup locale as prompted.
  6. Disable xbmc and patch tvheadend script to start after mounting filesystems:
$ sudo -i
# chmod a-x /scripts/
# vi /etc/init/xbmc.conf
 -start on (started dbus and started mountall)
 +#start on (started dbus and started mountall)
# vi /etc/init/tvheadend.conf
 -start on (started xbmc and enable-tvheadend)
 +start on (started dbus and stopped mountall)


Install dependencies for and download shepherd:
$ sudo apt-get update && sudo apt-get install libxml-simple-perl libalgorithm-diff-perl libgetopt-mixed-perl libdata-dumper-simple-perl libdate-manip-perl liblist-compare-perl libdatetime-format-strptime-perl libhtml-parser-perl libxml-dom-perl libgd-gd2-perl libarchive-zip-perl libio-string-perl xmltv libdbi-perl libsort-versions-perl && wget '' && perl shepherd  
... answer prompts then go to bed. This will take a while. ...

To have the tv_grab_au script picked up by tvheadend, symlink it to /usr/bin:
$ sudo ln -s /home/pi/.shepherd/tv_grab_au /usr/bin/tv_grab_au

RTL2832U kernel module

I've tried an AF9015 device (TinyTwin V3) and the quality of the drivers are terrible. It half works but has issues with I2C signalling, the IR remote and use of both tuners concurrently. In the end I gave up and went with an RTL2832U single-tuner device I had (EZCAP). The kernel module for it doesn't come with stock raspbmc. You can build it yourself or opt for the lazy option and download it here.
<build/download module and copy to /lib/modules/3.6.11/kernel/drivers/media/dvb/dvb-usb/>
$ sudo depmod -a


The changes to date should take effect. You should be able to connect to tvheadend at http://<ip>:9981. Add muxes for Australian locations and select the XMLTV: tv_grab_au option in the EPG settings. The first EPG run will take a while. Shepherd is intentionally very slow with its EPG crawling.