The Raspberry Pi as a media center
Tired of that big clunky media center unit taking up shelf space in your living room? We'll show you how to put together a tiny multimedia system with the versatile and ever-popular Raspberry Pi.
Only 10 years ago, a large proportion of the population was satisfied with the possibilities of video players and analog satellite receivers. Now this primitive world of the past seems so far away. In our time, virtually all audio and video recordings are produced and distributed digitally. A single user interface can bundle several reception channels (e.g., digital video streams and Internet media libraries, as well as files residing on the local NAS devices). A variety of devices, including laptops, desktop PCs, and smartphones, interact with the media center in the living room through a local WiFi network. In addition to managing your movies, a smart mobile device also offers plugins for music files or a personal photo collection.
Do-it-yourself home theater PCs (HTPCs) were already on the rise at the start of the new millennium. Initially, these early HTPC systems were still desktop computers, with fancy new cases to make them more living-room-friendly. The energy costs and the purchase price of the hardware were correspondingly high. But the Community quickly had some new ideas. The XBMC media center software was originally developed for XBox consoles. Over the years, XBMC has been ported to a variety of platforms and operating systems. Hardware, software, and Internet bandwidth have evolved considerably over the last decade. Now, as in the past, you can spend thousands of dollars on a state-of-the-art system to play video streams and multimedia files, but if you are really looking to save money and space, one new platform outshines all others: XBMC with Raspberry Pi.
Keep in mind that a US$ 35 embedded PC can't hope to achieve the same performance as a US$ 600 DIY HTPC or even a US$ 300 netbook system, but for many applications, this extra power isn't necessary. On a Raspberry Pi system, a video can easily take one to two seconds to launch after you select it, but it will then play smoothly with HD quality. In many multimedia applications, the GPU compensates for the shortcomings of the 700MHz CPU. The footprint, which is about the size of a packet of cigarettes, is pleasingly small, and the power consumption, which is down in low single-digit wattage figures, is gratifying. However, some applications offer no alternative to more expensive solutions: If you want to plug in an external Blu-ray drive, you will only be able to play discs without copy protection, and Raspberry Pi is a bit underqualified to support live TV applications in which both the back end and the front end run on the same device.
Fortunately, the lead time for Raspberry Pi has improved dramatically. One of the two official distributors, Farnell/element14 , often dispatches within 7-14 days of your order, although longer waiting times are reported for the other official distributor, RS Components . If do not want to wait, you can order the device at an additional cost directly from a reseller: Modmypi , for example, offers a case in a black design that will not clash with your parlor furniture for another EUR 8. Look online for a list of distributors, official resellers, and unofficial resellers . The list includes vendors from all over the world. Even Amazon now sells Raspberry Pi systems, although the Amazon price of US$ 47.45 is significantly higher than what you will pay if you buy from an official distributor. Check the seller's website to see whether the devices are currently available from stock. If the surcharge compared with the official distributors is more than EUR 5, my advice is to buy directly from one of the official sources.
The accessories necessary for a Raspberry Pi minicomputer, such as an HDMI cable, are often already present in many households. If you have these accessories already, you won't need to order what one mail order vendor refers to as a "Raspberry Pi Starter Kit" (a collection of cables, SD cards, etc.). Although the Raspberry Pi unit is picky in terms of the peripherals it cooperates with, you can check the online compatibility lists to see if your components are compatible . For instance, the USB adapter that came with your smartphone might provide enough power for a Pi if it delivers 1amp at 5V. Some sources state that 700mA is enough, but this is true only if neither an Ethernet cable nor USB devices are connected. If you use an external hard drive, it should come with its own power supply, or you can connect it via an active USB hub, which, in turn, is plugged into your Pi.
An insufficient power supply can sometimes lead to inexplicable, seemingly arbitrary stability issues. SD cards should ideally support the fast class 10 standard, and a modern media center only supports a full range of options if it also has Internet access: If there is no network socket near the TV, a micro USB wireless stick is useful from a visual point of view; it almost disappears in one of the two USB sockets of the small computer because of its small size. The Netgear N150 stick worked well with the major Linux distributions, and without requiring any additional package installations. In principle, it is ideal for any budding media center owner to control their box remotely – and this is also easily possible. However, if you will often be using plugins that require text input (such as the "Search" function on the YouTube plugin) a wireless Bluetooth keyboard is the better choice.
Many users confirm that the Logitech K400 model is compatible, because its integrated touchpad also works. Theoretically, you could select menu items in the media center via the XBMC remote app on your smartphone . Because communication with the Pi, in this case, is via the WiFi router and not via Bluetooth, the latency for responses is potentially higher. To enjoy conventional TV broadcasts, Raspberry Pi users can also connect an external USB DVB receiver directly, although, as you will learn later in this article, live TV is not necessarily the best use for the Pi.
Installing a specialized media center distribution is quickly done: for this purpose, the user just downloads the appropriate image file and writes it to the SD card, from which the Raspberry Pi then boots. The following distributions are available:
- OpenELEC – A distribution specially designed for the XBMC media center (Figure 1). A lean, pure design supports higher speeds than the other two alternatives. However, the filesystem was deliberately set up to be read-only, so users cannot easily install non-XBMC programs retroactively. You can download an OpenELEC archive from the official website . A user with root privileges can then use the executable
create_sdcardto write an SD card for the Raspberry Pi.
- Raspbmc – A distribution intentionally designed for supporting XBMC media centers on Raspberry Pi. Raspbmc started as a modified version of Raspbian (which in turn is a Debian derivative), but it has now evolved considerably. The filesystem is writable by the user, although you will not want to start installing dozens of software packages from the Raspbian repositories. If too many services are running on the small media server, the system load increases quite quickly. For the installation, use a Python script  that downloads the Raspbmc image and outputs it on an SD card.
- XBian – Another distro dedicated to supporting XBMC on Raspberry Pi. The project calls itself "XBMC on Raspberry Pi, the bleeding edge" .
XBian is different from the other two solutions in that it does not have an auto-update function. Users install the image manually using
dd after downloading. If the SD card is, for example, in
/dev/sdb, the command
sudo dd if=xbian.img of=/dev/sdb
will do the trick. In order not to accidentally overwrite a hard disk partition, you will – as should always be the case with direct write access to the
/dev/ directory hierarchy – want to ensure that you are talking to the right device. All told, the differences between the three distributions are fairly marginal. If you consider the minor differences between them, you can say that Raspbmc tends to be more user-friendly and OpenELEC is faster than the rest.
If you want to watch movies that use the MPEG-2 (known primarily from DVDs) or VC-1 format (found on some Blu-ray discs – although encrypted Blu-ray discs are not playable anyway), you will have to purchase the codecs from the Raspberry Pi Foundation.
For cost reasons, these codecs (which today, are not necessarily important for all users) are not automatically supplied for each Raspberry Pi. To install the codecs, first switch to the console of the small computer and type
cat /proc/cpuinfo | grep Serial
For XBian and OpenELEC, you need to enter the serial number in the
decode_WVC1=0x12345678. Make sure you use the right numbers as sent to you after you placed your order. On Raspbmc, the operation is different: The system simply ignores the default
config.txt configuration file; instead, you can conveniently enter the numbers within the XBMC interface in an options dialog.
Prospective media center owners should look at the XBMC add-ons – one of the great strengths of the XBMC media center. The add-ons are (mostly) Python scripts that support many extensions, such as add-ons that give you access to YouTube or your TV's media library (like the apps on smart TVs), but also add-ons that support browsing on Internet forums by remote control or playing console emulators. XBMC has its own repository system for these extensions. XBMC users who have written a new add-on can submit it for publication on the official XBMC repositories; XBMC users around the world can then install this new extension with just a few clicks. You can also use an add-on not listed in the repository by retrieving the Zip files directly from the author's website.
Cloud providers would have us believe that everything comes out of the cloud now, but many people continue to hoard recordings of their favorite TV series on their own local hard drives. Although some users have huge collections of movies for no particular reason (staying true to the motto: save everything, watch nothing), other users rely on local storage for very good reasons. First, not everyone has a broadband Internet connection that is sufficient to stream HDTV recordings. Additionally, the popular video streaming providers still focus on a somewhat limited selection of titles. To make matters worse, some video providers disable the use of non-Microsoft operating systems using very rigid DRM mechanisms.
To address the problems associated with cloud-based streaming, many users have come up with the idea of attaching an external hard disk directly to the Raspberry Pi. In principle, an attached storage device should allow for local video storage, (assuming a stable power supply), but a local storage solution is not exactly the ultimate choice. For one thing, it is more convenient for the media center to have access to files stored on other devices across the LAN, not just its own local storage. Resist the urge to provide an external hard drive for the network by running a server directly on the living room Raspberry Pi: Playing a movie will push the relatively weak CPU of the Raspberry Pi system to 100% system load if active data transfers to multiple clients are taking place simultaneously in the background.
A cleaner and far more practical solution is to separate physically the device in the living room and the mass storage device – for example, through a NAS on the LAN, which could then reside in the cellar, thus remaining invisible to dinner guests. NAS devices available for purchase on the market are not exactly cheap, and they do not offer the user much flexibility: You have to live with the protocols the vendor has implemented by default. A cheaper and more customizable solution is to use a second Raspberry Pi and "build" your own NAS. The second Pi is then connected to your mass storage and serves it up to the entire LAN. (Because the processor can focus on a single task in this scenario, performance is unlikely to become an issue.) The minimal Raspbian distribution  would be a good choice for your DIY NAS Raspberry Pi. If the Raspberry Pi in your living room is not the only beast on the network accessing the NAS, but you also have one or two Windows clients, the simplest approach is to use the SMB protocol. However, SMB won't provide very good performance for broadband transmissions. A more satisfactory solution would be to use NFS or WebDAV. In other words, if you install a server application such as MediaTomb on the NAS Raspberry Pi and then share the folder on the external hard drive, the media center Raspberry Pi can access the shared data without trouble.
To prevent a hard drive from running 24 hours a day and running up your electricity bill, it should spin down if no one accesses the data for several minutes at a time. For this purpose, you can install the hdparm package on the NAS Pi. If the drive is mounted as
/dev/sda and you want it to spin down automatically after one minute of inactivity, look for the
/etc/hdparm.conf file and enter the line:
sudo hdparm -S 12 /dev/sda
Optical discs are going out of fashion, but many people still have a few movies on silver discs. DVDs don't present a problem – XBMC plays them without complaint as long as the Pi has an external USB DVD drive (ideally with its own power supply). For Blu-ray discs, however, things look bleak; rigid DRM protection limits the Blu-ray option to unencrypted discs only.
Buy this article as PDF
Popular open source encryption tool is vulnerable to attack
New “Yakkety Yak” edition emphasizes cloud and servers
Google finally enters the phone hardware business.
Innovative system adds a hard drive and Ubuntu Core to the RPi for an IoT hub.
Linux is two weeks younger than we thought!
The Apache Software Foundation considers retiring OpenOffice
Adobe won’t kill the plugin in 2017
Linux Foundation's big event celebrates the 25th anniversary of Linux
Linux has evolved from “won’t be a professional” project to one of the most professional software projects in the history of computers.