Last week when I wrote about the BBC iPlayer addin for the the Raspberry Piand I got it working on the standard Debian build with VLC Player which was ok for testing but playback performance pretty poor. So I thought what would be a more useful project if the Raspberry Pi could download the BBC shows and then serve them out so I could watch them from devices like iPhone, TVs and PCs using UPNP. Of course you could just stream BBC shows via iPlayer and not bother downloading them but this way works with devices that are not supported by iPlayer and you get to keep the files. So there are two parts to the project, there is the iPlayer downloading software and there is the UPNP server. On the client side all you will need is a UPNP client and we can look at that later.

Part One – UPNP Server

There are a few different ways to achieve this and the one I am going to use is MediaTomb. To get this installed you can either download the SqueezePlug for the Pi and install a UPNP server form there (see this postfor details) or you can install MediaTomb directly from your Debian build. Installing MediaTomb is pretty simple as is a Debain package for it, so just type:

sudo apt-get install mediatomb

After installing MediaTomb you can access it via the browser using the IP address of the Raspberry Pi and the default port which is 49152, so it would be http://yourpiaddress:49152and the user name “mediatomb” with the password “mediatomb”. You can change the port, username and password by editing the XML file

sudo nano /etc/mediatomb/config.xml

We will come back to MediaTomb after we have the iPlayer part working.

Part Two – iPlayer

To get the iPlayer video files you can use a great Linux program called get_iplayer. To get this working you need to get the application and some modules to convert the file to mp4 automatically (details taken from this post). First get the program :

sudo wget ftp://ftp.infradead.org/pub/get_iplayer/get_iplayer-2.82.tar.gz

Next extract the gz file and un-compress the tar file:

sudo gzip -d get_iplayer-2.82.tar.gz

sudo tar -xf get_iplayer-2.82.tar

Next there are a couple of permission issues to fix:

sudo chmod 755 get_iplayer  

sudo chmod 777 get_iplayer

Now to install the perl, flvstreamer and ffmpeg modules:

sudo apt-get install libwww-perl

sudo apt-get install rtmpdump

sudo apt-get install flvstreamer

sudo apt-get install ffmpeg

Next I created a directory to dump the content into and tell the program to put the files there.

mkdir /iplayer export IPLAYER_OUTDIR=”/iplayer”

Now you can go back to the Mediatomb browser and add the iplayer folder to the database. To do this login via the browser, click on the Filesystem link and from the folder tree select the iplayer folder and click on the + icon.  This adds the folder to the upnp server and any content downloaded from iPlayer will show up in this folder.

image

Now you can download BBC shows via the command line and you need to know the ID of the show to download it. You can find the ID by doing a search from the command line: First run the program

./get_iplayer

Then you search by using ./get_iplayer search term e.g

./get_iplayer “Formula 1”

imageWhich in my case lists two shows, to download the show you need the id number

./get_iplayer  –get 302

A .flv file is downloaded which then gets automatically converted to a mp4. You can stream that file from a UPNP client. I tried it on XBMC and my Samsung Galaxy Note and it worked fine, you can also use Windows Media Player or any UPNP/DLNA client. image image For this project there is a lot more still to do, I want to come up with a UI that is better than the command line UI I have at the moment. I am using SSH to get on to the Raspberry Pi remotely so it’s a headless system but it would be nice to have a GUI for it. Also you could automate the capture of the TV shows, so you could create a script that checks for new shows and automatically downloads them. Part three will look at the UI and automation.

3 thoughts on “Project: BBC iPlayer server for the Raspberry Pi”
  1. A couple of points:

    1. If you’re going to “sudo” wget, gzip and the like, you might as well just “sudo” bash and be done with it!
    2. Did you really mean this line to look like this?: “sudo chmod 755 get_iplayer sudo chmod 777 get_iplayer” – you’re changing the mode on the same target twice as far as I can see, and the second time to rwxrwxrwx?
    3. If you pass the –get parameter to get_iplayer when searching it will go on and download anything that matches your search (e.g. get_iplayer –get “Formula 1”), so if you’re confident in what your search will match then you don’t need to muck about with id numbers. It’s also smart enough to not re-download anything it’s downloaded before (even if you’ve since deleted it – –force overrides that behaviour)
    4. get_iplayer has a whole bunch of “PVR” options that let you schedule recordings and download new instances as they become available, so your script for automating the capture could turn out to be very simple really.

    All you need now is a light web server with a bit of clever web scripting to manage the scheduling of recordings and you’re away 🙂

    Cheers, Steve

  2. I have completed a similar project, which automatically downloads content from iPlayer using get_iplayer’s PVR function and creates a podcast RSS feed which I then subscribe to from my phone, ipod, pc.

    You may find it useful to use the Web UI which comes with get_iplayer, as an alternative to find and downloading programs via a command line

    By using the PVR functions of get_iplayer you can also subscribe to a complete series which if then run as a scheduled job will automatically download content as and when it appears in iPlayer.

    See Raspberry Pi – BBC iPlayer Personal Podcast for how the Pi makes this work.

Leave a Reply