我正在录音。我能够以.caf(核心音频格式)录制音频,后来需要将其转换为.wav或.wma以便将文件上传到FTP服务器。如何在iOS中将文件转换为.wav或.wma格式?使用来自GitHub的POVoiceHUD代码。谁能帮助我解决我的问题。
最佳答案
如果您想将.caf转换为.wav,那么您也可以引用this SO post,就像我在评论中提到的那样。
但是,如果您希望将音频作为.wav或.wma格式发送到服务器或出于任何目的,那么为什么从一开始就不以.wav或.wma格式录制音频。如果您愿意,则无需进行转换。
第二件事,您可以仅将extension
作为.wav
或.wma
提供给存储视频并传递给path
对象的url
或AVAudioRecorder
,就可以将.wav或.wma格式的音频记录下来。
例如,
NSString *folderPath = NSTemporaryDirectory();
NSString *soundFilePath = [folderPath
stringByAppendingPathComponent:[NSString stringWithFormat: @"%.0f%@", [NSDate timeIntervalSinceReferenceDate] *1000.0, @"audio.wav"]];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSLog(@"Using File called: %@",soundFileURL);
audioRecorder = [[ AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSetting error:&error];
[audioRecorder setDelegate:self];
[audioRecorder prepareToRecord];
更新:
我访问过POVoiceHUd,
只需尝试替换下面的行
[self.voiceHud startForFilePath:[NSString stringWithFormat:@"%@/Documents/MySound.caf", NSHomeDirectory()]];
与
[self.voiceHud startForFilePath:[NSString stringWithFormat:@"%@/Documents/MySound.wav", NSHomeDirectory()]];
我认为它将以
.wav
格式存储音频!
关于ios - 如何在GitHub上使用此代码POVoiceHUD将.caf文件转换为.wav或.wma文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38790408/