My Mac Mini HTPC setup
For some time I've wanted to setup a Mac Mini based HTPC. I've been waiting until the system has sort of remained stable and in use for a while before documenting it for the fellow geeks out there.
Design goals
I started out trying to find software that did what I wanted, but ended up crafting my own highly custom code (detailed later). I was willing to trade some ease of use for some sophisticated features. We would mainly use this for watching shows and movies from the Internet (iTunes, etc) and DVD rentals. I did not feel a need to integrate a tuner, and we have no cable TV anymore - this is strictly an IP based setup. There was also limited budget so I was always looking for the lower dollar option.
Primary Components
Physical setup
I was lucky in that there is a small closet located directly behind the wall where the TV would be. The closet had no power, but there was an outlet on the wall and I cut a hole and was able to run a powerstrip cable through. Unfortunately it is on the same circuit as our fridge and microwave, but so far we have only tripped the breaker a couple times. For me one of the primary advantages to the closet is that there is no reason everything has to be kept neat and tidy, so as I need to muck around and change wires, I don't have to reroute and rewrap everything. The closet also holds cable modem, WIFI router, VOIP box, cordless phone base, and various chargers (camcorder, NIMH batteries etc). Luckily the door already had top and bottom screen panels for ventilation (we live near the coast and these were probably originally put in to help prevent mildew in linens). Even so, the temps can get a little warm on the warmer days here.
Overview of screen and speakers as seen from viewing seating |
View looking at the wall end on showing closet on left, screen on right |
View of one stage of progress in the closet |
Connections
The mini is connected to the screen via DVI. Originally I was using the panel's ability to do 1080p (which it handles fine and looks great) but after some experimenting, I now have it set to the 1360x768 resolution. After studying some resolution test images I put together in photoshop, I felt one could not really tell the difference on this size screen between the two resolutions at a distance over 6ft. The lower resolution is also easier to read text, and is less taxing for the graphics card to scale non-HD content. YMMV. The Westy panel does not have a tuner, which saved some $, and at the time I got this, I felt the deal was awsome.
The Bose unit was a scavenged unit from a neighbor of my parents who was moving in with her boyfriend who already had a 5.1 system. This is ony a stereo setup, but I'm not super picky on surround, and didn't really want to do the wiring, and hey, the cost was $0. It is connected to the mini via Toslink optical cable.
I have an assortment of firewire and USB drives for storage and a firewire DVD burner (which, since I already owned, I got the combo-drive model).
I picked up a ATI remote wonder II on Ebay for about $20. This remote has some tradeoffs. It is RF (with a corded puck shaped USB receiver), so works with my hidden closet setup. It has a great diversity of buttons. There are some limitations in the software that take some tedious work arounds, it does not have the clearest button layout and is unlit. However it is very functional and a fraction the price of a Harmony.
The keyboard is an Adesso slimtouch. This is also RF (with a USB stick receiver), and has the following nice HTPC features:
- Decent integrated trackpad with scroll region on the right and two buttons
- Mac compatible (windows key = command key)
- Has an auto sleep battery saving feature (I haven't changed the batteries yet in 6+ months) Just press any key several times to wake
On the downside the keyboard seems to work best when level or angled up, when angled down I get poor signal and irradic behavior.
The input from the keyboard and remote are received by a set of software components which then send control signals (mainly power and volume controls) through an IRTrans USB unit, that has one wire going back out of the closet to a small adhesive IR transmitter on the TV, and another one inside the closet going to the Bose sound system.
The Software
This is really where my setup is custom. I had done a survey of nearly all the HTPC front end software out there - and while there is some good stuff, none of them combined all the good features out there, and none of them had certain features I was looking for.
I didn't have the time or skills to write a complete front end application, so I've cobbled one together from several components.
I use Quicktime, iTunes, and iPhoto for media playback.
I've written a custom applescript application that acts as the hub for most actions. Each action can be triggered through several input methods. These input methods mainly consist of button presses on the remote, and onscreen menu selection, but also include web based control through RemoteBuddy's AJAX Web interface.
I use the RemoteWonder remote with remoteBuddy (emulating the keyboard) for onscreen menus. And a tedious chain of actions for remote quick action keys that involve a button press on the remote, triggering a keypress, which triggers a Butler action, which runs a Applescript snippet sending an event to my hub application. (Although I never use it, I could also use the keyboard shortcuts directly on my wireless keyboard). While a bit tedious to set up, using it is pretty smooth. Settin up Remote Buddy for this kind of use takes quite a few steps in adding the custom menu items to trigger custom actions to run Applescript.
The actions in the hub program (a stay open Applescript app) are just routines. For example there is an action called PowerTV. When this action is called, it tells iRed (via applescript) to send the IR code through the IRTrans USB device to power the TV. One of the advantages of doing this in my hub program is I can keep track of whether the TV is on or off, as the IR signal is the same to turn it on or off. In order to launch media files with my custom program, I had to do a few tricks to set .mov and other media types to "open with" my custom program.
These actions can be combined (called from each other), so that an openMovie() action will call these actions (in pseudo-code):
PowerOnTV() if TV is not on PowerTV() end if PowerOnSpeakers() if SPEAKERS not on PowerSpeakers() end if Open movie in Quicktime If movie was played before, jump to resume location Present in Full Screen
Another advantage of knowing the state of the components, is I can turn everything off with one button. Since the program knows what is already on, it can power down just those items. My power off button can also pause, remember the location of, and close a movie, stop iTunes etc. I call it my "walk out the door button", the idea is if you need to walk out the door, you should be able to hit one button and have everything close down and power off nicely.
For screen feedback I use a combination of RemoteBuddy, and a command line utility called, I kid you not, BigHonkingText, you just give BigHonkingText a string, and it pops up a display like this:
I also use a some text-to-speech for some feedback when the screen is off.
Here are some of the custom features that such a system has let me create, some of these take advantage of the fact that there are LOADS of buttons on the remote (Including arbitary color coded A,B,C,D,E,F buttons), but these features are also available by navigating an on screen display, or through RemoteBuddy's slick AJAX (aka iPhone) remote - some features require the screen some don't. (Of course, if the screen isn't already on, it's turned on automatically if needed). I'm not going to list the basic features of opening and playing movies, and music - those I consider pretty basic and not worth covering - I'm going to stick to the enhancements.
- Jump back 5 seconds - a favorite of my old DVR, easily done by scripting quicktime
- Speed up and slow down in progressive increments (increase by 160%, or decrease by 60%) Each tap of the button continues to speed up or slow down more.
- Close a movie and resume it where it left off (this is also automatically done when the AllPowerOff button is hit) - some may consider this a base feature since it is in Front row, but doing it wasn't trivial.
- Bookmark within movies - since I had to create a system to store the last played location, it didn't take much more to be able to store any number of bookmarks. You can add a bookmark, and jump to the next/prev bookmarks in a movie.
- Prompt at the end of a video to Delete/Keep/Keep Always. Movies that are marked keep always (uses a finder label) no longer prompt on end.
- Play latest Daily Show - one of our favorite shows, gets its own button on the remote, that looks through the shows on hand, turns on the TV and speakers, then opens and plays the latest show.
- Fishtank - Make sure TV is on, open Marine Aquarium, make full screen
- Check Tides - Make sure TV is on, open Mr. Tides program, show full screen for 30 seconds, quit program, turn TV off. We live near the beach, but if the tide is high, can't take the dog out for a walk on it. One press of the button gives us a glance at the tides - no need to shut it off since it will do it on its own.
- Fireplace - our last house had a fireplace, this one doesn't. This will open and play a video of a fire burning compete with snaps and crackles.
- Two levels of volume control - my Bose has a very gradual volume change from 0-100, when you want it to go up or down with the manufacturer's remote, you would just hold the button down - not so easy when you are relaying through a system like this. So I have a two sets of volume controls. The remotes Vol +/- buttons change the volume by 3, the channel +/- buttons (which don't apply in mysetup - since I have no "Channels") change the volume by 7.
- Display time remaining in video - handy for when my wife asks how much longer is this movie? Pops up a big text overlay that shows total movie length, how far in, and how much left (yes, I know one could do the math, but the point is quick info for a lazy brain).
- Switch between iTunes libraries (could also use this for iPhoto if I want, but only use mutliple libs in iTunes). For now I'm using iTunes full screen coverflow instead of Front Row - but we may see if 10.5 Front Row will step up to my needs for music.
- Single button playing of favorite MP3 streams - big KCRW fan, so it gets a button that turns the speakers on, and plays the stream.
- Control of kitchen "Radio" - which is a older Roku Soundbridge. If I forget to turn off NPR in the kitchen when sitting down for a movie, the soundbridge is automatically shutdown before the movie plays. (Future wishlist is for Indigo control of Insteon lighting, but can justify the budget for that yet).
There is another feature that is less HTPC related, but ties in. I have a launchd agent that watches for when my camera's SD card gets put in a card reader that sits in the closet. When it does, the following sequence of events are triggered:
- The card's jpgs are loaded into a date stamped folder
- The card's AVIs are loaded into a different date stamped folder
- The card is cleared
- The Mini announces that the camera download is complete
- A flag is set on the HTPC machine that there are new photos available
- A background thread is started that compresses the AVIs into a H.264 for onscreen viewing (less disk space than the camera AVI format), and also compresses even smaller and loads into iTunes for iPhone syncing. [this step is not implemented yet, but all the parts to do so are already figured out]
- A cron script runs every 5 minutes on my laptop, checking first to see if I'm on my home network, then to see if the flag on the HTPC is set announcing new images. (this all happens with keyed SSH connections, so you never know its going on in the background)
- This then mounts the HTPC drive, opens iPhoto and imports the new photos.
- Closes iPhoto, then rsyncs my iPhoto library back to the mini
- My laptop then sets a flag on mini that there is a new update to the iPhoto lib
- My wifes laptop has a cron script that checks every 5 minutes to see if there are iPhoto lib updates on the mini, and if so rsyncs from the Mini to her laptop. (this way both our laptops don't need to be open at the same time for this all to work).
What this essentially accomplishes is a quick way to load the pictures from the camera into my iPhoto, backup to the Mini, and make sure my wife has our latest photos on her laptop. We decided that we would manage the iPhoto library on my laptop (create albums etc) rather than each have an iPhoto library that imports the newest photos separately.
This ties back into the HTPC setup, since there is a button/feature to play the latest camera download as a slide show. So say we come back from a trip to the zoo, or whatever. Plug the card in, wait for the computer to say "Camera download complete" then hit a button on the remote and watch the slide show on our 42" screen.
Future Changes
There are a number of features I could add. I thought of adding a quick weather check feature, but the weather is so nice here generally that it wouldn't be that useful. I certainly plan to set up the mini as a time-machine hub once I upgrade to leopard - but thats not really that trick. I'd live to get more into home automation with Indigo and Insteon. But this is a rental, and not all that big a house, so when I check in with my rational side, I have to admit there isn't really much need for it. On the physical side of things - I may need to add more ventilation to the closet - probably up into the attic space with a small fan and stovepipe.
Useful software and links (in no particular order):
- Butler
- iRed
- RemoteBuddy
- Mr. Tides
- Marine Aquarium
- BigHonkingText
- My custom applescript hub application (note this is NOT general purpose, has plenty of warts, and some hard coded paths)