XBMC the Thecus N3200 NAS and NFS Redux

I’ve been meaning to post about this for ages, but for some reason I’ve always had something better to do, like washing my hair. As I detailed in my previous post about XBMC the Thecus N3200 NAS and NFS, I couldn’t get it working, as XBMC couldn’t mount the NFS shares and I couldn’t adjust the mounts via the Thecus N3200 OS. I gave up in the end and switched my XBMC distro from OpenELEC to Raspbmc mainly so I could get access to the underlying Debian OS and thus edit the /etc/fstab file.

Installing Raspbmc is a breeze, just download the install script, stuff your SD card into your computer, run the script and then go and enjoy a beer while it does its stuff. Then all that was left to do, was ssh into the Raspberry Pi and edit it’s copy of /etc/fstab and create some local folders to mount the shares to. As I’d previously done all of that on my laptop, it was just a case of copying the relevent bits from one /etc/fstab to the other. A reboot later and XBMC was happily adding all the media from what it thought was a local folder.

Just in case you find yourself in a similar position, here’s the entries in the /etc/fstab on my laptop:

# Thecus N3200 mount points, assuming your NAS has a fixed IP of 192.168.0.100
192.168.0.100:/raid/Bob /home/boba/nas/bob nfs rw
192.168.0.100:/raid/Photos /home/boba/nas/photos nfs rw
192.168.0.100:/raid/Music /home/boba/nas/music nfs rw
192.168.0.100:/raid/Video /home/boba/nas/video nfs rw
view raw mount-points.sh hosted with ❤ by GitHub

Extracting Audio Tracks From MKV Files

I’ve been ripping all my DVDs to MKV files, so I can serve them up via XBMC running on a Raspberry Pi. I was up in the loft at the weekend, mainly trying to sort out the mess into something more logical. I suddenly remembered that I had a number of music DVDs that I bought with the express intention of ripping the audio from, so I dug them out.

My normal DVD ripping process is to use MakeMKV to get a raw MKV file and then use Handbrake to re-encode the contents it into something slightly smaller. I want to be able to listen to these DVD tracks on a mobile player as well as at work, so I don’t just want them as MKV files with video and audio, I want a separate audio file as well. One of the features of Handbrake, is the ability to add more audio tracks with different encodings etc, so it’s really easy to have your DD or DTS passed through and have it re-encoded into FLAC, Vorbis or MP3 on a separate track.

Armed with a MKV file that contains a FLAC/Vorbis/MP3 audio track, the only thing left is to extract this track into a separate file. If you are using Linux or Windows, then there are a couple of command line utilities that make doing this quite easy, they’re part of the MKVToolNix package, which you should be able to get out of your distributions repositories or download from here. I had four DVDs to extract audio tracks from, one of the DVDs had two different live concerts, so you can imagine there was a fair few files to extract audio from once each song had been ripped to its own MKV file.

It would have taken a while to manually extract the audio track from each MKV file, so I needed a way to script it, so it could all be done automatically. Firstly, I needed to find out the track number that the audio was on, I used mkvmerge for this:

~/scrap/music/mkv/Franz Ferdinand/Live at Brixton$ mkvmerge -i 08\ -\ I\'m\ Your\ Villain.mkv
File '08 - I'm Your Villain.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AC3)
Track ID 3: audio (A_FLAC)
view raw mkvmerge hosted with ❤ by GitHub

All the MKV files I’d created had the FLAC audio track on ID 3, which made life slightly easier, so then it was just a case of finding all MKV files in the current folder tree and extracting track three from them. I used mkvextract in the following script:

#!/bin/bash
find . -type f -name *.mkv | while read filename; do mkvextract tracks "$filename" 3:"${filename%.*}".flac; done
view raw extract-flac.sh hosted with ❤ by GitHub

It would be cool to call the script with the output format you want to extract (A_FLAC in this instance) and parse the output of mkvmerge for each MKV file to find the desired track id to pass to mkvextract. Doing it this way, with a fixed track id, was all a bit quick and dirty, but it worked for me. Maybe I’ll modifying it in the future, but as I’ve no more music DVDs needing audio ripped from them, I’m in no rush…

XBMC the Thecus N3200 NAS and NFS

After getting OpenELEC installed on an SD card and running on my Raspberry Pi, the next step was to get XBMC serving up all the media that is stored on our Thecus N3200 NAS.

It looked like it should be pretty straight forward, as I already have various NFS mounts setup on the NAS for access via my Kubuntu laptop. However, I just couldn’t get XBMC to browse into any of the mounted folders; it could see them, just not access them.

There isn’t much information out there about my NAS, mainly as it was superseded pretty quickly by the N3200PRO. Which meant that there wasn’t much information with which to try and diagnose the issue. After a bit of googling, I did manage to track down a post that implied that my NFS mounts would need to invoke insecure mode, which was backed up by the XBMC wiki. Shame the N3200 doesn’t expose any real NFS settings, so you can’t configure the mounts from the frontend; at least not with the last official firmware.

I did look at adding the insecure flag the NFS mounts directly, via the /etc/exports file; shame that you can’t SSH into the NAS by default though. After a bit more trawling, I found a couple of modules that would allow me to reset the root password and run a SSH demon. With the modules loaded, I SSH’d into the NAS and added the insecure flag to each of the NFS mounts; shame the changes were lost when I rebooted. I eventually gave up trying and asked for help on the Thecus forums, I haven’t had a reply yet.

While I wait on a reply, I just added the various mounts to XBMC via SMB. It’s not my first choice, but it appears to work fine, at least there were no obvious streaming issues while I watched Ratatouille last night…

OpenELEC

The HDMI cables and SD cards I ordered via Amazon, were waiting for me when I got home on Friday after work. So I spent some of Saturday morning trying to get OpenELEC up and running on my Raspberry Pi, with various levels of success.

Earlier in the week I cloned the OpenELEC github repository and compiled the source, before installing it onto the SD card I normally use in my Nikon P6000. I followed the instructions on this page of the OpenELEC wiki and it appeared to all go to plan. A couple of corrections needed to be made in the Installing OpenELEC to the SD Card section, as the build put certain files in a different place to that specified. Instead of copying the files from:

$ sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-driver-*/boot/arm128_start.elf /media/System/start.elf
$ sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-driver-*/boot/bootcode.bin /media/System/
$ sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-driver-*/boot/loader.bin /media/System/

They were in the bcm2835-bootloader-* folder, not the bcm2835-driver-* folder, so I copied them with:

$ sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/arm128_start.elf /media/System/start.elf
$ sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/bootcode.bin /media/System/
$ sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/loader.bin /media/System/

After a bit of faffing with my TV and AV equipment, I finally managed to get a picture displaying on the TV, but as you can see from the image at the top of this post, all I got was an error message. Rather than break out the laptop to edit the cmdline.txt file and spend a while trying to get the partition name correct, I just downloaded one of the nightly builds and ran the create_sdcard utility. This produced a working SD card and I was able to boot straight into XBMC, all in all a much easier and less time consuming option.

A Slice of Raspberry Pi

I meant to get up early the day the Raspberry Pi was put on sale, but I totally forgot. By the time I remembered, both the Farnell and RS websites had long melted down. I eventually managed to get on the waiting lists at both companies and finally, after what has seemed like an ages, my first Raspberry Pi arrived on Saturday.

I should have been prepared, I had meant to buy a HDMI cable and a SD card, but it was the Cambridge Beer Festival last week, so beer was more of a priority. I did take it into work with me today though and got it all wired up to ensure it was all working. It was really cool to see the large raspberry appear on the screen.

Now I just need to wait till later in the week when some HDMI cables and SD cards arrive via Amazon. In the meantime, I need to build OpenELEC, as this Pi is going to be running XBMC and serving up all the familys media in the living room. It’ll be another month or so until my second unit comes and this gives me some time to think of things to do with it. I might put it into a rocket, or I may look to use it in automating my homebrewery, we’ll see.

I’m looking forward to playing with it and I think I’ll have to get another couple of SD cards so that the kids can have one each and learn how to prgram, if they want to. Either way, I’m looking forward to my slice of Pi.