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 :
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.
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
Then you search by using ./get_iplayer search term e.g
./get_iplayer “Formula 1”
./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. 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.