How to use afconvert to convert from .caf to .mp3

2019-03-14 12:19发布

问题:

I am using the afconvert command line utility to convert an audio file from .caf to .mp3 format. I have used afconvert:

afconvert -f 'MPG3 ' -d '.mp3' -v input.caf output.mp3 

But this gives me the following error:

Input file: input.caf, 19008 frames
Error: ExtAudioFileSetProperty ('cfmt') failed ('fmt?')

I have also tried the following:

afconvert -f 'MPG3 ' -d LEI32@44100 -v input.caf  output.mp3

This also gives me the error:

Input file: min.caf, 19008 frames
Error: ExtAudioFileCreateWithURL failed ('fmt?')

I couldn't figure out why is this giving error.

Can anybody guide me in solving this problem?

Thanks in an advance.

回答1:

you should check this,

afconvert -f mp4f -d aac -b 128000   input.caf output2.mp4

This way you will convert your CAF file to the MPEG-4 format.

Read: Apple does not ship any form of MP3 encoder with Mac OS X aside from the one built into iTunes. source: http://lists.apple.com/archives/coreaudio-api/2005/Jul/msg00182.html

you should use 3rd party encoders if you need to encode mp3 Mp3 Encoder examples: lame encoder or ffmpeg :) good luck.



回答2:

You can install LAME encoder and use it.

If you have Mac Ports (if don't - just search and install), just run:

sudo port install lame

First, you will have to convert caf to wav (I had no chance to check if LAME supports caf as input, but it supports wav for sure). Then run

lame --alt-preset cbr 128 sample.wav

This will create mp3 file with 128 kbps constant bitrate. LAME has lot of settings, you can choose mp3 parameters as you wish.



回答3:

try this:

afconvert -f mp4f -d aac -v input.caf output.mp3

I know it's not exactly mp3, but I couldn't get around that same error you are getting, so I tried mp4f and it worked.