Jul 22 2009

Update: See Part II of this post – all this has been improved and simplified…

I’ve been playing with get_iplayer PVR Manager (get_iplayer.cgi) on Linux (although it works on MacOSX and Windows also). It can now also act as an RTMP proxy to allow simple streaming of any flashaac radio or liveradio BBC iPlayer programme to a Slim Devices / Logitech Squeezebox (SBII or better). WARNING: This is still alpha quality experimental code….

All you need to do is:
Install and start the get_iplayer PVR Manager:

  • download get_iplayer.cgi from SVN (see the get_iplayer PVR Manager page)
  • Ensure you have flvstreamer installed and it’s location saved in your options
  • Ensure ffmpeg is installed and in the system PATH
  • Start it on your Linux server:

    perl get_iplayer.cgi –port=1935 –getiplayer=/path/to/get_iplayer –ffmpeg=/path/to/ffmpeg

Now configure the Squeezebox:

  • Go to the Squeezecenter page for your Squeezebox
  • Add a Favourite with the streaming URL. e.g. http://[server_ip_address]:1935/?ACTION=stream&PROGTYPES=liveradio&PID=bbc_radio_one&MODES=flashaac&OUTTYPE=a.wav
  • Go to your Squeezebox remote control or web page and play the favourite you have added.
  • Sit back and listen to much higher quality Radio at up to 192kbps AAC on your Hi-Fi

Similarly you can stream all sorts of programmes and modes on other http based media players. e.g.:

* Stream flash AAC liveradio as 320k mp3 stream:

vlc "http://localhost:1935/?ACTION=stream&PROGTYPES=liveradio&PID=[PID]&BITRATE=320&MODES=flashaac\

* Stream flash livetv as an flv stream:

vlc "http://localhost:1935/?ACTION=stream&PROGTYPES=livetv&PID=[PID]&MODES=flashnormal\

* Stream flash AAC liveradio as a raw wav stream:

vlc "http://localhost:1935/?ACTION=stream&PROGTYPES=liveradio&PID=[PID]&MODES=flashaac\

* Stream tv as a quicktime stream:

mplayer "http://localhost:1935/?ACTION=stream&PROGTYPES=tv&PID=[PID]&MODES=iphone\
  &OUTTYPE=nnn.mov" -cache 2048

* Stream iphone radio as http mp3 stream:

vlc "http://localhost:1935/?ACTION=stream&PROGTYPES=radio&PID=[PID]&MODES=iphone\

* Stream flash mp3 radio as http flac stream:

vlc "http://localhost:1935/?ACTION=stream&PROGTYPES=radio&PID=[PID]&MODES=flashaudio\

***PLEASE REWRITE THE DOUBLE QUOTES – this blog mangles them***

The valid [PID]s for any programme type can be determined by running:

get_iplayer –info [usual search terms]

Update (July 30th 2009): I changed SEARCH= to PID= in the latest version…Also updated to use new cmdline options. Also now works in Windows with the latest Automated Installer.
Update (September 18th 2009): I changed streaming URLs for the latest version.


  • On July 23rd, 2009, AudioBear said:

    Great idea Phil, a streamer would probably be of more use to even more peeps!

    Got it working with OSX with VLC from the command line – but the sound is jumpy, pauses etc.
    I was using:

    Looking at the VLC log I’m getting:
    “Trying to seek before the beginning
    Trying to seek before the beginning
    avformat debug: Trying to seek before the beginning
    Trying to seek before the beginning”
    The last line is repeated lots!

    In the termincal runninc vlc (when VLC opened with ‘/Applications/VLC.app/Contents/MacOS/VLC’)
    [0x24468f68] main access error: connection failed: Connection refused
    [0x8aeca8] main decoder error: no suitable decoder module for fourcc `undf’.
    VLC probably does not support this sound or video format.”

    If I try to open it in normal Mac vlc as “Open network’ URL then in get_iplayer.cgi terminal:
    “INFO Trying to stream pid using type liveradio
    INFO: pid found in cache
    INFO: Checking existence of default version
    INFO: flashaac1 modes will be tried for version default
    INFO: Trying flashaac1 mode to record liveradio: BBC Radio 2 – live
    INFO: File name prefix = liveradio__bbc_radio_two__BBC_Radio_2-live
    FLVStreamer v1.8c
    (c) 2009 Andrej Stepanchuk, The Flvstreamer Team, license: GPL
    Connecting …
    Starting download at 0.000 kB
    15.714 kB / 0.92 sec
    INFO: Streaming completed successfully
    INFO: Finished Streaming liveradio:bbc_radio_two to browser”

    I don’t have much more time this morning to look at it, but felt that this excellent post deserved at least one reply 😉

    • On July 23rd, 2009, linuxcentre said:

      If it is any help I am using: ‘VLC version 0.9.9 Grishenko’. However, ffplay and mplayer also work for me. In fact there was an error in the above post – the iphone mov files have to be streamed by mplayer not vlc using that command I gave.
      Also, the get_iplayer.cgi script does expect to find ffmpeg at /usr/bin/ffmpeg. Just go and edit the script and change it if it is wrong for you – I’ll make that a bit more flexible in future. I didn’t see your ffmpeg fire up so I guess that is probably it.

      As a more simpistic test try streaming native flv which won’t require ffmpeg.e.g.

      vlc “http://localhost:1935/stream?SEARCH=radio:b00lpptc&MODES=flashaudio&OUTTYPE=nnn.flv”

      (rewrite those double quotes though)

    • On July 23rd, 2009, AudioBear said:

      Thank you, it was of course the path to ffmpeg and also the path to get_iplayer, it works fine now, at least with radio and VLC. TV is still choppy and then stops but I’m not that worried!

      Below is an .m3u of the main BBC Radio channels that have high quality streams (Five is sometimes mono). You can open this in VLC and it will play the selected channel, assuming you are running get_iplayer.cgi on localhost and the default port (1935).

      Tips: Stop the stream in VLC before selecting another one. Give it a few second…watch the get_iplayer.cgi in the terminal. Select the next channel. Sometimes you have to select a channel, wait for it to stream, then stop the stream in vlc, wait a bit and then re-select the channel to get it to play through VLC (even though it appears to be streaming in the terminal.)

      Copy all the stuff below into a text editor, then save as ‘BBC Radio High Quality Streams.m3u’. Open the file in VLC. At least on the Mac version (vlc 1.00), it will auto play the first stream but it won’t play it. Stop the stream in VLC and then select the channel you want and click play. As above, you may have to stop and repeat. You of course have to have the get_iplayer.cgi running 😉

      #EXTM3U; For use with get_iplayer.cgi streamer service – assumes localhost & port 1935
      #EXTINF:-1,BBC Radio – BBC Radio One (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio 1Xtra (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio Two (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio Three (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio Four (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio Five (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio Five Live Sports (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio 6 Music (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Radio 7 (High Quality Stream)

      #EXTINF:-1,BBC Radio – BBC Asian Network (High Quality Stream)

      • On July 23rd, 2009, linuxcentre said:

        AudioBear – I have taken your fantastic idea of playlists and now get_iplayer.cgi automatically generates them 🙂

        Get the latest version and take a look at the comments at the top of the script for detailed examples.

        Basically use:
        vlc “”

        (rewrite the double quotes – don’t copy-and-paste)

      • On August 11th, 2009, Angela said:

        I’ve just discovered that vlc will play a BBC live radio stream directly.

        I used:-
        get_iplayer –stream 80135 –streaminfo
        to reveal:-
        as one of the streams. This is a wma stream

        Then from the command line
        “vlc http://www.bbc.co.uk/radio/listen/live/r4.asx” will play back the stream with no interruption. The other streams avaialable either do not work or fail after a minute or two.
        Radio 1
        Radio 2
        http://www.bbc.co.uk/radio/listen/live/r2.asx …well you can see the pattern.

        I now have icons on my desktop that opens Radios 2 and 4. Magic.

        • On August 11th, 2009, linuxcentre said:

          VLC will play these back directly but these are not the high quality AAC or MP3 streams – they are the somewhat inferior WMA streams.

          • On August 11th, 2009, Angela said:

            128Kb/s with 44100 Hz sample rate is good enough for just listening to talk radio!

            The reason I was hunting around is that the streams played via

            get_iplayer –stream 80135 | vlc –

            resulted in the stream playing well for several minutes then pausing more and more frequently before finally halting. This was repeatable at several times of the day and consequently, I assume, not due to bandwidth limitation.

            Using the ‘inferior’ streams results in uninterruted playback so I’m happy!

            • On August 11th, 2009, linuxcentre said:

              128kbps at 44100 Hz sample rate can be VERY bad quality – the bitrate has no bearing on quality unless you couple that with the codec and many other parameters! Even with talk radio the quality difference between these streams is noticeable by many.

              The problem you were having was most likely due to your audio / network buffer not being set long enough in vlc.

        WordPress Themes