Converting Audio to AC-3 using afconvert? 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.
Can't you use ffmpeg? This seemed to work for the DTS WAV files here:

ffmpeg -i test.wav -ab 640k test.ac3