Jun 022012
 

Update 15 November 2016

Installing latest Get_iplayer instructions here…

https://raspi.tv/2016/get_iplayer-on-raspberry-pi-update-november-2016

Update 5 November 2014

Installing latest Get_iplayer instructions here…

https://raspi.tv/2014/get_iplayer-raspberry-pi-update

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.

RTMP timed out - trying to resume (but failing)

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.

Yay - it's resumed after a timeout.

Caveat operator

– 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
when asked
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:

sudo rpi-update

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

sudo rpi-update

At the end of this, you should have up to date firmware. You will need to reboot.

sudo shutdown -r now

Install Packages

Assuming you got through that alright, let’s navigate to a known starting point

cd /home

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…

cd get_iplayer

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.

cd /home

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

Then
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
y
confirm install without verification

Now the package update should work…
sudo apt-get update
sudo apt-get install libssl-dev librtmp-dev
y
to confirm install of the libraries required to build rtmpdump, which we’re going to do next.

Build and Install rtmpdump

Make sure we are still in the home folder.

cd /home
sudo git clone git://git.ffmpeg.org/rtmpdump
cd 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 ;)

Test with
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.
cd /home
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…

cd ffmpeg

Note that the following command from ./configure to --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.)

sudo make

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
sudo ldconfig

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

cd /home/get_iplayer
then
./get_iplayer
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.

part of get_iplayer program list

part of program list

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…

-o /path/to/file-destination

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

All those 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.

cd /home
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.

  33 Responses to “Get_iplayer – full instructions for Raspberry Pi install from scratch”

  1. Can you tell me what sockets rpi-update uses when connecting to the internet?
    I receive the following error & I suspect a new firewall rule at the perimeter is needed to allow access.

    github.com[0: 207.97.227.239]: errno=Connection timed out
    fatal: unable to connect a socket (Connection timed out)

  2. Thank you Alex.

  3. Cheers fella :)

    I chown’d the ffmpeg, rtmpdump & get_iplayer directories to ‘pi’ and also when running the cgi for the GUI had to add an extra ‘get_iplayer’ to the path to get_iplayer, but it’s all working now thanks! :)

  4. One simplification: You don’t need to install flvstreamer. rtmpdump handles all the Flash media streaming in get_iplayer (rtmpdump supplanted flvstreamer a couple of years ago). Plus, you won’t be able to download any HD programmes with flvstreamer since it lacks SWF verification functionality.

    • Thank you. I didn’t know that. :) I’ve amended this now having done it this way when I did a fresh install on wheezy. It works perfectly well without flvstreamer, so thanks for that one :)

  5. Hello mate

    Can you help, getting the following when requesting the big compile

    pi@raspberrypi:/home/ffmpeg$ sudo make
    Makefile:2: config.mak: No such file or directory
    Makefile:47: /common.mak: No such file or directory
    Makefile:89: /libavutil/Makefile: No such file or directory
    Makefile:89: /library.mak: No such file or directory
    Makefile:169: /doc/Makefile: No such file or directory
    Makefile:170: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    pi@raspberrypi:/home/ffmpeg$

    Looks pretty fundamental, any ideas?

    Thanks a lot

    Gavin

    • Ouch. Looks like something is messed up or missing to me. My first thought was one of the libraries might be missing? Or maybe something went wrong with the git clone? Or could it be a permissions issue? I’m speculating really. Did you accidentally omit or make an error in the sudo ./configure command before the make? Just ideas – I don’t know for sure.

  6. Did get 1 error from sudo ./configure

    ERROR: libgsm not found

    could this be the problem?

    • When you did this command…

      sudo apt-get install libfaac-dev libmp3lame-dev libx264-dev libxvidcore-dev libgsm1-dev libtheora-dev libvorbis-dev

      did you include the libgsm1-dev bit? Looks as if the config might think it’s missing?
      Could always try it again in case it was mistyped or something?

      sudo apt-get install libgsm1-dev

      NOTE THAT IT’s LIBGSM1 as in the last digit is number one. I sometimes get messed up with ones and lower case letter L.

      and if it installs, you might have mistyped that part and not noticed when it didn’t install. I’m still guessing. There could also have been an issue with the ./configure command itself I suppose?

  7. […] may remember from the Get_iplayer installation instructions that I recommended not running the FFMPEG compile via ssh. The reason for this was because when you […]

  8. As per the default Debian install, I left swap disabled. Compiling ffmpeg fails with an message “out of memory” message. I enabled my swap file, and it successfully compiled: Would a mention of this be useful?
    It now finds the programmes, but refuses to download (I entered the –get command exactly as above): It only tries flashhigh1,flashhigh2,flashstd2, not flashhd,flashvhigh,flashhigh,flashnormal.
    Any thoughts?

    • It looks like the latest firmware update might have messed with something? What version are you using?

      The output from uname -a will show you what version you have.

      Also, not many programmes are broadcast in HD. To see which ones are, you can
      ./get_iplayer --category hd then pick one of those.

      I have noticed recently that RTMPdump occasionally selects a lower resolution than the maximum. No idea why. If you know a programme is in HD, you could try deleting previous versions of it and then use…
      ./get_iplayer --get 456 --force --tvmode=flashhd

      Then if it can’t give you the hd, it will just say so instead of downloading a lower res version you don’t want. The –force will force it to try again on a programme it has already done.

    • Further to my previous post, the console output for my failure to download problem is:

      jim@raspberrypi:/home/get_iplayer$ ./get_iplayer –get 460 –tvmode=flashhd,flashvhigh,flashhigh,flashnormal
      get_iplayer v2.82, Copyright (C) 2008-2010 Phil Lewis
      This program comes with ABSOLUTELY NO WARRANTY; for details use
      –warranty.
      This is free software, and you are welcome to redistribute it under certain
      conditions; use –conditions for details.

      Matches:
      460: League of Super Evil: Series 2 – 14. L.O.S.E the M.O.V.I.E., CBBC, Animation,Children’s,Entertainment & Comedy,TV, default

      INFO: 1 Matching Programmes
      INFO: Checking existence of default version
      INFO: flashvhigh1,flashvhigh2,flashhigh1,flashhigh2 modes will be tried for version default
      INFO: Trying flashvhigh1 mode to record tv: League of Super Evil: Series 2 – 14. L.O.S.E the M.O.V.I.E.
      INFO: File name prefix = League_of_Super_Evil_Series_2_-_14._L.O.S.E_the_M.O.V.I.E._b00z1c1m_default
      RTMPDump v2.3
      (c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
      Failed to open file! /home/get_iplayer/League_of_Super_Evil_Series_2_-_14._L.O.S.E_the_M.O.V.I.E._b00z1c1m_default.partial.mp4.flv
      INFO: Command exit code 1 (raw code = 256)
      WARNING: Failed to stream file /home/get_iplayer/League_of_Super_Evil_Series_2_-_14._L.O.S.E_the_M.O.V.I.E._b00z1c1m_default.partial.mp4.flv via RTMP
      INFO: skipping flashvhigh1 mode
      INFO: Trying flashvhigh2 mode to record tv: League of Super Evil: Series 2 – 14. L.O.S.E the M.O.V.I.E.

      —SNIP—

      WARNING: Failed to stream file /home/get_iplayer/League_of_Super_Evil_Series_2_-_14._L.O.S.E_the_M.O.V.I.E._b00z1c1m_default.partial.mp4.flv via RTMP
      INFO: skipping flashhigh2 mode
      ERROR: Failed to record ‘League of Super Evil: Series 2 – 14. L.O.S.E the M.O.V.I.E. (b00z1c1m)’
      jim@raspberrypi:/home/get_iplayer$

      • Try deleting

        /home/get_iplayer/League_of_Super_Evil_Series_2_-_14._L.O.S.E_the_M.O.V.I.E._b00z1c1m_default.partial.mp4.flv

        from your output directory and try again. I’ve come across this before. After a failed attempt you have to delete the file.

  9. Alex: thanks for the reply. I’m using this version:

    jim@raspberrypi:/home/get_iplayer$ uname -a
    Linux raspberrypi 3.1.9+ #110 PREEMPT Wed Jun 13 11:41:58 BST 2012 armv6l GNU/Linux
    jim@raspberrypi:/home/get_iplayer$

    I tried your suggestions, but with the same results as before. Here is an extract from the output:

    INFO: 1 Matching Programmes
    INFO: Checking existence of default version
    INFO: flashhd1,flashhd2 modes will be tried for version default
    INFO: Trying flashhd1 mode to record tv: Jools Holland – London Calling
    INFO: File name prefix = Jools_Holland_-_London_Calling_b01jxzfq_default
    RTMPDump v2.3
    (c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
    Failed to open file! /home/get_iplayer/Jools_Holland_-_London_Calling_b01jxzfq_default.partial.mp4.flv
    INFO: Command exit code 1 (raw code = 256)
    WARNING: Failed to stream file /home/get_iplayer/Jools_Holland_-_London_Calling_b01jxzfq_default.partial.mp4.flv via RTMP
    INFO: skipping flashhd1 mode

    • Is it a permissions issue? You are trying to download into the get_iplayer directory. Do you have the right permissions?

  10. A big thankyou, it all works now.
    It was permissions – chmod 777 fixed it.
    I should have realised, especially as Nommo mentioned it earlier in the thread.

  11. […] If you have the Debian Squeeze Raspberry Pi release you need to click here and use these different instructions. […]

  12. Thanks for the instructions- this is the first time I’ve got get_iplayer working on Linux!

    I’m using RaspBMC (the Raspberry Pi build of XBMC) and have got get_iplayer working following these instructions, with a few caveats:
    – The rpi-update doesn’t work, but it works perfectly well without so I’m assuming it’s not necessary
    – RaspBMC doesn’t come with make installed so you need to “apt-get install make” before you can compile
    – DON’T GET RTMPDUMP FROM APT! I tried it first, thinking I’d just build from source if it didn’t work, and it didn’t- but even after building it from source I was still getting “failed to read RTMP packet header” messages. I restored my card to a snapshot from before I started and redid the process, but didn’t install RTMPdump using apt-get and it all works brilliantly. (I haven’t built ffmpeg from source because I’m too impatient to wait 3.5 hours for it, but the apt package of that seems to work OK, and even without it XBMC will play FLVs)
    – Finally, XBMC mounts FAT32 USB storage with some write permissions denied, which you can’t change once it’s mounted. To let get_iplayer write to your USB storage you’ll need to mount it with a dmask of 000 to enable all write permissions (so, for example, sudo mount -t vfat /dev/sda1 /media/usb0 -o dmask=000). There’s probably a way to make it do this automatically in /etc/fstab but I haven’t figured it out yet.

    I hope someone finds these useful! Raspberry Pi + XBMC + get_iplayer = a winning combination :)

    • I think RTMPdump is more critical to have an up to date version than FFMPEG, as all the FFMPEG conversion does is repackage the FLV container to mp4 – it’s still an H.264 encoded video within.

      I would have made a download available for the compiled FFMPEG, except for the fact that it uses some non-free components, which makes it OK to make yourself, but not OK to share :cry:

      I didn’t realise XBMC could play FLV files. I’ve got cards with OpenELEC and RaspBMC, but haven’t tried to view an FLV. For some reason I would have assumed it wouldn’t work. (I guess it’s because we’ve been repeatedly told “no flash, no flash, no flash” – but there’s a difference between running flash and viewing a flash video file).

  13. Just wanted to say brilliant instructions. Followed to the letter and have now downloaded a programme that I forgot to record last night.

    It’s worked a treat and is downloading 1280×720 of 90 mins programme.

    Thanks

    • Fantastic. The thing I like most about using get_iplayer is that the recordings are portable. It’s more convenient than recording on our PVR because we can then watch things away from home on my phone, or any of a number of other devices. :-)

  14. Hi…..followed the instructions, but when I try to download a program I get error message saying no SWF verification……any ideas?
    thanks

    • Did you compile RTMPdump or just do the “quick and dirty” method? I’m under the impression that BBC changed something fairly recently that made it important to have recent versions of the get_iplayer scripts and RMTPdump. It could also be a temporary fault at the BBC site, so worth trying again a couple of times over the next few days before you tear your hair out over a problem that may not be at your end. :-D

  15. […] If you have the Debian Squeeze Raspberry Pi release you need to click here and use these different instructions. […]

  16. Hello, thanks for this, I have been running get_ipalyer on Ubuntu since it’s inception, I am now running a Pi, with wheezy
    2013-02-13, are the instructions any different?

Leave a Reply