Monday, March 23, 2009

MythTV on Early 2009 Mac Mini

I've been running MythTV for a few years now on an old early dual core machine, however I've always been annoyed by how noisy and ugly it was. It has always struck me that the Mac Mini would be the perfect form factor for a MythTV box but the hardware has been a bit long in the tooth ... until now. In early March 2009, Apple released an updated version of the Mac Mini, so I finally got around to buying one. This post will serve to document my MythTV setup on the Mac Mini.

(Note - this isn't intended to be a HOWTO, I assume your comfortable working out exact commands on your own. Also, I didn't take notes or anything while setting this up so any commands in here are from memory and may not be exactly correct)

Hardware
Basically, I bought the lowest-end Mini from the available choices, this is what I got:
  • 2.0GHz Intel Core 2 Duo (I didn't feel it was worth the AU$270 for the 2.26GHz)
  • 1GB RAM (I'll probably upgrade this later from a 3rd party)
  • 120GB Hard drive (even maxing this out to 320GB wouldn't be big enough - see below)
The internal hard drive on the Mini is available up to 320GB from Apple, but I don't really consider this to be big enough for MythTV, so I stuck to the smallest and purchased an external USB2.0 3.5" SATA enclosure to use for recording storage. Ideally, I would have liked to use the Firewire-800 connection available on the Mini for this as I was a bit concerned about the throughput of USB2.0 but I couldn't find a Firewire-800 enclosure for a decent price. The USB enclosure seems to be going OK so far.

For a TV tuner, I plan on getting a HD HomeRun DVB-T but it hasn't been fully tested on MythTV yet so for now I got a Leadtek WinFast DTV Dongle Gold which is a simple USB based DVB-T tuner. (Note that there seem to be many different variants of this dongle with different chipsets, so your experience may differ).

For a remote, I reused the same Microsoft MCE remote (model 1039) that I had from my old MythTV box.

Initial Setup
To get started, I followed the excellent procedure for installing Ubuntu 8.10 outlined by Victor Costan here. (Don't make my mistake and think that you can just format the entire disk and install Ubuntu :-) ... it doesn't boot and you'll need to reinstall OS X from the DVD)

Victor has also kindly added some additional comments I made regarding sound and configuration at the bottom of his post. Make sure to follow those if you want sound and video acceleration.

I also installed all updates before continuing.

At this point its probably a good idea to ensure all the hardware has been detected by the kernel - use dmesg for this. In my case most things were detected automatically (remote, keyboard, network, etc). For sound and video see above. The USB tuner took a bit more work ...

First, install mercurial ("sudo apt-get install mercurial"). Then grab the V4L sources ("hg clone http://linuxtv.org/hg/v4l-dvb"), compile them ("cd v4l-dvb; make") and install them ("sudo make install"). If you now unplug/plug the USB tuner and look in dmesg you should see that the driver was loaded. Most likely it will still be missing a firmware for the tuner but the dmesg output should give some indication of the filename - Google should be able to find it for you.

MythTV
I installed MythTV from the Mythbuntu website. It should automatically install MySQL, and any other requirements. I also really like the Mythbuntu Control Centre. I enabled my Mini as both a Primary back-end and a front-end, and use the control centre to enable automatic login as my myth front-end user.

After enabling the Myth components run the MythTV back-end setup to configure your tuner card, channels, storage, etc.

I don't stress too much about the guide data configuration in the MythTV Backend setup, as I install shepherd straight away (it is without a doubt the best way to get guide data for Australia - really easy to configure, grabs data from multiple sources and reconciles them all together). Follow the installation instructions to get it going.

That should pretty much be it .. fire up the front-end and give it a try.

Extras
After getting this all going and starting to use it, I have been noticing some random segfaults in most of the MythTV processes (front-end, back-end, and mythfilldatabase). I can't work out if these are related to the USB tuner, the USB HDD, or something else. I've just upgraded to the SVN weekly builds of MythTV 0.21-fixes from mythbuntu (follow the instructions here), and haven't seen the problem again yet, but I will keep monitoring it and update this post if it happens again.

I usually add a fair bit of other functionality to my MythTV box, and am slowly doing the same to the Mini - currently it is running apache (for MythWeb, but also a couple of other things), samba (to share out my iTunes and video libraries) and the Vuze bitorrent client (so that I don't need to leave my desktop PC on all the time).

Conclusion
Hopefully this post has some useful pointers for using a new MacMini as a MythTV box. If you try this and have any issues (or not) leave me a comment and I'll try to help you out.

Tuesday, March 3, 2009

REST Client

Recently I've wanted to access some content from Google Reader. Previously for this I've used both Net::HTTP and Open-URI, both of which work fine. This time, however, I needed to authenticate and grab content from a user account. Open-URI doesn't support the POST method and Net::HTTP seemed like a bit too much work. Enter REST Client:

require 'rest_client'

authresponse=RestClient.post('https://www.google.com/accounts/ClientLogin', :service=>'reader',:Email=>email,:Passwd=>password,:source=>'mreader',:continue=>'http://www.google.com')
if authresponse=~/SID=(.*)/
sid=$1
end

xml=RestClient.get("http://www.google.com/reader/atom/user/-/state/com.google/reading-list", {:Cookie=>"SID=#{sid}"})

As you can see REST Client makes the REST methods GET and POST (also DELETE and PUT) really easy.

Monday, March 2, 2009

First post

So this is the first post on my new blog.

The hardest thing about starting this blog was coming up with a name for it, because … well there really isn’t a point to this. It will probably end up being a random collection of bits and pieces, so I thought it would be a good idea to pick a random word for the name. After a few minutes of trying to think of a random word without success I decided (in typical nerd fashion) to try and automate the process using bash. With a little mucking around, this is the command I came up with to pick a random word from the dictionary (let me know if you can think of a better way):

awk “FNR == $(( $RANDOM * `wc -l /usr/share/dict/words| awk ‘{print $1}’` / 32768 ))” /usr/share/dict/words

And sure enough, the first word that came out of this was nonspeaking, which I thought was pretty cool … and here we are. Stay tuned for (hopefully) interesting tidbits and learnings from my various half finished projects...