xcode 将多个 .wav 转换为 .caf

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8769851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:56:00  来源:igfitidea点击:

Convert multiple .wav to .caf

iphonexcodeaudiococos2d-iphone

提问by FBryant87

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

我正在制作一个 iPhone 应用程序,我有大量的.wav文件需要转换为.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 caffnot -caff. The correct code snippet would then be.

编辑:由于上面显示的 for 循环中的拼写错误,实际上会发生该错误。应该caff不是-caff。正确的代码片段将是。

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

可能还有其他问题,并且接受的答案是有效的,只是想帮助澄清问题。/编辑

回答by Loic Argelies

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.

将其保存在名为“afconvert_wavtocaf.sh”的文件中。看看这是否有效。

回答by iHunter

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

尝试在脚本中添加echo $i;beforeafconvert以获取命令失败的声音文件的名称。然后尝试手动转换它,它也可能会失败。

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

我怀疑您的一个文件不是实际的 wav,而是 .wav 无法识别的格式afconvert