我使用此扩展名将视频文件从AVAsset
保存到tmp文件夹。问题是,当我使用AVAssetExportPresetHighestQuality
类型的视频文件无法由于这个原因,保存:AVAssetExportPreset类型的AVAssetExportSession问题
错误域= AVFoundationErrorDomain代码= -11800“的操作可能 无法完成”的UserInfo = {NSUnderlyingError = {0x1748482e0错误 域= NSOSStatusErrorDomain代码= -12780 “(空)”}, NSLocalizedFailureReason =出现未知错误(-12780), NSLocalizedDescription =操作无法完成}
还有些时候,甚至当我我正在使用AVAssetExportPresetHighestQuality
它ves视频,但以随机顺序。
extension AVAsset {
func write(to url: URL, success: @escaping() ->(), failure: @escaping (Error) ->()) {
guard let exportSession = AVAssetExportSession(asset: self, presetName: AVAssetExportPresetMediumQuality) else {
let error = NSError(domain: "domain", code: 0, userInfo: nil)
failure(error)
return
}
exportSession.outputFileType = AVFileTypeMPEG4
exportSession.outputURL = url
exportSession.exportAsynchronously {
switch exportSession.status {
case .completed:
success()
case .unknown, .waiting, .exporting, .failed, .cancelled:
let error = NSError(domain: "domain", code: 0, userInfo: nil)
failure(error)
}
}
}
}