Monday, January 18, 2010

Ubuntu Boxee and get_iplayer on the Acer Aspire Revo

A little while ago I bought an Acer Aspire Revo 3600 which is basically a small PC suitable for media playback. It has HDMI out and plays up to 1080p HD video in certain formats, so is ideal for connecting to a TV to consume video content. I previously blogged about the Acer, and how I setup the device for use with Boxee on a pre-release version of Ubuntu. I wanted to post some updated detail because people keep asking me how the Acer is going, and how I’m using it.

My use cases are quite straight forward. I wanted a box which would sit near the TV and allow me to play back HD content. I don’t have a blueray player or Freesat HD, but I do already have a Freeview (standard definition) hard disk recorder – a Humax 9200T. As a result I have the ability to record terrestrial television programmes – and the whole family use the Humax to record and watch TV. The Humax has a limited (160GB) disk capacity, so we tend to use it for ad-hoc recording and ad-skipping rather than longer-term storage.

I like the flexibilty that tools like MythTV offers, specifically being able to watch programmes in other rooms on different devices, but right now the Humax does enough that I’ll not be using MythTV. Instead I’ve been playing with Boxee and XBMC to playback HD media on the Acer. The Acer has a standard installation of Ubuntu 9.10 which was installed by downloading the ISO image and putting it onto a bootable USB stick. Everything worked out of the box including wired & wifi network, VGA & HDMI video out, audio over HDMI and everything else besides. It boots fairly pretty fast, but as it consumes about 25W I tend to leave it switched on.

As this sits behind the telly and is to be used by all of the family I didn’t want to have a keyboard and mouse either trailing across the room or a wireless one stashed as they’re often cumbersome and not small-child friendly. I do have the original white USB keyboard and mouse stashed behind the telly permanently connected to the device just in case things go bad and I need to directly control the device. However I rarely use them because I can just as easily SSH into the Acer from the sofa, or another room, or indeed another country :)

So I bought a remote control. Initially I used a Sony Playstation 3 Bluetooth remote control, but this as proved unreliable so I now use an infra-red remote control. The one I chose is an Ortek VRC-1100 which isn’t pretty or especially technically elaborate, but it works, and works out of the box. It has a mouse control joypad & two mouse buttons and plenty of other buttons which match to the most appropriate logical keys on a keyboard. I’d recommend it for simplicity. I got mine for £15 from Ebay.

As the Ubuntu 9.10 installation process was unremarkable – in that everything just worked – I won’t document it here but provide the following links instead:-

http://releases.ubuntu.com
http://wiki.ubuntu.com/Mirrors
https://help.ubuntu.com/community/Installation
https://help.ubuntu.com/community/Installation/FromUSBStick

In terms of storage the Revo has a 150G disk onboard, but I already have some network storage which is accessible from any machine in the house and is considerably larger. So I’d rather mount that over the network and store programmes there. My storage device of choice is a drobo which is shared with a droboshare using Samba, and it’s mounted on the Revo under /media/drobo with a line in my /etc/fstab which looks like this:-


//10.10.10.237/drobo /media/drobo cifs user=alan,uid=1000,gid=1000,iocharset=utf8 0 0

You can find out more about Samba and fstab at these links:-

https://wiki.ubuntu.com/MountWindowsSharesPermanently
https://help.ubuntu.com/9.10/serverguide/C/windows-networking.html
https://help.ubuntu.com/community/Fstab
http://www.tuxfiles.org/linuxhelp/fstab.html

In terms of software on top of Ubuntu, I have used Boxee and XBMC. XBMC is a beautiful piece of software that I’ve used previously on an old XBOX Crystal, so I’m happy that it does what I need. Boxee which is based in part on XBMC has had a fairly major update recently which makes it a lot prettier and more logical than the previous release. At the moment I tend to use Boxee most of the time, dipping into XBMC now and then to compare the two products. Both products have .deb installation packages available so actually installing the software is quite a breeze.

To download Boxee, simply sign up at http://boxee.tv/ and then go to http://www.boxee.tv/download where they have a link to Boxee Beta for 32-bit and 64-bit Ubuntu, OSX, Windows and Apple TV along with the source code should you want it. Once downloaded, double click the deb file which installs fine on Ubuntu 9.10 and places a Boxee icon on the applications menu.

XBMC is easy to install on Ubuntu 9.10 from the team-xbmc ppa


sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install xbmc

I have configued both Boxee and XBMC to find my media on the drobo under /media/drobo/TV. This was fairly straightforard in both applications.

The final cool piece in this free software jigsaw is the BBC iPlayer. Now for those people reading from outside the UK this next bit is going to be a bit meaningless to you, feel free to zone out now. The BBC iPlayer terms of use specify that “Downloadable BBC Content is available for download within the UK only.”, sorry about that. But if you’re in the US, you get Hulu and other channels we don’t *shakes fist*.

The BBC provide a wide range of their output for viewing online, some of it in HD 720p. This can be streamed using a browser based flash plugin, or watched on some specific mobile (and less mobile) devices such as the Apple iPhone and Nintendo Wii. The BBC also have a desktop download client which is an Adobe Air app.

I’d rather not use a fat GUI client to do this because I want to schedule the download of my favorite programmes, so they’re ready for me to watch without me having to go and seek them out. Enter get_iplayer, a fantastic perl script which does a great job of downloading and streaming programmes from the BBC iPlayer.

I have get_iplayer and flvstreamer in /home/alan/bin on the Revo. I also have the ffmpeg package installed which is invoked by get_player after a download finishes to convert the video from flv to mp4. Finally I have the following script in /home/alan/bin as ‘download_programmes.sh’ and have it set as executable.


#!/bin/sh -x
/home/alan/bin/get_iplayer \
--vmode=flashhd,flashvhigh,flashhigh, \
flashstd,flashnormal,iphone --pvr \
--flvstreamer=/home/alan/bin/flvstreamer \
--output=/media/drobo/TV --subdir

Here’s the crontab entry for my user which I maintained with crontab -e.


MAILTO="alan@example.com"
# m h dom mon dow command
0 * * * * /home/alan/bin/download_programmes.sh

Note the email address in the crontab above will be sent a mail every time the script runs. This is useful because I will find out if new programmes are available for me to watch without having to go and look.

So every hour download_programmes.sh runs which calls get_iplayer to run in PVR mode (the –pvr option) and will download programmes to /media/drobo/TV (–output) into subdirectories named after the series/programme (–subdir). get_iplayer calls flvstreamer (–flvstreamer tells get_iplayer where to find it) to actually download the programmes to disk. It will attempt to download them in HD first, but if that’s not available it will go through all the lower quality options (–vmode) because some programmes aren’t in HD or the HD version isn’t online.

If you set all that up it won’t actually download anything until you tell get_iplayer what programmes you want to get. This is quite easy.

  • Running get_iplayer to update itself

  • $ get_iplayer
    get_iplayer v2.58, 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.

    INFO: Current version is 2.58
    INFO: Checking for latest version from linuxcentre.net
    INFO: Newer version 2.59 available
    INFO: Updating /home/alan/bin/get_iplayer (from 2.58 to 2.59)
    INFO: Downloaded /home/alan/bin/get_iplayer
    INFO: Updating /home/alan/.get_iplayer/plugins/podcast.plugin
    INFO: Downloaded /home/alan/.get_iplayer/plugins/podcast.plugin
    INFO: Updating /home/alan/.get_iplayer/plugins/localfiles.plugin
    INFO: Downloaded /home/alan/.get_iplayer/plugins/localfiles.plugin
    INFO: Change Log: http://linuxcentre.net/get_iplayer/CHANGELOG.txt
    INFO: Changes since version 2.58:

    Version 2.59 - 20100113
    * Added --future option to allow searching of future programme schedules / EPG for BBC Radio and TV (if indexed).
    * Added --refresh-future option to allow indexing of future programme schedules / EPG for BBC Radio and TV when refreshing the caches.
    * Running the PVR is now much faster due to caching the cache and history files in memory between PVR searches.
    * Updated list of available radio channels.
    * Improved display of help where options can be used in more than one context e.g. --long.
    * Prevent repeated metadata requests when the metadata retrieval fails.
    * Renamed --ignorechannels to --refresh-exclude.
    * Added --refresh-include option so that only matching channels are indexed when refreshed.
    * Fixed --multimode where existing file check was incorrectly failing.

  • Running get_iplayer on its own will list all BBC TV programmes available right now – in this case, 719 programmes

  • $ get_iplayer

    get_iplayer v2.58, 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:
    1: ... Sings Elvis - -, BBC Four, Classic Pop & Rock,Highlights,Music,TV, default,
    2: 1984 - A Sikh Story, BBC One, Factual,History,Religion & Ethics,TV, default
    3: 3rd and Bird - Fly, Muffin!, CBeebies, Children's,Entertainment & Comedy,TV, default

    (snip)

    717: dirtgirlworld - 9. Dig, CBeebies, Animation,Children's,Entertainment & Comedy,Learning,Pre-School,TV, default
    718: dirtgirlworld - 10. Creepy Crawly, CBeebies, Animation,Children's,Entertainment & Comedy,Learning,Pre-School,TV, default
    719: dirtgirlworld - 11. Bees, CBeebies, Animation,Children's,Entertainment & Comedy,Learning,Pre-School,TV, default

    INFO: 719 Matching Programmes

  • Downloading an individual programme
  • This is great for a one off thing that you want to get. Although personally why anyone watches the utter freakshow kids programme “Dirt Girl World” I will _never_ understand.


    $ get_iplayer -g 719
    get_iplayer v2.59, 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:
    719: dirtgirlworld - 11. Bees, CBeebies, Animation,Children's,Entertainment & Comedy,Learning,Pre-School,TV, default

    INFO: 1 Matching Programmes
    INFO: Checking existence of default version
    INFO: iphone1,flashhigh1,flashhigh2,flashstd1,flashstd2 modes will be tried for version default
    INFO: Trying iphone1 mode to record tv: dirtgirlworld - 11. Bees
    INFO: File name prefix = dirtgirlworld_-_11._Bees_b00p1mfz_default
    2.57MB / 45.79MB 2959kbps 5.6%, 00:01:59 remaining

    Note, this defaults to download the ‘iphone’ version, that is the lowest quality video (in this case it’s 480×272 resolution). It’s delivered over http so get_iplayer just downloads that file directly (pretending to be an iphone).

  • Downloading a higher quality video

  • $ get_iplayer -g 719 \
    --vmode=flashhd,flashvhigh, \
    flashhigh,flashstd,flashnormal,iphone
    get_iplayer v2.59, 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:
    719: dirtgirlworld - 11. Bees, CBeebies, Animation,Children's,Entertainment & Comedy,Learning,Pre-School,TV, default

    INFO: 1 Matching Programmes
    INFO: Checking existence of default version
    INFO: flashvhigh1,flashvhigh2,flashhigh1,flashhigh2,flashstd1,flashstd2,iphone1 modes will be tried for version default
    INFO: Trying flashvhigh1 mode to record tv: dirtgirlworld - 11. Bees
    INFO: File name prefix = dirtgirlworld_-_11._Bees_b00p1mfz_default
    FLVStreamer v1.9
    (c) 2009 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
    Connecting ...
    Starting download at: 0.000 kB
    Metadata:
    duration 660.08
    moovPosition 32
    width 832
    height 468
    videocodecid avc1
    audiocodecid mp4a
    avcprofile 77
    avclevel 30
    aacaot 2
    videoframerate 25
    audiosamplerate 48000
    audiochannels 2
    trackinfo:
    length 16501000
    timescale 25000
    language eng
    sampledescription:
    sampletype avc1
    length 31683584
    timescale 48000
    language eng
    sampledescription:
    sampletype mp4a
    14198.833 kB / 75.76 sec (11.5%)

    Note that this is now invoking FLVStreamer to download the higher quality, higher resolution (in this case 832×468) video over RTMP. Once complete it calls ffmpeg to convert the video to mp4 (x264)…


    Download complete
    FFmpeg version SVN-r19352-4:0.5+svn20090706-2ubuntu2, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    configuration: --extra-version=4:0.5+svn20090706-2ubuntu2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --extra-cflags=-I/build/buildd/ffmpeg-0.5+svn20090706/debian/include --enable-shared --disable-static
    libavutil 49.15. 0 / 49.15. 0
    libavcodec 52.20. 0 / 52.20. 0
    libavformat 52.31. 0 / 52.31. 0
    libavdevice 52. 1. 0 / 52. 1. 0
    libavfilter 0. 4. 0 / 0. 4. 0
    libswscale 0. 7. 1 / 0. 7. 1
    libpostproc 51. 2. 0 / 51. 2. 0
    built on Oct 13 2009 22:15:16, gcc: 4.4.1

    Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 25.00 (25/1)
    Input #0, flv, from '/home/alan/dirtgirlworld_-_11._Bees_b00p1mfz_default.partial.mp4.flv':
    Duration: 00:11:00.07, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: h264, yuv420p, 832x468 [PAR 117:117 DAR 16:9], 25 tbr, 1k tbn, 50 tbc
    Stream #0.1: Audio: aac, 48000 Hz, stereo, s16
    Output #0, mp4, to '/home/alan/dirtgirlworld_-_11._Bees_b00p1mfz_default.partial.mp4':
    Stream #0.0: Video: libx264, yuv420p, 832x468 [PAR 1:1 DAR 16:9], q=2-31, 90k tbn, 25 tbc
    Stream #0.1: Audio: 0x0000, 48000 Hz, stereo, s16
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    Press [q] to stop encoding
    frame=16501 fps=4882 q=-1.0 Lsize= 123714kB time=660.01 bitrate=1535.5kbits/s
    video:112951kB audio:10106kB global headers:0kB muxing overhead 0.534616%
    INFO: Recorded /home/alan/dirtgirlworld_-_11._Bees_b00p1mfz_default.mp4

    Note that the file size is significantly larger for the higher quality video:-


    $ ls -lh dirtgirlworld_-_11._Bees_b00p1mfz_default.m*
    -rw-r--r-- 1 alan alan 46M 2010-01-14 14:51 dirtgirlworld_-_11._Bees_b00p1mfz_default.mov
    -rw-r--r-- 1 alan alan 121M 2010-01-14 15:02 dirtgirlworld_-_11._Bees_b00p1mfz_default.mp4

    This is all rather good but very manual, what if we want to schedule the download of all episodes of Dirt Girl World? Firstly, go and see a psychiatrist, next we tell get_iplayer what programme we want to download and what we want to call it – in this case ‘Freakshow’.

  • Mark a programme for future download

  • $ get_iplayer "dirtgirlworld" \
    --pvradd "Freakshow"
    get_iplayer v2.59, 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.

    INFO: Saving PVR search 'Freakshow':
    search0 DirtGirlWorld

    That’s it, all done. Now the next time the cron job kicks in (hourly in my case) it will grab all episodes of programmes that match that search criteria. Note, it’s a search criteria. So if I used the term “Doctor Who” it would download episodes of “Doctor Who”, but also other programmes with that text in the name like the behind the scenes programme “Doctor Who Confidential”. You can of course be more sophisticated with your searches, and that’s all covered in the documentation very well.

    I’m not saying this is the best way to use get_iplayer, it’s just the way I use it, and a lot of people ask me how I use it. One thing I’d like to do is maybe change the download location to /media/drobo/TV/YYYY-MM-DD or TV/DayOf_Week_DDMMYYYY. Maybe also I could move stuff older than a few days to /media/drobo/TV/Archive to make it easier to get to the new stuff.

    Comments and suggestions welcome!

    This entry was posted in Ubuntu. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

    No comments: