I’ve been investigating 5.1 Dolby Digital playback on the Mac, and I’ve discovered some limitations with using 5.1 audio under QuickTime – especially when trying to output it to the Mac’s S/PDIF optical output. This makes me wonder about some not-yet-mentioned features of the upcoming AppleTV and its support for surround sound, and Apple’s approach of using 6-channel AAC audio instead of AC-3.

Dolby Digital AC3

First up, a bit about AC-3, also known as Dolby Digital or A52. AC-3 is Dolby’s way of encoding several channels of audio into a stream which can be passed down an optical S/PDIF cable, and decoded at the other end by a suitable decoder (i.e. your surround sound amp). AC-3 is the format used for 5.1 Dolby Digital surround sound on DVDs. It has five channels for normal-range speakers: Center, Left Front, Right Front, Left Surround, and Right Surround. The extra “.1″ is a Low Frequency Effects (LFE) channel for a subwoofer. Dolby Digital isn’t limited to 5.1 – but this is the most common use you’ll find.

S/PDIF Output

Now, all new Macs come with some form of optical S/PDIF output – either a combined optical digital output/headphone out (minijack) for the MacBook, MacBook Pro, iMac and Mac Mini, or a dedicated optical output on the Mac Pro. So, you’d think that playing 5.1 sound would just be a case of connecting the optical output of your Mac to the optical input of your 5.1-savvy amp. Not so.

Thing is, that optical output doesn’t appear as a six-channel output device on your Mac. In order to send six channels down the optical wire, it has to be encoded into a supported stream such as AC-3. The maximum number of discrete (unencoded) channels you can send via the optical output is two channels, and that’s all you’ll get if you play a movie on a Mac with the optical wire plugged into your stereo, rather than the six channels you might expect

QuickTime doesn’t come with an AC-3 codec by default. There is an open-source QuickTime component available, called A52Codec, which enables QuickTime to open, import and export AC-3 audio. (It does this using a free AC-3 library called liba52.) A52Codec provides some form of support for working with AC-3 under QuickTime, at least for file conversion and export. What the A52Codec can’t do, however, is to enable applications to stream encoded AC-3 data straight to the optical output on the Mac.

Dolby Digital Players

Apple’s DVD Player application – included for free on every Mac – can play the 5.1 AC-3 audio from a physical DVD directly through the optical output of your Mac. DVD Player does this by streaming the encoded AC-3 straight from the DVD to the optical out, bypassing QuickTime. Some other players – notably VLC (which also uses liba52) – will stream AC-3 straight to your optical output, too. But any application which uses QuickTime for its audio playback – and this includes Front Row, iTunes, and QuickTime Player – works by first decoding audio into its discrete channels, before outputting it to your system audio device. The AC-3 encoding is lost in the process. So if you want a Mac Mini and Front Row to run your home theatre, with 5.1 sound from third-party movie files, then it’s not so easy.

What does this all mean? It means that right now, the only way to play multichannel audio (from a .mov file or .mp4 file) on a Mac is to buy a six-channel sound card – something like the Gigaport AG – and set this up in Audio MIDI Setup to support 5.1 sound. You then need to plug the six discrete outputs into an amp with six discrete inputs. You also need to install A52Codec if your source file has an AC-3 soundtrack. Which means that very, very few people will bother to do so.

However, here’s where it gets interesting. For some time now, Apple has been distributing its HD movie trailers with 5.1 audio. But not as an encoded AC-3 audio track – as after all, neither QuickTime player, iTunes, nor FrontRow can play those as mentioned above. Instead, Apple’s trailers come with an AAC-format soundtrack containing six discrete channels, matching the 5.1 channels mentioned above.

Why would Apple bother to ship 5.1 audio, if it’s very hard for most Mac users to play it? This is just a guess, but I think the reason is called Apple TV.

Apple TV

The Apple TV comes with an optical output on the back. This pretty much guarantees that it will somehow output Dolby Digital 5.1 through the optical port. It’s just a hunch, but I’d guess that the Apple TV will have a built-in AC-3 encoder, which will take the six channels from an Apple trailer or movie and encode this into an AC-3 stream on the fly.

So why not just ship these files with an AC-3 soundtrack from the off? This is where I think Apple are being clever. QuickTime 7 is very good at converting between different channel mappings. So, it’s perfectly set up to downmix the six AAC channels into a stereo mix for the average Mac user. The same file, synced to an Apple TV, would then have its six channels encoded into a 5.1 AC-3 stream, to be played through the AppleTV’s optical output to an appropriate amp. This maintains the iPod-like syncing with iTunes, in a file format which iTunes, QuickTime, Front Row and Apple TV can all support. It also means that Apple can pay for a Dolby encoder license as part of each Apple TV sale, without needing to fork out for an encoder license for every QuickTime user in the world.

I might be wrong, and a future version of QuickTime could also include an AC-3 encoder, which would mean Mac owners could benefit from 5.1 optical output too. But it seems more likely that 5.1 is going to be one of the selling points of the Apple TV.

So for now, we’re going to follow Apple’s lead, and make our multichannel movies with six AAC channels too :-)