APC Australia

Build a Pi Zero media centre.

Nick Peers demonstrat­es how to construct your own smart-streaming stick using a Raspberry Pi for both personal and Internet media.

-

Why fork out for an expensive set-top box when you can build your own for significan­tly less? Thanks to the powerful open-source Kodi media centre software ( kodi.tv), you can access both locally stored personal media on demand, plus watch a wide range of Internet streaming services, including catch-up TV.

The success of Kodi — formerly known as XBMC — has led to the developmen­t of Kodi-flavoured distributi­ons (distros). If you’re looking for a full-blown Ubuntu-based distro with Kodi sitting on top then Kodibuntu ( kodi.wiki/view/Kodibuntu) will appeal.

Kodibuntu is overkill for most people’s needs, which is where OpenELEC ( www.openelec.tv) comes in. This is an embedded OS built around Kodi, optimised for less powerful setups and designed to be as simple to run and administer as possible. There’s an underlying OS you can access via SSH, but for the most part, you can restrict yourself exclusivel­y to the Kodi environmen­t. Four official builds are currently available: ‘generic’ covers 32-bit and 64-bit Intel, Nvidia and AMD graphic setups; two Raspberry Pi flavours: one for the Pi 2, and the other for everything else, including the new Pi Zero; and one final build is for Freescale iMX6 ARM devices. There are further unofficial builds for jailbroken Apple TV mark 1 boxes (head to chewitt.openelec.tv/appletv), as well as AMLogic-based hardware ( bit.ly/amlogic-oe).

CHOOSE YOUR HARDWARE

The cheapest way to build an OpenELEC streaming box from scratch is to base it around the Raspberry Pi Zero. There’s one slight complicati­on caused by the fact it only has one USB port, so you’ll need a powered hub to support both keyboard and Wi-Fi adaptor during the initial setup phase. Expect to pay between $55 and $80 for all the kit you need (not including postage) from the likes of The PiHut ( www.thepihut. com) or Pimoroni ( shop.pimoroni.com). You’ll need a Pi Zero (obviously), case, power adaptor, Wi-Fi adaptor, microSD card, powered USB hub and accessorie­s.

If you’re willing to spend a little more, then the Raspberry Pi Model B+ costs about $38 or the quad-core Pi 2 Model B costs approximat­ely $52 from au.rs-online.com, not including power and Wi-Fi adaptors, micro SD card and case. Both come with an Ethernet port for wired networking, plus four USB ports and full-size HDMI port — choose the Pi 2 if you plan to run a full media server, which requires more CPU grunt.

You’ll need a keyboard for the initial configurat­ion of OpenELEC, but once those steps are complete, you’ll be able to control OpenELEC remotely via your web browser or by using a free mobile app. You’ll also need somewhere to store your media. If you only have a small (sub-50GB) collection, then splash out for a 64GB microSD card and store it locally; otherwise attach a USB hard drive or even store your media on a NAS drive and connect over the network. Note the latter option will slow things down considerab­ly, and you may experience buffering, particular­ly if connected via Wi-Fi.

You can find both of the Raspberry Pi builds of OpenELEC (or just the generic 64-bit build if you’re not using a Pi) available as free downloads from openelec.tv/get-openelec — be sure to get the latest version. The files are compressed in TAR or GZ format, so you’ll first need to extract them. The simplest way to do this is using your Linux distro’s GUI — in Ubuntu, for

example, copy the file to your hard drive, then right-click it and choose ‘Extract Here’.

BUILD, INSTALL AND CONFIGURE

Now connect your micro SD card to your PC using a suitable card reader (you can pick one up for under $10 online) and use the $ dmesg | tail command or Disks utility to identify its mountpoint. Once done, type the following commands — which assume your drive is ‘sdc’ and that your image file is in the Downloads folder. $ umount /dev/sdc1 $ cd Downloads $ sudo dd if=OpenELEC-RPi. arm-6.0.1.img of=/dev/sdc bs=4M

You’ll want to use sudo dd if=OpenELEC-RPi2.arm-6.0.1.img of=/dev/sdc bs=4M if installing OpenELEC on the Raspberry Pi 2. Wait while the image is written to your micro SD card — this may take a while, and there’s no progress bar, so be patient (time for a cup of tea, perhaps?).

Once complete, unmount your drive and then eject it. Insert the micro SD card into the Pi, connect it up to monitor and keyboard and switch it on. You should immediatel­y see a green light flash, and the screen come on.

The OpenELEC splash screen will appear, at which point, it’ll tell you it’s resizing the card — it’s basically creating a data partition on which you

“You’ll also see tabs for movies, TV shows and music — once you’ve populated your media libraries, you’ll be able to browse and set up content to play from here.”

can store media locally if you wish. After a second reboot, you’ll eventually find yourself presented with an initial setup wizard for Kodi itself.

If you’ve not got a mouse plugged in, use Tab or the cursor keys to navigate between options, and Enter to select them. Start by reviewing the hostname — OpenELEC — and changing it if you’re going to run a media server and the name isn’t obvious enough already. Next, connect to your Wi-Fi network by selecting it from the list and entering your passphrase. You can then add support for remote SSH access, as well as Samba (see SSH Access box, above).

You can now control Kodi remotely if you wish via your web browser: type ‘192.168.x.y:80’ into your browser (substituti­ng ‘192.168.x.y’ with your Pi’s IP address). Switch to the Remote tab and you’ll find a handy point-andclick on-screen remote to use — what isn’t so obvious is that your keyboard now controls Kodi, too, as if it were plugged into your Pi directly. You’ll also see tabs for movies, TV Shows and music — once you’ve populated your media libraries, you’ll be able to browse and set up content to play from here.

This approach relies on your PC or laptop being in line of sight of your TV. If that’s not practical, press your tablet or phone into service as a remote control instead. Search the Google Play store for Kore (Android) or the App Store for Kodi Remote (iOS) and you’ll find both apps will easily find your Pi and let you control it via a remote-like interface.

By default, OpenELEC uses DHCP to connect to your local network. If your Pi’s local IP address changes, it can be hard to track it down in your web browser for remote configurat­ion. Change this by choosing ‘System > OpenELEC > Connection­s’, selecting your connection and hitting Enter. Choose ‘Edit’ from the list and pick ‘IPv4’ to assign a static IP address you’ll be able to use to always access Kodi in future. You can simply stick with the currently assigned address, or pick another. Make sure you select ‘Save’ to enable the change. If all of this sounds like too much bother, check out the box on SSH (SSH access back over the page) for a way to change the underlying configurat­ion files instead.

SET UP LIBRARIES

The first thing to do is add your media to your library. Kodi supports a wide range of containers and formats, so you should have no problem unless you’ve gone for a particular­ly obscure format. Check the box Add content to your library, opposite, for advice on naming and organising your media so that allows Kodi to recognise it and display extra informatio­n about TV shows and movies. This uses the help of special ‘scrapers’: tools that extract metadata from online databases such as movie titles, TV episode synopses and artwork to pair them with your media files for identifica­tion.

Where should you store this local content for Kodi to get at it? If your micro SD card is large enough — we’d suggest 64GB or greater — then you can store a fair amount of video and music on there. You can transfer files across the local network — open File Manager and opt to browse your network. Your OpenELEC device should show up — double-click the file-sharing entry and you’ll see folders for Music, Pictures, TV Shows and Videos. Simply copy your files here to add them to your library. Once done, browse to Video or Music and the media files should already be present and accounted for, although at this point in time, they’ve not been assigned a scraper to help you identify them yet.

It can be slow copying files across in the network — you can transfer files directly to the card when it’s mounted in a card reader on your PC, but you’ll need to access File Manager as root to do so — in Ubuntu, for example, typing

$ gksudo nautilus and hitting Enter will give you the access you need. A simpler option — if you have a spare

USB port on your Pi — is to store your media on an external thumb or hard drive. Just plug the drive into your Pi, browse to Videos or Music and choose the ‘Add…’ option. Click ‘Browse’ and select the toplevel folder containing the type of media you’re adding — TV, movies or music. If you’ve plugged in a USB device, you’ll find it under ‘root/media’, while NAS drives are typically found under ‘Windows Network (SMB)’. Once selected, click ‘OK’.

The Set Content dialogue box will pop up — use the up and down arrow buttons to select the type of media you’re cataloguin­g and verify that the selected scraper is the one you want to use. Check the content scanning options — the defaults should be fine for most people — and click ‘Settings’ to review advanced options (you may want to switch certificat­ion country to Australia for movies, for example). Click ‘OK’ twice and choose ‘Yes’ when prompted to update the library.

Once done, you’ll find a new entry — Library — has been added to the media menu on the main screen. This gives you access to your content with filters such as genres, title or year to help navigate larger collection­s. Now repeat for the other types of media you have. If you want to include multiple folder locations within single libraries, you’ll need to browse to the Files view, then rightclick the library name (or select it and press ‘C’ on the keyboard) to bring up a context menu. Select ‘Edit Source’ to add more locations, and ‘Change Content’ to change the media type and scraper if necessary.

The smartest thing to do with any digital media library is host it on a media server, which allows you to easily access it from other devices on your network and, in some cases, over the wider Internet. Kodi has UPnP media server capabiliti­es that work brilliantl­y with other instances of Kodi on your network, as well as making your media accessible from other compatible clients. Media servers can be quite demanding, so we don’t recommend using a Pi Zero or Pi Model B+. Instead, set it up on your most powerful PC (or Pi 2) and use OpenELEC to connect to it as a client.

As media servers go, Kodi’s is rather basic. If you want an attractive, flexible server, then you might want to consider Emby (see APC 428, page 53). Pair this with the Emby for Kodi addon and you can access your Embyhosted media without having to add it to your Kodi library. A similar addon exists for users of Plex Media Server too, PleXBMC ( bit.ly/PleXBMC), providing you with an attractive frontend.

If you want access to other UPnP servers via Kodi without any bells and whistles, then browse to ‘System > Settings > Services > UpnP/DLNA’ and select ‘Allow remote control via UPnP’. You can also set up Kodi as a media server from here: select ‘Share my libraries’ and it should be visible to any UPnP client on your network, although you may have to reboot.

Performanc­e is obviously going to be an issue on lowerpower­ed devices, such as the Pi, and while the Pi 2 is pretty responsive out of the box, you may find the Pi Zero struggles at times. It pays, therefore, to try to optimise your settings to give your Pi as many resources as it needs to run smoothly.

Start by disabling unneeded services — look under both ‘System > OpenELEC > Services’ (Samba isn’t needed if you’re not sharing files to and from Kodi, for exmaple) and ‘System > Settings > Services’ (AirPlay isn’t usually required). Incidental­ly, while you’re in ‘System > Settings’, click ‘Settings level: Standard’ to select first ‘Advanced > Expert’ to reveal more settings.

One bottleneck for Pi devices is dealing with large libraries — give it a helping hand by first going to ‘Settings > Music > File lists’ and disabling tag reading. Also go into ‘Settings > Video > Library’ and disable ‘Download actor thumbnails’. You can also disable ‘Extract thumbnails and video informatio­n’ under File Lists, but you’ll lose a lot of eye candy and the thumbnail caching for future use.

The default Confluence skin is pretty nippy, although if you suffer from stutter when browsing the home screen, consider disabling the showing of recently added videos and albums: select ‘Settings > Appearance’, then click ‘Settings’ in the righthand pane under Skin. Switch to ‘Home Window Options’ and deselect both ‘Show recently added…’ options.

Speaking of Confluence, if you don’t like the default skin, then try Amber — it’s beautiful to look at, but easy on system resources. You do lose access to the OpenELEC settings when it’s running, but you can always switch back to Confluence temporaril­y or use SSH for tweaks, if necessary.

 ??  ?? The Amber skin is a beautiful alternativ­e to the more functional Confluence default. Sadly, there’s no access to the OpenELEC configurat­ion menu from it.
The Amber skin is a beautiful alternativ­e to the more functional Confluence default. Sadly, there’s no access to the OpenELEC configurat­ion menu from it.
 ??  ?? Kodi employs the use of scrapers to automatica­lly grab artwork and metadata for your media files based on their filename and folder structure.
Kodi employs the use of scrapers to automatica­lly grab artwork and metadata for your media files based on their filename and folder structure.
 ??  ?? OpenELEC runs an initial configurat­ion wizard to get you connected — you’ll need a USB hub if you have a Pi Zero and want network capabiliti­es.
OpenELEC runs an initial configurat­ion wizard to get you connected — you’ll need a USB hub if you have a Pi Zero and want network capabiliti­es.
 ??  ??

Newspapers in English

Newspapers from Australia