En Fr
Web/database development and more...
« Twitter plugin for b2evolutionMac OSX Terminal Page Up/Down + Home/End of line »

How to get AC-3 5.1 surround sound on your Mac

03/11/09

English (US) How to get AC-3 5.1 surround sound on your Mac

Permalink 03:17:55 am, by Francois Planque Email , Categories: Multimedia, Mac stuff
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:

Follow up:

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)

16 comments

Comment from: Laurie [Visitor] Email
LaurieHi-

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
03/14/09 @ 06:09
Comment from: Francois Planque [Member] Email
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)?
03/14/09 @ 16:54
Comment from: Laurie Sosna [Visitor]
Laurie SosnaYes, 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?


03/14/09 @ 17:34
Comment from: Francois Planque [Member] Email
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?
03/14/09 @ 19:22
Comment from: Laurie [Visitor]
LaurieHave 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.

03/15/09 @ 03:56
Comment from: RaWHiDe [Visitor]
RaWHiDeHi 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!

04/23/09 @ 17:39
Comment from: christian [Visitor]
christiandude u r a legend ! had alot of problems with this ! thanks SOOOO much, really really appreciate it !
07/28/09 @ 14:27
Comment from: satya [Visitor] Email
satyaThese 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?????
09/04/09 @ 15:51
Christian Counseling Madison AlabamaI 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!
10/22/09 @ 08:10
Comment from: Marcus [Visitor]
MarcusAhh 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! :)
11/05/09 @ 23:12
Comment from: Larry [Visitor]
LarryI 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.
12/23/09 @ 00:19
Comment from: Tino [Visitor]
TinoHi 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 (http://fplanque.com/media/dev/2009/midi.png) 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?
01/31/10 @ 10:52
Comment from: Francois Planque [Member] Email
Try 2ch-16 bits! I recently found that It was sometimes necessary to set to 16 bits.
01/31/10 @ 11:29
Comment from: Tino [Visitor]
TinoI 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?
01/31/10 @ 14:13
Comment from: yaseen [Visitor]
yaseenhi, 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.
02/07/10 @ 06:36
Comment from: kevin [Visitor] Email
kevinI 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?
03/03/10 @ 18:12

This post has 2 feedbacks awaiting moderation...

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)