Raspberry Pi TV/PVR
Update (26 Jan 2013)
This post is now a historical record of the hoops that I once had to jump through to get my Raspberry Pi working as a PVR. Everything has now been folded into the official OpenELEC build, which at the time of writing is at 3.0 RC2. You can download an SD card image, unzip it and copy it onto an SD card using Win32DiskImager (on Windows) or dd (on Mac or Linux) and get going on your own Raspberry Pi in minutes. If you hit any trouble then come back and read the full post (and comments) below…
Back to the original post
Inspired by a post by Tiago Pires on using the Raspberry Pi with OpenELEC as a PVR I thought I’d give it a go myself. I bought a cheap USB DVB Tuner from the same eBay supplier, but it turned out that I got a v1 device, meaning that I didn’t have to jump through the same hoops as Tiago to get v2 driver/firmware support.
I’ve found that the power draw on my USB tuner is right at the edge of what the Raspberry Pi can support. It needs a decent power supply (I’ve been using some 1A rated ones from Amazon [affiliate link]), and so far I’ve avoided using other USB devices (even keyboards or mice). A powered USB hub might improve matters (or might cause its own issues) – I haven’t tried that option yet.
The tuner comes with a little antenna, but frankly I can’t see that working unless you’re pretty much stood next to the transmitter. DVB needs a good strong signal, and I have mine plugged into an output of a house distribution TV signal amplifier.
First I needed to build OpenELEC with the PVR option:
PROJECT=RPi ARCH=arm PVR=yes make release
I installed the PVR binaries into one of my regular OpenELEC images. And confirmed that the appropriate drivers had been loaded:
root ~ # dmesg | grep 913
[ 2.498568] usb 1-1.2: New USB device found, idVendor=048d, idProduct=9135
[ 8.440492] it913x: Chip Version=02 Chip Type=9135
[ 8.441318] it913x: Firmware Version 52887808
[ 8.447402] it913x: Dual mode=0 Tuner Type=38
[ 8.447435] it913x: Unknown tuner ID applying default 0x60
[ 8.447453] dvb-usb: found a ‘ITE 9135 Generic’ in warm state.
[ 8.449127] DVB: registering new adapter (ITE 9135 Generic)
[ 8.595944] it913x-fe: ADF table value :00
[ 8.608486] it913x-fe: Crystal Frequency :12000000 Adc Frequency :20250000 ADC X2: 01
[ 8.908508] it913x-fe: Tuner LNA type :60
[ 9.568536] DVB: registering adapter 0 frontend 0 (ITE 9135 Generic_1)…
[ 9.569612] IR keymap rc-it913x-v1 not found
[ 9.634890] dvb-usb: ITE 9135 Generic successfully initialized and connected.
[ 9.634905] it913x: DEV registering device driver
[ 9.686323] usbcore: registered new interface driver it913x
The app to tune into and record TV is TVHeadEnd. This is available as an addon for OpenELEC, which can be created thus:
PROJECT=RPi ARCH=arm PVR=yes ./scripts/create_addon hts-tvheadend
Installation of the addon zip file is pretty straightforward, and once it’s running the addon is configured by browsing to a web console rpi_ip:9981
The first thing to do is configure the DVB multiplexes for your local transmitter. Add DVD Network by location didn’t work for me (I’m guessing that the database might be out of date after the UK analogue TV switch off).
I was able to get details of my local transmitter from ukfree.tv, which I could enter manually:
At this point it’s possible to hit Play and see live TV in your PC browser (provided that it has the VLC plugin) installed.
I used the Digital Video Recorder tab to configure a recording path of /storage/recordings and mounted that directory to my NAS (as an SD card won’t hold very many shows) using /storage/.config/autostart.sh:
#! /bin/sh (sleep 30;\ mount -t nfs nas_ip:/volume1/RPi_DVR /storage/recordings \ ) &
Recordings can be configured from the Electronic Programme Guide (EPG) or by setting up a regular expression to catch future programmes.
The recordings are MPEG2 streams within a .mkv container (which isn’t exactly a popular combination). These can be played on the Raspberry Pi (with OpenELEC) if you have an MPEG2 license. My main laptop had the right codecs on board to be able to play these files too, but I’ve been less fortunate with other machines that I’ve tried. I had a go at transcoding with DivX converter, but this didn’t work without an intermediate conversion to MPEG2 Transport Streams using TSMuxeR.
Live TV on OpenELEC
I’m told that it’s possible to watch TV on the RPi attached to the tuner, but I haven’t figured out how to do this myself yet (and right now I’m using a different RPi for my media player and TV receiver). To get things hooked up I added an entry to /storage/.xbmc/userdata/sources.xml in the video section:
<source> <name>Live TV</name> <path pathversion="1">htsp://10.10.10.41:9982</path> </source>
With the MPEG2 license installed and a recent build of OpenELEC I can now watch Live digital TV.
For less than £12 for the hardware and an MPEG2 license it’s possible to add Digital TV viewing, recording and playback to a Raspberry Pi based media player, which seems like a bargain.
Update 2 – 29 Sep 2012 – the build process for release bundles with media_build is now automated.
 This adaptor on Amazon [affiliate link] looks the same as what I got.
Filed under: howto, Raspberry Pi | 136 Comments
Tags: 9135, codec, divx, dvb, DVR, it913x, license, MPEG2, openelec, PVR, transcode, tv, TVHeadEnd, USB, XBMC