Sat, 08 Mar 2008

BBC iPlayer on the iPhone

Posted by Ben Sat, 08 Mar 2008 18:23:00 GMT

Yesterday the BBC announced that their iPlayer video on demand service was available for the iPhone (and iPod Touch). There’s a more in depth post on the BBC Internet Blog where they give details on the technical implementation.

Back to BBC iPlayer on iPhone implementation: we’re not using the new Apple SDK, nor are we using the much-rumoured Flash for iPhone (no – we haven’t seen it, either). Instead, we’re creating 516Kbps streams (400Kbps H.264 video, 116Kbps AAC audio) that show off BBC programmes brilliantly on an iPhone.

It’s interesting to read about the raw processing power required to transcode their 24 simultaneous incoming programmes, for a peak data rate of over a gigabit per second of incoming video.

I tried out an episode of Top Gear and was impressed with both the streaming speed and the quality of the video (check out the images below). The only downside is that it only supports streaming and requires a WiFi connection; unsurprisingly, EDGE isn’t fast enough. Ideally it would be fantastic to be able to download a programme to watch ‘offline’, such as on a train (I’ll keep my finger’s crossed).

Update

I knocked up a quick Ruby script to download the mp4 files that the iPhone version uses (it uses wget).

ruby iplayer_download.rb http://www.bbc.co.uk/iplayer/page/item/b0074fvk.shtml

Now enhanced with the help of Richard & Richard via the comments.

Comments

Leave a response

  1. Jon 1 day later:

    Wow – that’s some excellent news.

    I also owe you a beer for the download script, which hopefully will mean I can stop rebooting into Windows just to download some TV!

  2. Richard Lewis Jones 1 day later:

    The script works a treat. Nice one. A small tweak—change the system line to read:

    system "wget -O #{pid}.mov http://www.bbc.co.uk/mediaselector/3/auth/iplayer_streaming_http_mp4/#{pid}"

    ...so the rename is done automatically.

  3. Richard Bowman 2 days later:

    I’ve modified it so it automatically names the file with the title of the programme:

    #!/usr/bin/ruby -w
    require 'open-uri'
    
    IPHONE_USER_AGENT = "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3" 
    
    def download_movie(url)
      # Get html for movie page (as an iPhone UA)
      htm = open(url, {'User-Agent', IPHONE_USER_AGENT}).read
    
      # Get the pid of the movie
      pid = htm.match(/pid\s+:\s+'([a-z0-9]+)'/i)[1]
    
      # Get the pid of the movie
      title = htm.match(/prog\s+=\s+"\s*(.*)\s*"/i)[1]
      dest = "#{title}.mov" 
    
      # Download the mp4 file (uses wget)
      puts "Downloading mp4 file of #{title} (http://www.bbc.co.uk/mediaselector/3/auth/iplayer_streaming_http_mp4/#{pid} to (#{dest})"  
      system "wget -O\"#{dest}\" http://www.bbc.co.uk/mediaselector/3/auth/iplayer_streaming_http_mp4/#{pid}" 
    end
    
    if ARGV.length == 1
      download_movie(ARGV.first)
    else
      puts "usage: ruby iplayer_download.rb <iplayer programme URL>" 
    end
    
  4. Ben 3 days later:

    Thanks for the updates Richard & Richard, I’ve updated the post with a link to the enhanced script.

  5. Ben 3 days later:

    I stumbled across a few more useful resources…

  6. Ben 6 days later:

    The BBC have ‘fixed’ the iPlayer so the original method no-longer works. Don’t worry, this has been circumvented already (download the Ruby script).

Comments