Hacking the Apple TV

Part 2 Apple’s Apple TV set-top box supports all the audio and video file formats that iTunes, iPods and iPhones can handle. That’s plenty for many folk, but for those who favour less mainstream formats or widespread ones that Apple’s not keen on — DivX, for one — it severely limits the value of the machine.

Fortunately, once the Apple TV’s sealed system has been opened for access — as we detailed last time — it’s surprisingly easy to increase the number of codecs the machine has access to.

Perian’s Preferences panel in Mac OS X

The bottom line: if Mac OS X can be loaded with new codecs, so can the hacked Apple TV. It is, after all, an Intel-based Mac in its own right, and almost all of the free tools available to Mac users can be installed on the set-top box.

That naturally favours the Mac as the platform on which to work when modifying the Apple TV’s system software. More than anything, that’s because most codecs are supplied by the now-standard Apple .DMG disk image format. These can be opened on Windows and Linux PCs — see ‘Mac DMGs on Windows’ on the next page — and once that’s achieved, grabbing the necessary files is merely a matter of navigating a directory structure.

Undoubtedly, the best source for Mac-compatible video codecs is Perian, which plugs a host of formats into Apple’s QuickTime infrastructure. You can find a full list of supported codecs and media containers that Perian knows how to deal with on its website, but it’ll handle .FLV, .MKV, .AVI, DivX to name but four.

The key files in the Perian .prefPane folder structure

Once you’ve downloaded and mounted the Perian .DMG disk image file, the crucial elements are stored in Perian.prefPane, presented by Mac OS X as system preferences panel, but essentially a folder. Inside it, within the /Contents/Resources/Components folder, you’ll find Perian.zip. Copy this, along with the contents of the two accompanying folders, CoreAudio and QuickTime, to the desktop and unzip the files. You’ll end up with

A52Codec.component
AC3MovieImport.component
Perian.component

three files that need to be copied to the Apple TV using your SFTP client then moved to the correct locations on the box and assigned the correct file ownerships:

How to Access ‘Non-standard’ Files

Restart the Apple TV using the Software menu option we installed last time, and the codecs will now be available to the system and to any applications running on it. The snag is, the Apple TV’s GUI — an application in its own right — won’t show any ‘unofficial’ files you copy across.

ATVFiles on the main menu

To locate and play them, you’ll need ATVFiles, an Apple TV application that can be easily downloaded and installed using the ‘Manage 3rd Party Plug-ins’ section of the Software menu.

ATVFiles allows you to browse the your Apple TV’s folder structure using the regular remote control, a feature (understandably) absent from the standard GUI. When you find a file you want to view, pressing the OK button presents an Apple TV UI-style preview, and a second click plays the movie or song.

If you fancy installing ATVFiles manually, here’s how you go about it. Download the software from Awkward TV, here. You’ll end up with a file called ATVFiles-1.2.0.run which you need to copy over to the Apple TV then run it with the terminal command:

sudo sh ATVFiles-1.2.0.run

This will download and install the ATVFiles.frappliance plug-in with the correct ownership settings then automatically restart the Apple TV UI. When it’s running again, the main menu will now contain an entry called Files.

This allows you to navigate around the Apple TV’s file structure and play media files through QuickTime, which we’ve already augmented with Perian.

Of course, most of them won’t sync across in iTunes, but with your file-transfer app, it’s easy enough to copy a bunch of them over. If you do, you may get an odd warning:

We saw this message when we tried a couple of AVI files. The videos played just fine, even though we had to use the Apple TV remote’s Menu button to get away from the warning screen. It’s an odd glitch, and with so many factors — codec, file, ATVFiles etc — it’s hard to pin down the cause. Please let us know if you’ve found a way to avoid this.

How do you open a Mac-oriented DMG disk image file on your Windows PC? We tried EZB Systems’ Ultra ISO. Version 9 can open a DMG downloaded on a Windows machine and cope with the Mac disk format sufficiently to show you the image’s contents. You can than navigate through the folder structure to the files you want and extract them to your desktop.

For example, we used it to open Perian_1.1.3.dmg downloaded from the Perian website. We were than able to find the key perian.zip file, extract it, then used Windows Vista’s own Zip tools to access the .component folders within.

Ultra ISO costs $30, but it’s available as a free, trial release.

More Codecs to Add

Perian isn’t entirely comprehensive — it lack some key codecs, such as WMV and Ogg. Apple doesn’t support WMV directly, but developer Telestream — formerly Flip4Mac — does and it offers a free QuickTime component sponsored by Microsoft. You can download it here.

Installing WMV and Ogg

Again, you’ll get a DMG file which needs to be mounted on a Mac so you can run the installer to extract the files. The one you want is Flip4Mac WMV Import.component (note the spaces in the filename) and this needs to be copied across to the Apple TV then placed in the correct location using the following Terminal command:

sudo mv "Flip4Mac WMV Import.component" /Library/QuickTime/

Ogg fans can download the Xiph QuickTime component here. You’ll get another DMG, but this time the file you need is right there in the mounted volume. Get the XiphQT (decoders).component file and copy it to your Apple TV.

sudo mv "XiphQT (decoders).component" /Library/Components/

ATVFiles is pre-configured to display WMV files, but it’s not Ogg-aware out of the box, so you’ll need to tweak its settings manually. You’ll have to log in using a terminal app and then the standard defaults command to make the change.

ATVFiles maintains two lists of the file extensions it can recognise, one for video, the other for audio, and it’s the latter we need to add Ogg too:

Blast the other formats, just give me H.264!

There’s no doubt that adding codecs is the easiest way of getting the Apple TV to play ‘non-standard’ media, but it’s not the most elegant solution. Arguably, the most seamless way to enjoy content is to convert it into a native Apple TV format. For video, that’s H.264, and while a powerful machine will churn through files and output them as .MP4s, you can speed the process up a bit.

Elgato’s Turbo.264 application

Mac users should check out Elgato’s Turbo.264, a small USB dongle that, combined with the company’s bundled conversion software, punches out H.264 copies of any file format that QuickTime recognises — including, if you install Perian, a whole heap more than the default QuickTime installation provided for.

Even if you don’t own an Apple TV, Turbo.264’s a great tool for iPod and iPhone users with ‘non-standard’ video files they want to play on their portable players.

For Windows users, ADS offers what is essentially the same hardware but bundled with a more suitable conversion utility. ADS calls its version Instant Video To Go.

Avoiding Unwanted Apple Updates

All the codecs we’ve added here, along with ATVFiles and the other Apple TV plug-ins and utilities we installed last time will be erased when Apple next updates the set-top box’s system software — and you allow it to be downloaded and installed.

It’s easy enough to ignore a message that there’s new system software to download, but the Apple TV OS does nag you about it, so you have to choices: update the OS then go back and re-hack it — once plug-ins have been verified to work with the new version, of course. Alternatively, you can elect to trick the Apple TV so it never spots the arrival of new OS updates.

Ready to unhack your Apple TV?

This can be achieved by tweaking the Apple TV’s domain name look-up system so that Apple’s update server points to the box itself. Fire up a terminal app, log into the Apple TV and enter the following commands:

News of Apple TV updates will appear on sites like AwkwardTV, so you’ll have plenty of warning about new versions of the OS. Since you backed up the original hosts file — that’s what the hosts.old is — it’s easy enough to log in using a terminal app and disable the loopback:

sudo cp /etc/hosts.old /etc/hosts

Now the Apple TV will detect the new update, and tell you it’s ready to download. ®

AppleTV screen grabs

Our thanks go to reader Steve Arch for pointing out to us after the previous installment of Hacking the Apple TV that it’s possible to get screengrabs directly from the set-top box. Steve steered us in the direction of screencapture a utility that’s part of Mac OS X.

Extracting the code from one of our old Mac OS X 10.4 installation discs — since the Apple TV runs Tiger rather than Leopard — allowed us to copy screencapture over to the box from where it can be activated through a terminal app after you’ve logged in.

And it works… sort of. screencapture generates output at the resolution the Apple TV is set to. Ours is tuned to 720 x 576 in order to drive our PAL standard-definition TV, so we got a set of 720 x 576 PNG files as we expected we would.

Not quite right

What we didn’t expect was the right-most third of the screen image to be missing from the grab! Now, this is undoubtedly a by-product of our use of the composite-video output hack we applied last time. Not being C++ kernel coders, we’re not sure how to get around this, but if you have a notion how it can be achieved, send us the details and we’ll tell all next time.