Using afconvert command line tool to convert .mp3 files to m4r

533 Views Asked by At

I have a short bash script that is meant to convert a folder full of .mp3 files to .m4r ringtones. I am having trouble figuring out why it is throwing the following error:

"Error: ExtAudioFileCreateWithURL failed ('fmt?')"

#!/bin/bash

cd "/path/to/directory/containing/mp3s"

for i in *.mp3; do
    baseFilename=$( basename ${i} .mp3 )
    afconvert -f m4af ${i} -o "/path/to/new/location/${baseFilename}.m4r"
done

exit 0
1

There are 1 best solutions below

0
On BEST ANSWER

The issue was that I had not specified the output data format. Found a helpful page that lead me to the answer:

http://support.moonpoint.com/os/os-x/audio/afconvert.php

    #!/bin/bash

cd "/path/to/directory/containing/mp3s"

for i in *.mp3; do
    baseFilename=$( basename "${i}" .mp3 )
    afconvert -f m4af "${i}" -d aac "/path/to/new/location/${baseFilename}.m4r"
done

exit 0