1
這是我在我的iOS8上斯威夫特應用程序錄制音頻代碼:Xcode的記錄不工作
var fileName = "/SFRecording-" + String(recordingSequence) + ".caf"
var str = storageLocation + fileName
var url = NSURL.fileURLWithPath(str as String)
audioSession.setCategory(AVAudioSessionCategoryRecord, error: nil)
audioSession.setActive(true, error: nil)
var recordSettings = [
AVFormatIDKey:kAudioFormatAppleIMA4,
AVSampleRateKey:44100.0,
AVNumberOfChannelsKey:2,
AVEncoderBitRateKey:12800,
AVLinearPCMBitDepthKey:16,
AVEncoderAudioQualityKey:AVAudioQuality.Max.rawValue
]
var error: NSError?
realRecorder = AVAudioRecorder(URL:url, settings: recordSettings as [NSObject : AnyObject], error: &error)
它工作正常,但是得到的CAF
文件是在Windows系統中無用。我想以更熟悉的格式(如MP3
)進行錄製,但由於授權問題,您無法在iOS中進行錄製。
現在我想在我已經在上面的代碼轉換的文件擴展名從.CAF
到.AAC
並交換價值AVFormatIDKey:kAudioFormatAppleIMA4
到kAudioFormatMPEG4AAC
,但這些設置不記錄任何AAC
格式進行錄製。我想改變一些其他的設置,以使AAC錄音工作?
記住我的目標是一個格式,它是Mac/WIN /瀏覽器容易可玩
您是否嘗試過使用擴展名.m4a保存它? –
@Leonardo Savio Dabus:無效:'OSStatus錯誤1685348671.' – Kashif