[英]AVAssetExportSession export failure NSURLErrorDomain Code-=3000 (Swift)
这是我的代码:
startTime = endTime
endTime = CMTimeMake(startTime.value + chunkSize, duration!.timescale)
if endTime > duration {
endTime = duration!
}
let composition = AVMutableComposition()
let videoCompTrack = composition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID())
let assetVideoTrack: AVAssetTrack = asset!.tracksWithMediaType(AVMediaTypeVideo).first!
let chunkDuration = CMTimeSubtract(endTime, startTime)
let chunkTimeRange = CMTimeRangeMake(startTime, chunkDuration)
do {
try videoCompTrack.insertTimeRange(chunkTimeRange, ofTrack: assetVideoTrack, atTime: kCMTimeZero)
} catch let error as NSError {
print("Video reversing chunking failure: \(error)")
}
let exportSession = AVAssetExportSession(asset: composition, presetName: preferredPreset)
exportSession!.outputURL = chunkURL
exportSession!.outputFileType = AVFileTypeQuickTimeMovie
exportSession?.shouldOptimizeForNetworkUse = true
removeFileAtURLIfExists(chunkURL)
exportSession!.exportAsynchronouslyWithCompletionHandler({ () -> Void in
switch (exportSession!.status) {
case AVAssetExportSessionStatus.Completed:
NSLog("Export completed")
case AVAssetExportSessionStatus.Cancelled:
NSLog("Export cancelled")
break;
default:
NSLog("Export failed: \(exportSession?.error)")
}
})
这是错误消息:
2015-11-13 10:34:24.307 DemFishes[3501:63127] 导出失败:可选(错误域=NSURLErrorDomain Code=-3000“无法创建文件”UserInfo={NSLocalizedDescription=无法创建文件,NSUnderlyingError=0x64ff50ee { NSOSStatusErrorDomain Code=-12115 "(null)"}})
非常感谢任何帮助,谢谢!
发现我的错误。 chunkURL 不是有效的 url
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.