Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to use afconvert to convert an audio file to AC-3 format. It's 5.1 audio, having already been converted from DTS to WAV (using ffmpeg, since afconvert doesn't seem to deal with DTS).

As you can see, I've tried various parameter incantations, including trying to use a different container formats, but with no success:

$ afconvert -f ac-3 test.wav 
Error: ExtAudioFileCreateWithURL failed ('typ?')
$ afconvert -f ac-3 -d ac-3 test.wav 
Error: ExtAudioFileCreateWithURL failed ('typ?')
$ afconvert -f caff -d AC-3 test.wav 
Error: ExtAudioFileSetProperty ('cfmt') failed ('fmt?')

I have been able to encode it to an AAC file successfully, so it's presumably something with the AC-3 encoding, but Googling those errors yields no results. Does anyone know how to properly convert to AC-3 with afconvert?

If you want to do some testing yourself, I found some free 5.1 DTS sample files here. Note that while the file extension is .wav, they're actually DTS files, not WAV. To replicate my desired workflow, decode to a WAV file with ffmpeg: ffmpeg -i input.wav -acodec pcm_s16le -f wav output.wav, then you'll have a proper 5.1 WAV file afconvert should be able to work with.

share|improve this question
add comment

2 Answers

Can't you use ffmpeg? This seemed to work for the DTS WAV files here:

ffmpeg -i test.wav -ab 640k test.ac3
share|improve this answer
    
Yeah, that's my fallback. In the past the ffmpeg AC3 encoders haven't had a great reputation for quality, which is why I was hoping to avoid it. –  robmathers Apr 1 '13 at 18:41
add comment

EDIT: Deleted original answer as it did not pertain.

Did an alternate test on my box, mainly to generate a file that would allow me to test afconvert, but came up with another solution to generate an AC3 file, which does not use ffmpeg:

So, starting with a mono 44100 wav file, I used 'sox' to merge multiple wav files into a multiple channel wav: surround.wav which I then used 'aften' to convert to an AC3 encoded file:

$ file surround.wav 
surround.wav: RIFF (little-endian) data, WAVE audio, 5 channels 44100 Hz

$ aften -b 448 -cmix 0 -smix 0 -dsur 2 -acmod 7 surround.wav surround.ac3


$ file surround.ac3 
surround.ac3: ATSC A/52 aka AC-3 aka Dolby Digital stream, 44.1 kHz,, complete main (CM) 3 front/2 rear, LFE on,, 448 kbit/s not Dolby Surround encoded

(src: http://parumi.wordpress.com/2007/12/12/how-to-create-multichannel-51-ac3-audio-and-video-in-linux/ )

Still working on why afconvert won't honor or work with the ac-3 format.

share|improve this answer
    
Thanks, but not really helpful. That's for converting to AAC, which as I noted in the question already works, but is not my desired output. It seems to be an issue specific to the AC3 conversion. I'll try to find a decent sample file and link to it later if you want to test some things out. –  robmathers Apr 9 '13 at 23:59
    
Sure thing. Like Lauri, I've been doing my audio conversion via ffmpeg and the like. :) I'll update my answer if I get the file to encode. –  Wing Tang Wong Apr 10 '13 at 0:11
1  
Thanks. I've used aften before on my Linux box, but for some reason I didn't think it was available for OS X. Just discovered there's a Homebrew formula, so that's a good option. Still hoping out for an afconvert solution, but this was helpful, thanks! –  robmathers Apr 10 '13 at 2:52
1  
Did some more digging and ran into an interesting problem: "afinfo output.ac3" this resulted in the error: "Fail: AudioFileOpenURL failed" I suspect that the AC-3 codec as accessed via the af* binaries might be a bit wonky. The afinfo worked fine on the 5.1 channel wave file, however. –  Wing Tang Wong Apr 10 '13 at 4:13
1  
Aften is also easy to compile with CMake and should do what you're looking to accomplish. I downloaded the samples you mentioned, converted them to .wav, then used Aften to output to AC-3 format with no issues at all. –  l'L'l Apr 13 '13 at 4:10
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.