Domain=AVFoundationErrorDomain Code=-11838\"Operation Stopped\"UserInfo={NSLocalizedDescription=Operation Stopped, NSLocalizedFailureReason=该媒体不支持该操作。})")
{来源:caf lpcm,目的地:aiff 或 wav 或 caf}
代码如下:
let composition = AVMutableComposition()
self.prepareToCombineMedia(composition)
let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetPassthrough)!
let tmpFilePath = FileUtils.tempFile(ext: "caf")
exportSession.outputURL = NSURL.fileURL(withPath: tmpFilePath)
exportSession.outputFileType = AVFileTypeCoreAudioFormat
exportSession.exportAsynchronously {
if exportSession.status == .completed {
print("completed")
print(tmpFilePath)
subscriber.onCompleted()
} else {
subscriber.onError(LeafError.runtime(message: exportSession.error.debugDescription))
FileUtils.rm(tmpFilePath)
}
}
它只能合并到 m4a 或 mov。我需要 caf 或 wav 或 aiff 文件,帮助...
最佳答案
替换这一行:
let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetPassthrough)!
与:
let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleM4A)
希望它会起作用
关于ios - 合并两个音频文件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43039019/