Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert multiple .wav to .caf

I'm making an iPhone app and I have a ton of .wav files I need to convert to .caf

I can use this for each file:

afconvert -f caff -d LEI8@22050 walking.wav walking.caf

But that would take ages, so I'm trying to convert all files with:

for i in *.wav; do afconvert -f -caff -d LEI16@44100 -c 1 $i ${i%.wav}.caf; done

But I get this error:

Error: ExtAudioFileCreateWithURL failed ('typ?')

EDIT:The error will actually occur because of a typo in the for loop shown above. It should be caff not -caff. The correct code snippet would then be.

for i in *.wav; do afconvert -f caff -d LEI16@44100 -c 1 $i ${i%.wav}.caf; done

There may be other issues and the accepted answer is valid, just wanted to help out with making the question clear. /EDIT

like image 472
FBryant87 Avatar asked Jan 07 '12 12:01

FBryant87


People also ask

What is the difference between WAV and CAF?

WAV's own time limit is somewhere between 40 minutes and 13 hours, and CAF's is unlimited. Apple Loops use the CAF format. Generally speaking, you will no problems recording in AIFF format, which is Logic Pro X's default.


2 Answers

This is the script i have been using, slightly modified from another source, which kindly deserves all credit:

##
## Shell script to batch convert all files in a directory to caf sound format for iPhone
## Place this shell script a directory with sound files and run it: 'sh afconvert_wavtocaf.sh'
## Any comments to '[email protected]'
##

for f in *.wav; do
if  [ "$f" != "afconvert_wavtocaf.sh" ]
then
 afconvert -f caff -d ima4 $f
 echo "$f converted"
fi
done

Save this in a file named 'afconvert_wavtocaf.sh'. See if that does the trick.

like image 131
Loic Argelies Avatar answered Oct 06 '22 03:10

Loic Argelies


Try adding echo $i; before afconvert in your script to get the name of sound file your command fails on. Then try to convert it manually, it will probably fail too.

I suspect one of your files is not an actual wav, but is in format not recognizable by afconvert.

like image 20
iHunter Avatar answered Oct 06 '22 04:10

iHunter