Get_iplayer is an excellent program that allows you to download content streamed from the BBC’s iplayer server, to watch at a time convenient to you. What makes it excellent is that it is entirely under your control. There is no DRM or restrictions on the content you download. And you don’t need to have the iplayer app on your computer, which is a good thing because it won’t run on the Pi – no Flash.
It’s an Open Source iPlayer client, that works on pretty much any platform supporting PERL (which the Raspberry Pi certainly does). It also has PVR functionality and an HTML interface that I have yet to scratch the surface of.
How does it work? There’s a clever system for querying and searching the programmes available on the BBC iPlayer site. Once you’ve chosen what to record, it uses RTMPdump to record the incoming flash video stream and dump it in a file. Then once the whole thing is downloaded, it uses FFMPEG to strip the H.264 mp4 video out of the flash “wrapper” in a process called transcoding. (You have to learn a whole new language here )
You end up with an H.264 mp4 file which you can watch on your Raspberry Pi using Omxplayer, XBMC, RaspBMC or OpenELEC – and in future, no doubt, many other media playing systems yet to be developed. You can also watch these on pretty much any other computer or media player. My Samsung TV can cope with these if I put the mp4 files onto a USB stick and plug it into the telly.
Some of the content is available in 720p HD (1280 x 720 pixels), but most programmes are available in at least 832 x 468.
I’d discovered and been messing about with get_iplayer on Ubuntu for about a month before LetHopeItsSnowing on the Raspberry Pi forums posted about getting it up and running on the Pi. It worked, kind of, almost out of the box. But it tended to time out a lot and when it did time out, it would hang the process.
There followed a week or so of trying various approaches to getting it fully up and running with the latest versions of get_iplayer itself, RTMPdump and FFMPEG. I joined the get_iplayer mailing list and received excellent help and instructions from dinkypumpkin and tommy.
I decided to blog this, partly as a thank you to them, so that any future Raspberry Pi owning Linux newbs would have all the instructions they needed in one place at the end of a single URL.
I have now got my Raspberry Pi get_iplayer installation capable of downloading full length programmes in HD without timing out or giving error messages. If this is what you are after, read on. I warn you, though, it will take some time, but if you are relatively new to Linux, you will learn something – it will be well worth it.
We will cover getting hold of the latest package versions, installing required libraries, updating the raspberry pi firmware, and updating and locally compiling RTMPdump and FFMPEG, which should give you a stable install. So you shouldn’t have to see a 720p programme suffer an RTMP timeout at 97% downloaded, requiring you to start all over again.
- let the operator beware! Things change with time. It is possible that something could go wrong. The Raspberry Pi firmware is updated regularly at the moment. That could mess something up. I’m showing you how to get the latest versions of some things. When these change it could mess something up. I may not know enough to help you if you run into problems. But others will.
There are no guarantees, but I have been through the entire process (including the 3.5 hour compilation) from scratch with a freshly flashed Debian install to check the procedure and give precise, complete instructions that could be followed by someone with no previous Linux experience.
Last of all, there’ll be some brief instruction in how to use get_iplayer to record your programmes. If this page gets too long I may split it over a couple of blog posts.
All commands you have to type will look like this…
type this command and then press <enter>
…which should make it easy for you. If you are logged into your Pi by ssh, you could even cut and paste to make it super easy.
Starting point assumptions.
I’m assuming that you have an SD card (4 Gb & up – 2Gb is not enough for compiling FFMPEG) Raspberry Pi booted up into a clean install of a Debian Squeeze distribution you got from the Raspberry Pi download page. The current version at the time of writing is debian6-19-04-2012.
If you have the Debian Wheezy Beta released on 19 June 2012, the instructions are different, click here to go to the Get_iplayer Wheezy Beta installation instructions.
If you have the Raspbian Wheezy Beta released on 15 July 2012, the instructions are different, click here to go to the Get_iplayer Raspbian Wheezy installation instructions.
The first thing we’re going to do is update it to the latest firmware using Hexxeh’s rpi-update.
Before we do that let’s ensure all our package information is up to date. It’s good practice to do this before installing something new. If you are logged in as the user called root, you won’t need the sudo, but including it won’t hurt.
sudo apt-get update
This will update your packages and may take a few minutes. If you get a message about “Duplicate sources… You may want to run apt-get update to correct these problems” go ahead and run it again.
sudo apt-get update
That should clear it. Now to the firmware update.
Instructions edited from https://github.com/Hexxeh/rpi-update
To install the tool, run the following command
sudo apt-get install ca-certificates
y to continue.
The certificates take a couple of minutes to install. Then type…
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update
sudo chmod +x /usr/bin/rpi-update
To then update your firmware, simply run the following command:
If it prompts you to install Git, do that now…
sudo apt-get install git-core
y to confirm when prompted.
This installs git, which is a version control system we will need to access the latest versions of various packages.
Now rerun rpi-update
At the end of this, you should have up to date firmware. You will need to reboot.
sudo shutdown -r now
Assuming you got through that alright, let’s navigate to a known starting point
and install some required packages. If you want a quick and dirty install of get_iplayer (I recommend doing it properly, so best to skip this one) to try out, use this command…
sudo apt-get install libwww-perl rtmpdump ffmpeg
These will take several minutes to install. Quick and dirty works some of the time, but I had issues with it timing out and not recovering – basically if the download times out, the process has to be restarted. It happened often enough to be annoying, so I looked for a better way. You can try this first if you want (it’s not irreversible).
If you want to do it “properly” with the latest versions of everything right from the start you need to leave out rtmpdump and ffmpeg at this stage like this…
sudo apt-get install libwww-perl
y to confirm
We’re going to build (compile) and install rtmpdump and ffmpeg from the latest source code for the “proper” version.
Regardless of whether you chose “quick and dirty” or “proper”, you will need to get hold of the latest version of get_iplayer…
sudo git clone git://git.infradead.org/get_iplayer.git
This will create a new folder called get_iplayer in your /home folder. All the get_iplayer files are in this folder. Let’s go there…
we need to make the get_iplayer file itself writeable or it won’t work properly, so…
sudo chmod 777 get_iplayer
This changes its permissions so it can be read, written to and run by anyone.
Then, if you did a “quick and dirty” install, you should be good to go. Skip to the bottom to see how to start using get_iplayer.
If you’re on the “properly” track, we’ve got some more work to do, but it will be worth it when your install can withstand a timeout. Let’s get back to our home folder so we know where we are.
Now we’re going to edit a file which contains the sources of debian repositories. We’ll do this with nano – a text editor.
sudo nano /etc/apt/sources.list
Then use the cursor keys to get to line 3 and add…
deb http://www.deb-multimedia.org/ squeeze main non-free
CTRL-X to exit
y to confirm you want to save
enter to confirm the filename (don’t change it)
sudo apt-get update
It will update some package lists and give two errors. W: GPG error and W: Duplicate sources… We’ll deal with those next…
sudo apt-get install deb-multimedia-keyring confirm install without verification
Now the package update should work…
sudo apt-get update to confirm install of the libraries required to build rtmpdump, which we’re going to do next.
sudo apt-get install libssl-dev librtmp-dev
Build and Install rtmpdump
Make sure we are still in the home folder.
sudo git clone git://git.ffmpeg.org/rtmpdump
sudo make SYS=posix
You will now see a some lines starting “gcc -Wall” and the process will take a few minutes. When it finishes, you’ve just compiled the latest version of rtmpdump. Now we need to install it…
sudo make install SYS=posix
You should then see some lines starting “cp” and “mkdir” as the files are copied over to their new homes. You have now compiled and installed rtmpdump. Congrats
rtmpdump -v to check you are running the latest v2.4 (at the time of writing). Ignore the hostname error. We’ve got what we wanted. Onward.
Build and Install FFMPEG
Now I’ve got some good news and bad news for you. The good news is that our typing is nearly done. The bad news is that FFMPEG is quite a large, complex program and takes about 3.5 hours to compile on the Pi. But as long as you know this, you can plan round it, right?
Let’s get back to home so we don’t end up putting FFMPEG inside the rtmpdump build folder.
sudo apt-get install libfaac-dev libmp3lame-dev libx264-dev libxvidcore-dev libgsm1-dev libtheora-dev libvorbis-dev
From sudo to dev is is all one line. It installs all the development libraries required to build FFMPEG. Now let’s get the FFMPEG files themselves.
sudo git clone git://source.ffmpeg.org/ffmpeg.git
This is quite a large download and will take a little while (10-20 mins). Once complete…
Note that the following command from
--enable-nonfree is all one continuous command.
sudo ./configure --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-libgsm --enable-postproc --enable-libxvid --enable-libfaac --enable-pthreads --enable-libvorbis --enable-gpl --enable-nonfree
After a minute or so, you will get a warning about pkg-config not found. Ignore it. It’ll still work. Now to compile.
WARNING! Once you press <enter> for the sudo make command it will tie up your Pi for about 3.5 hours until the compile is finished. (If you are accessing your Pi via ssh, you might want to run it via screen, so you can detach and reattach without killing the process.)
This will show you what it is doing as it goes. There will be lots of scary messages you don’t understand. Best go and do something else. And best run the “sudo make” directly on the Pi if you can. If you do it by ssh you’ll have to leave your other computer on and connected until it finishes.
Once compiled, the install is a fair bit faster (~2 minutes).
sudo make install
So we don’t stumble across permissions issues, if you are going to be logging in as a normal user (pi) rather than root, we need to give ourselves ownership of these directories…
sudo chown -R pi /home/get_iplayer
sudo chown -R pi /home/ffmpeg
sudo chown -R pi /home/rtmpdump
It won’t work, for me, using the pi login without chowning the get_iplayer directory. I’m not 100% sure if it’s necessary to chown the ffmpeg and rtmpdump directories, but I can’t see it doing any harm.
Now your installation is finished, let’s try it out.
Starting using get_iplayer
Go to your get_iplayer directory
If it tries to update and gives an error message, stick a sudo in front of the command
sudo ./get_iplayer then
sudo chmod 777 get_iplayer
The above probably won’t be necessary for you, but it was for me because, as luck would have it, a new release (2.82) was pushed to git (published) while I was compiling FFMPEG to test this procedure.
Run get_iplayer and once it’s finished updating plugins etc. It will update the program list. You’ll know when that happens you will see about 1000 programmes displayed.
Then you use it like this.
./get_iplayer keyword (substitute keyword for a keyword in a programme title)
This will result in a list of programmes (or none) with that keyword in. Make a note of your chosen programme’s ID number e.g. 460
Then, to download programme 460, type this
./get_iplayer --get 460 --tvmode=flashhd,flashvhigh,flashhigh,flashnormal
This will download the program at the best available resolution to your get_iplayer folder on your SD card, which you probably don’t want. I generally put my downloads on a USB memory stick. You can redirect the download wherever you like using…
so for me, with a USB stick mounted at /media/usbstick, the full command would be…
./get_iplayer --get 460 --tvmode=flashhd,flashvhigh,flashhigh,flashnormal -o /media/usbstick
flashhd etc. options ensure you download at the best available resolution.
To mount a USB flash drive/memory stick or other device click here for the procedure
Back Up Your FFMPEG Compile?
One more thing. It might be a good idea to back up your compiled FFMPEG files in case you ever want to re-flash your SD card. If you copy it onto a stick – (here’s how to handle mounting a USB stick), you won’t have to recompile.
sudo tar -cvzf /media/usbstick/targetfile.tgz /home/ffmpeg
This will make a full zipped archive of your ffmpeg files.
Well done and happy recording
I hope this has helped you learn how to install get_iplayer on the Raspberry Pi. Enjoy using it.