我使用以下方法在文档文件夹中录制了一些声音
func record() { self.prepareToRecord() if let recorder = self.audioRecorder { recorder.record() } } let recordSettings = [ AVSampleRateKey : NSNumber(float: Float(44100.0)), AVFormatIDKey : NSNumber(int: Int32(kAudioFormatAppleLossless)), AVNumberOfChannelsKey : NSNumber(int: 2), AVEncoderAudioQualityKey : NSNumber(int: Int32(AVAudioQuality.Medium.rawValue)), AVEncoderBitRateKey : NSNumber(int: Int32(320000)) ] func prepareToRecord() { let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString let soundFileURL: NSURL? = NSURL.fileURLWithPath("\(documentsPath)/recording.caf") print("\(soundFileURL)") self.audioRecorder = try! AVAudioRecorder(URL: soundFileURL!, settings: recordSettings) if let recorder = self.audioRecorder { recorder.prepareToRecord() } }
此方法将音频文件保存为recording.caf到文档目录,但我想将此recording.caf文件转换为mp3以进行进一步操作.
如何将这个.caf文件转换为swift中的.mp3文件?