Building a Home Media Server with Raspbmc: Part Four

If you’ve been following along with the last few blog entries, you should have a pretty good idea of how to build a Raspbmc device for cheap (What’s Raspbmc? Click here to start at the beginning.) Maybe you’ve already built one. And maybe it’s already achieved family-member status. 🙂 If so, congratulations!

In this last installment, I’m going to talk about enhancing your Raspbmc experience. I’ll also discuss some of the issues I had along with their solutions.

The topics presented below are in no particular order. It’s really more of a collection of Raspbmc recipes. So feel free to scan down the list until something catches your eye. And if you have a tip that doesn’t appear here, please leave a comment!

Fickle HDMI – When I first began using Raspbmc, the HDMI connection was a real pain. I’d finish watching one of my favorite movies, turn the TV off, and then return later to watch something else. Once I turned the TV back on, Raspbmc was nowhere to be seen. My only recourse was rebooting the Pi by unplugging it and plugging it back in. Not only was this inconvenient, but also extremely clumsy. Not shutting down Raspbmc properly before yanking the power can damage the filesystem.

If you experience this problem, the solution is to modify the /boot/config.txt file. Simply SSH into Raspbmc (User: pi, Password: raspberry) and edit /boot/config.txt using your favorite text editor. Add the following two lines at the end of the file.

hdmi_force_hotplug=1
hdmi_drive=2

Then save and reboot.

Setting hdmi_force_hotplug to 1 forces Raspbmc to use HDMI even if the TV or monitor isn’t detected. The other setting, hdmi_drive, controls the mode that HDMI runs in. Setting it to 1 forces Raspbmc to use DVI mode, which is merely HDMI without sound. This is NOT what we want. Setting it to 2 forces Raspbmc to use normal HDMI mode, which includes sound. This IS what we want.

Hulu/Netflix/Amazon Playback – One of the things that attracted me to Raspbmc was the ability to stream content from providers like Hulu. I had read about the Free Cable add-on from the Bluecop repo before starting the project. Free Cable is an XBMC add-on that allows you to stream content from both paid services (e.g., Hulu, Netflix, Amazon, etc.) and networks that make their content available online for free (CBS, Fox, etc.). So I tried it. And my experience with Free Cable was less than spectacular. Not only was it incredibly slow. But for many media sources, such as CBS, HGTV, etc., it simply didn’t work.

The solution for my woes wasn’t a Raspbmc add-on, but a desktop application called PlayOn. PlayOn is an application that acts as a middleman for streamable content. You install it on a PC and then supply it with credentials for whatever streaming services you use. It accesses content on behalf of Raspbmc and then restreams it. It’s fast. It’s simple. And it works.

At the time of this writing, PlayOn costs between $8.99 and $59.99 depending on your needs and budget. At the low end, they offer subscription model. At the high end, you can purchase a lifetime license.

A word of caution. To use PlayOn with Raspbmc, you MUST ALSO purchase the MPEG-2 license from RaspberryPi.com. Otherwise, Raspbmc won’t be able to decode PlayOn’s video stream. I didn’t realize this at first and all I got from PlayOn was audio.

When you purchase the MPEG-2 license, I suggest SSHing in to Raspbmc and adding it to the /boot/config.txt file using your favorite text editor. Just open up the /boot/config.txt file and paste the lines they instruct you to copy from the email you receive. Then reboot. Alternatively, you can enter the keys using the Raspbmc Settings program. But if you do, you’ll probably lose any custom settings you’ve added to the config.txt file, including the HDMI settings I mentioned above.

To use PlayOn with Raspbmc, you’ll need to add a uPnP video location. Start PlayOn from your PC, hop over to your Raspbmc device, and then navigate to Videos->Files->Add Videos. Click the Browse button and then select uPnP Devices. The PC running PlayOn should show up in the list. If it does, select it. If it doesn’t, check that your PC’s firewall isn’t blocking uPnP traffic. Once you’ve added the PlayOn source, you can use it by navigating to Videos->Files->PlayOn. I haven’t figured out a way to put PlayOn on the main Raspbmc menu. So if someone knows, please tell me how in a comment below.

Subtitles – The first time I curled up on the couch and started watching an English speaking movie with subtitles, I just about lost my mind. I couldn’t figure out how to shut them off. If you look around in the system settings you’ll find there isn’t a single subtitles on/off setting anywhere.

The trick to fixing this starts with playing a single video that contains subtitles. Press the “OK” button on your remote to pop up the On Screen Display. Then press the right button until the little speaker icon is selected. Press OK again. This will pop up the audio settings for the current video. If you scan down the list of options, you’ll find one called “Disable Subtitles”. Turn it off. And then at the bottom of the menu there will be another option called “Set as default for all videos”. That is the secret sauce. Select that and subtitles will be disabled globally. For videos that you need subtitled, you can navigate back to this menu to turn them back on for that single video.

Remote Updating/Cleaning – We store the bulk of our media on a FreeNAS box in a part of the house that’s about as far away from the TV as you can get. The computer I usually use to maintain our collection is just as far away. A common chore for me was having to fire up Raspbmc’s web based remote control to clean and update Raspbmc’s video library.

Raspbmc actually features a pretty slick JSON-RPC API. It’s what enables applications like Yatse to work as a remote control. Since it’s web based, you can also use it to do tasks like library cleaning and updating through your browser. I created bookmarks in my browser to make these sorts of tasks quick to do.

If you’re curious as to what services are available, here’s a link to the docs for Version 6 of the API. My favorite calls, and the ones I have bookmarked in my browser, are as follows. To use them for yourself, you’ll need to change the IP address to point to your own Raspbmc device.

This will update your video library.

http://pi:raspberry@192.168.0.7/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Scan"}

This will clean dead content from your video library.

http://pi:raspberry@192.168.0.7/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Clean"}

This will update your audio library.

http://pi:raspberry@192.168.0.7/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.Scan"}

This will clean dead content from your audio library.

http://pi:raspberry@192.168.0.7/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.Clean"}

File Management – When you select a folder as a media source, Raspbmc gives you the option of selecting that folder’s media type (TV or Movie). So you’ve probably already figured out that it’s best to have separate folders for your movie and TV content. What you might not have figured out is how your files should be named.

Raspbmc is extremely smart when it comes to file names. If you have a file named “Night.Of.The.Living.Dead.720p.mkv”, for example, it’ll be able to parse out the name and find it in the Movie Database. On the other hand, if you name the file “NOTLD.mkv”, Raspbmc will have no idea what the file is and you’ll probably not see the title show up in your movie library. So make sure you’re smart with your naming. If Raspbmc doesn’t add a title to the library, chances are it couldn’t parse the name or it couldn’t find it online. This also includes titles with accented characters. For instance, Raspbmc won’t be able to find “Les.Miserables.mkv”, but it will find “Les Misérables.mkv”.

I prefer to keep separate folders for each movie or TV show. For TV shows, you can also create subfolders, one for each season. For instance, underneath your TV folder, you might have a folder for “The Office (UK)”. And inside that folder you might have two folders, “Season 1” and “Season 2”, each of which contain the files for their respective season. If you follow this scheme, make sure you turn on the setting for “separate folders for content” when you add your content source in Raspbmc

Another cool thing about having your content in separate folders is that you can control the artwork that Raspbmc displays for a given title. You just need to deposit one or more of the following files in the same folder as your content.

fanart.jpg Background image. See the movie database or TV database for examples.
poster.jpg The poster that’s displayed for a given title. See the movie database or TV database for examples.
banner.jpg Banner image. I’ve only see this used in 3rd party remote control applications, like Yatse. See the TV database for examples.
thumbnail.jpg The thumbnail used for a given title. This is usually automatically extracted by Raspbmc and can take some time. Supplying it can save Raspbmc a bit of trouble.

Audio – I mentioned this in part 3, but it bears repeating one more time. Don’t use the mini-jack for your audio. You’ll just be subjecting your ears to bad stuff. Turn the audio-over-HDMI setting on and configure it appropriately for your home theater.

Remote Controls – If you haven’t ditched the mouse to control Raspbmc, you should. If you’re an Android user, check out Yatse. It’s a great remote control app you can use on whatever WiFi enabled Android device you have. I used this for a long time on my Kindle Fire before I got annoyed with the amount of time it took to establish a WiFi connection. I then dropped a whopping $14 on a SANOXY remote and never looked back.

Video Podcasts – One of my favorite things to watch on the Pi are video podcasts, such as those from Leo Laporte’s TWiT network. I really wanted to be able to automatically download shows as they were made available. And fortunately, the TWiT network features an RSS feed for video.

For TWiT’s “All About Android”, I wrote a bash script that looks like the following. Keep in mind that this is script runs as a cron job on an older FreeNAS box. Depending on what machine you use, you may have better regex facilities available to you. If you choose to use this script, you’ll need to adapt it to your environment and podcast source.

#!/bin/bash
 
cd "/mnt/Public/Media/"
wget http://feeds.twit.tv/aaa_video_hd -O feed.xml
 
# The version of grep that comes with FreeNAS doesn't support the -P option and Perl
# isn't installed. So we make do with what we've got.
LINKS=(`cat feed.xml | tr '\n' ' ' | grep -ho "<link>[^<]*" | grep -ho "http:.*.mp4" `)
LATESTLINK=${LINKS[0]}
 
FILENAME=`echo $LATESTLINK | grep -ho "[^/]*$"`
 
# We need to mangle the filename a bit to play nice with Raspbmc.
VERSION=(`echo $FILENAME | grep -ho "[^a0_]*_" | grep -ho "^.*[^_]"`)
FILENAME="All.About.Android.S01E${VERSION[0]}.mp4";
FILENAME="./TV Shows/All About Android/$FILENAME"
 
echo "Latest Link: $LATESTLINK"
echo "Destination File: $FILENAME"
 
if [ -f "$FILENAME" ]; then
    echo "File exists. Nothing to do.";
    rm feed.xml
    exit 1;
fi
 
rm feed.xml
echo "wget $LATESTLINK -O \"$FILENAME\"";
wget $LATESTLINK -O "$FILENAME"
 
# Telling Raspbmc to update itself.
wget "http://pi:raspberry@192.168.0.7/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22VideoLibrary.Scan%22}" -O /dev/null

Reclaim SD Card – Perhaps you’ve decided to replace or upgrade your SD card. Or maybe you’ve had enough of Raspbmc and you’re moving on to something else like Openelec. In either case, you’ll want to reclaim and reformat that old SD card to something your PC can use again.

To do this you’ll need the tool that started us down this road way back in the beginning – the Simple UI installer.

Fire up the installer and you’ll be presented with this familiar window.

Simply select the SD card and click the “Restore device for formatting” button. It does its work pretty quickly. Once it’s finished, you’ll still need to format it.

The SD card should now show up in Windows Explorer. From there, you can right click on the card and select Format.

Conclusion

Those are all of the Raspbmc tricks up my sleeve. If you have any tips of your own, please leave them in a comment below. Good luck!