Perian

Perian includes the a52 codec you need to decode AC-3 out from AVI or MKV files

So your hooked up your Mac to your 5.1 receiver and all you get is lousy stereo? Worry no more, decent AC-3 support is finally available for Mac OSX!

In my case I have an Intel Mac Mini from 2006 hooked up to a Denon AVR-3801 via a fiber optic S/PDIF connection. On most (fairly recent) macs, an SPDIF fiberoptic cable will be the best solution to get the digital 5.1 signal from your mac to your home theater equipment.

Once you make that connection, there is one thing you should be able to do immeditately: play back DVDs in 5.1 Dolby Digital (or DTS or whatever surround track is on the DVD). If not, remove any DVD from the drive, then launch the DVD player app (not Front Row), go to Settings and tell it to output the DVD sound directly to the digital output instead of using the Mac Mini sound processing system.

If still not, the problem is either the cable or the mode selected on your receiver :p

Now, what if you want to convert your DVDs to files on your terrabyte harddrive? (Private use copy is legal here but I can’t tell you about your country). So for the video you’ll probably use a divx or xvid codec and for the 5.1 audio you’ll use an AC-3 codec… and package all that into a nice AVI file.

Now in order to play that back on your mac, you need a bunch of codecs that are now conveniently packaged in a single downloadable package called Perian.

Once you install Perian, you will get playback but the sound will be stereo, or at best, some variation of Dolby Pro-Logic depending on what you set on the Perian preferences pane. But what you actually want is to get the AC-3 audio from the AVI file straight out to the SPDIF digital out without your Mac doing any alterations (especially not a stereo downmix!)

In order to do that you first need to go to your Applications/Utilities folder and launch the “Audio MIDI Setup” app.

At the lower right, you want to set the Digital Out format to 48000.0 Hz. (See screenshot) That’s the frequency used by AC3. Some say you also want to set it to 2ch-16bit but I haven’t found this to be necessary so I leave it at 2ch-24bit.

Once that is done, you need to launch the Terminal app that you will also find in Applications/Utilities. In the terminal window type the following in order to enable passthrough of the AC3 signal to the digital output:

defaults write com.cod3r.a52codec attemptPassthrough 1

If you ever want to disable pass through of AC-3 to SPDIF, type this:

defaults write com.cod3r.a52codec attemptPassthrough 0

Now open your AVi file in Quicktime and just make sure the volume slider is at the max! Again you don’t want your Mac to interfere with the AC3 signal. From there it should just work :) If not, are you sure your AVI was encoded in 5.1? (hit command-I in QuickTime and check the audio encoding :p)


Comments from long ago:

Comment from: Laurie

Hi-

I tried your method with the command in Terminal and the ac3 file plays fine with VLC. My receiver sees all 5.1 channels on its display. When I play it in QT, I get what sounds like a chattering/static noise. I did change the audiomidi from 24 to 16 with no success.

The DVD player app passes through ok, just not QT, which means Front Row won’t play back ac3 audio.

Any suggestions? Thank you

2009-03-14 06-09

Comment from: François Planque

Laurie I know the chattering noise (it’s generally very high pitched an loud too, isn’t it?)

The only checkpoint you did not mention is: when playing in QT, do you have the QT volume slider below the video at the maximum position (all the way to the right)?

2009-03-14 16-54

Comment from: Laurie Sosna

Yes, it’s all the way up. I always leave it at full volume and use the amplifier to adjust level.

I noticed something else odd. When I plugged the toslink cable into the mini, the volume slider in my menu bar is at the highest level, but it’s “greyed out”, that is, I can’t change the sytem volume. And in the Sound system preferences, the system volume is also greyed out.

Anything like that happen to you?

2009-03-14 17-34

Comment from: François Planque

Yes the greying out of the mac output amplifier level is normal when you send out optical bits. In that case the output amp is not active.

Your case is strange though. Have you tried it with different movie files/types. For me AVI seems to work better than MKV for example. I read something about the time coding being different.

When you hit Command+I in Quicktime, was does it say in the audio section?

2009-03-14 19-22

Comment from: Laurie

Have you ever tried so many things and made so many changes that at some point you’ve just lost the plot?

Well, at some point I did something that I can’t remember and now it’s working. It might have been removing/reinstalling flip4mac or changing the audio midi frequency or the Perian output prefs or the terminal command or maybe it was pixies that came in the night and sprinkled pixie dust. Yeah, that’s it: mac pixies that come in the night!

What ever. Whew!

By the way, if anyone reading this needs a cool test avi, try this one: http://www.tfm.ro/ac3/ click the Downloads link and you’ll find the rar file. Sweet subwoofer sweep.

2009-03-15 03-56

Comment from: RaWHiDe

Hi Francois…

Thank you for a great tip! I have followed your steps exactly, rebooted, and voila! My DVD switched to DTS automatically. Was a little impatient to try it out without setting the DVD player, and was stuck on stereo. But after setting DVD player, it all works perfectly!

2009-04-23 17-39

Comment from: christian

dude u r a legend ! had alot of problems with this ! thanks SOOOO much, really really appreciate it !

2009-07-28 14-27

Comment from: satya

These tips are working fine…But when I play HD movies which have both 2Ch and 5.1ch using frontrow..it always picking 2CH, But if I play the same HD movie going to itunes and changing selecting 5.1 surround option it plays Dolby Digital. Any Idea?????

2009-09-04 15-51

Comment from: Christian Counseling Madison Alabama

I followed your steps properly but something went wrong I guess and couldn’t hear anything. The second time worked though and I haven’t had any trouble with it since then. Thanks a lot!

2009-10-22 08-10

Comment from: Marcus

Ahh awesome! I have been hunting around for an exact how-to tutorial..

I am picking up my first mac today and was a bit unsure about 5.1 playback on my mac..

You eased my worries and I will try it out when I bring my new mac home! :)

2009-11-05 23-12

Comment from: Larry

I don’t know if this is because I have the latest MacBook Pro with Snow Leopard, but 5.1 encoded sound is actually possible to play from mkv-files in VLC without having to make any changes or istall drivers.

I have optical from my laptop connected to my home theater amp and when I start playing the mkv-file I just choose “Built-in Output (Encoded Output)” from the Audio > Audio Device-menu in VLC. My amp then switches to Dolby Digital and all is fine and dandy and I have sweet 5.1 digital audio.

Maybe this is new in Snow Leopard? I have no clue since this is my first Mac.

2009-12-23 00-19

Comment from: Tino

Hi Francois, thanks for your good tutorial - but I don’t get it done :( First my setup:

MAC MINI (Intel-based, 2009) OSX Snow Leopard Flip4Mac (2.2.3.7-for iTunes .wma Internet Radio) Perian (current version) Quicktime (current version) VLC (current version)

AC3 Testfile: http://www.tfm.ro/ac3/download/test_ac3.rar

I followed your instructions. DVD is set to Digital Output and works just fine with two different Dolby Digital 5.1 test DVDs: 5 separate speaker channels, 1 subwoofer - great DVD surround sound.

The Audio MIDI Setup looks a little bit different on Snow Leopard but I chose the same settings. 48000 & 2ch/24.

I enabled Passthrough via Terminal as well and started Quicktime. And … … I hear the same noise described above :(

Using the AC3 testfile from above, I only hear a chattering voice and a loud and partly high pitched noise - but through the correct channels! BTW I tested 3 different AC3 encoded movies in avi and mkv containers as well - same result: very chattering audio.

Ah, yes, the Quicktime volume slider is a its right end.

Trying the same testfile in VLC - it sounds great, clear and clean - but not in surround quality. Front left ist front left, front right is front right, center is front left, center and front right combined, rear left is front&rear left combinded, rear right the same at the right side.

Do you have any idea what I could do?

2010-01-31 10-52

Comment from: François Planque

Try 2ch-16 bits! I recently found that It was sometimes necessary to set to 16 bits.

2010-01-31 11-29

Comment from: Tino

I just changed the settings and chose 2cd/16 - but the same happens. After playing the testfile the voice is chattering front left and front right, center as well but combined with the high pitched noise. rear and sub channel are chattering as well :(

Do you have any other idea?

2010-01-31 14-13

Comment from: yaseen

hi, forgive me as i’m not an expert but when you write in terminal do you just press enter and then it will run the command?? i’ve tweaked with the perian,audio medi and have had no luck. could be due to the fact i dont know how to imput data in termanal lol.

2010-02-07 06-36

Comment from: kevin

I have the optical hooked up and my receiver is seeing AC3. All looks good. However, when playing a DVD, the music seems to cut out every 5 seconds or so. Not a complete cut out but like slight drop in volume for a 1/2 second. Does the same in VLC, DVD Player etc. Any ideas?

2010-03-03 18-12

Comment from: Bill Lyon

VLC plays mp4 with ac-3 properly but Qtime10 will not, I get digital chatter. Since I want to use Front Row, how do I get Quicktime to cooperate?

2010-04-22 00-56

Comment from: DreamConjuror

Francois,

I do not know if I can convey the number of hours I have spent on this. I am new to the Mac world and I am loving it. I knew it would be a multimedia marvel and it is. I had no idea it would be so cumbersome to work out the 5.1 sound thing. I went initally through the Perian combination three months ago with some better results. If I got something with DTS or an actual DVD with AC-3 all was hunky dory. But avi and mkv files with AC-3 kept giving the usual chattering/ I was able to simply convert some file to other formats (using a combination of Mac software and stuff ran through crossover.

I still could not get everything. So for some reason I did another search and found this page.

The tip with going into DVD player really did the thing. I could never figure out why the sound output in the preferences was grayed out.

Thank you so very much.

But I did encounter yet more problems with surround and stereo on my Mac.

THE StuFF THAT MIGHT HELP OTHERS:

– After getting surround sound, I at some point tried to play something on youtube (just stereo)and no sound. I ended having to go back into DVD and change the sound output back to “System SOund Output”.

– At some other point, I could not get a stereo signal, and it ended up that I had to take my AMP and change it from “Straight” input, back to a “stereo” input.

Thanks again Francois, I spent scores and scores of hours on this, and you have brought the time down to a matter of moments. Now to make it all so I do not need to change anything to get each format to work, other changing settings on the AMP.

2010-04-25 22-03

Comment from: Ben

Thank you for this excellent tip! So let me see if I have this straight:

After I install Perian, does DISabling passthru mean that my laptop will now decode the AC3 signal and then send it straight out to plug-n-play 5.1 surround speakers? Then that would mean that if I ENable passthru, I would have to use speakers that have an included decoder (like a receiver setup), right? Would these 2 cases result in the same surround sound? I just need to know what speakers I should buy now, 5.1 speakers with or without a decoder, since that means quite a bit of price difference.

Hope that made sense, and thanks again! Ben

2010-05-27 20-05

Comment from: Zoran

Here is how you can make VLC 0.8.6d and iTunes 9 work (for 6 speakers A B and 1 set of central speakers) on Yamaha RX-V592 and possibly some other amps, with your MAC Mini OSX 10.4.

Connect speakers as your plugs require at the back of amp. Connect your Mac. Important: on amp select 1 Dolby 5.1 Pro logic 2 Wide 3 Give some power to central speaker.

That’s it your Mac will be running with no problem on 6 speakers with imput from not surround source with no converters needed.

Z

2010-06-05 20-13

Comment from: Drew Marshall

thank you thank you thank you!!!

2010-06-12 08-34

Comment from: Matt

Ok… many many hours later… ;-)

I’ve installed Perian (on my new MacMini) and haven’t changed a bit. The settings is:

  • Stereo
  • Normally

All’s well I guess?

So, I open up Audio Midi Setup, and the setting is already at 48,000.0hz so don’t have to change anything here either. I leave the setting on 2ch-24bit…

And still I’m on the right track…right!?

Last… entering the: “defaults write com.cod3r.a52codec attemptPassthrough 1” in the terminal, and also dubbelcheck it in the file…

Now… I should be able to get surround sound thru QT with a m4v? Correct?

Sorry… but just doesn’t work :-/

I’ve checked to change setting in the DVD-player, and playing the DVD works fine… Dolby Digital :-D … but the same DVD ripped into 5.1 channels DPLII in Handbrake… just doesn’t work :-/

What am I doing wrong?

2010-06-21 21-04

Comment from: serr

That’s all well and good but my big question is how do you send 6 discrete channels to the outputs on a firewire interface? You can set up the surround outputs in Audio MIDI Setup but what media player will output the surround from the lossy stereo encoded Dolby and DTS formats?

2010-06-25 03-10

Comment from: MACS

Hi Francois, I did everything as you said, but i don´t have any audio from digital output, I can hear music and videos or DVD movie on the internal speakers, but when I plug the toslink to my macbook and then to my Yamaha receiver, I don´t have any sound! Do you have some idea? Thank you

2010-06-25 05-36

Comment from: Dave Green

my Macbook Pro will not switch off the optical and use the internal speekers no matter what i do - could there be a way to set things back to using internal speekers - using the sound control pan or audio midi setup dont let me change the output to anything but digital,- will switch to headphones but never to internal speakers HELP

2010-07-26 13-38

Comment from: NAZ

Hello Francois

Thanks for your support on the matter

i bougth an external sound card for my macbook pro (SB XFi 5.1) and i got the 5.1 audio working with movies with AC3 but then .. is there a way to get my stereo music go through all my speakers… mp3 is stereo… so is it possible to tweak to play the 2 channels on left and right accordingly…????

Thank you very much

2010-07-29 22-38

Comment from: cheap outdoor gear

Well thanks i was looking for this how to get surround out of it :)

2010-08-12 12-08

Comment from: Chris H

@ Larry

What version of VLC are you running on your Macbook? Like you, I’ve got the latest Macbook Pro with Snow Leopard and plenty of functional .mkv files, but I can’t find the 5.1 option in Audio options.

2010-08-20 02-10

Comment from: Johan

Hi Francois

Did you make it work with SL 10.6 ?

I tried the settings described above and I only get some stereo sound (PCM on my receiver).

My Hardware is an Intel Mac Mini, with 2 Ghz Core 2 duo., connected with a Fiber optic to my receiver which is an Arcam.

Thanks !

2010-08-31 21-44

Comment from: David

I use to have the chattering/static noise whenever playing AC-3 and surround sound encoded files in Quicktime on my laptop. It took me too much time mucking around to figure out what I had done wrong!

To remove the static noise for surround sound audio and video I used both: defaults write com.cod3r.a52codec attemptPassthrough 0 and sudo defaults write com.cod3r.a52codec attemptPassthrough 0

The reason I failed in the first place was because I prepended “sudo” to my commands, when in reality “sudo defaults *” is different to “defaults *”. I’m too use to needing it on nix systems obviously.

2010-09-02 21-33

Comment from: admin

dude u r a legend ! had alot of problems with this ! thanks SOOOO much, really really appreciate it !

2010-09-22 07-38

Comment from: Kris Van de Sande

This worked great for audio playback through avi files etc; however, this did not work for Soundtrack Pro, the main reason 1 want the 5.1 mixing. :(

any ideas ?

2010-09-30 23-55

Comment from: CloneDVD

dude thank you. nice post. that is what i need.

2010-12-02 08-12

Comment from: DVD X Player

I had the same problem and googled solutions to find you. Great! It works! Thank you soooo much!

2010-12-09 07-51

Comment from: Floris

i have done everything, my amp sees dolby surround slider to the right, new version flip4mac i heare nothing/?!

sorry for my bad english i am from the netherlands And can’t found a good tuturial there, i am 13

2011-03-09 17-49

Comment from: Ace23

Thank You!!!!!!

2011-03-13 10-28

Comment from: monasun

I have been able to get Dolby sound out the Mac without problems. By using your suggestions (above). I then bought this Diamond external sound card and I get the digital sound from the Mac to my 5.1 speakers(no problem). but when I try to connect the Xbox and the TV (either analog or digital), I get no sound at all. How would I control the flow of data to my speakers. This is suppose to work. What am I doing wrong

any ideas? suggestions?

Thanks

2011-04-04 08-42

Comment from: Inaxio

“Mac_mini” HDMI out to Sony Bravia=Video OK “Mac_mini” audio out toslink 3,5 to YAMAHA RXV-440=Audio dont work= no sound. help please.. i have tryed somo configurations but no results. excuse my english.

2011-08-09 00-35

Comment from: Thierry

I received a video movie from a postproduction company. Here’s the info: Apple ProRes 422 (HQ), Linear PCM, Timecode

There’s 7 sound tracks. Tracks 1 to 5: dolby and tracks 6-7: stereo.

To approve the file, I need to listen to the dolby tracks. Here’s what I tried: 1- I connected my MB pro with an optical cable. 2- I tested the connection with the macos included DVD Player. The dolby digital works fine when I unckecked the dolby compression option. 3- I played my .mov video with Quicktime 10.1. Only stereo. 4- Tried with VLC and NicePlayer and unchecked tracks 6-7. Only stereo. 5- Even if it’s not AC3 sound, I tried with Perian and Quicktime 10.1 (http://www.cod3r.com/2008/02/the-correct-way-to-enable-ac3-passthrough-with-quicktime/). Still stereo.

Can anyone tell me what am I doing wrong? I would be appreciated.

Thanks

2012-09-12 21-04