Tôi có ghi lại một số bằng giọng nói vào tài liệu thư mục sử dụng phương pháp sau đâyLàm thế nào để chuyển đổi tệp .caf thành tệp .mp3?
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()
}
}
Phương pháp này sẽ lưu các tập tin âm thanh như recording.caf trong vào danh mục tài liệu, nhưng tôi muốn chuyển đổi tập tin recording.caf này trong sang mp3 để thao tác thêm.
Cách chuyển đổi tệp .caf này thành .mp3 nhanh chóng?
apple không hỗ trợ mp3, tại sao bạn không lưu nó thành .mp4? – karthikeyan