AVAssetExportSession导出失败NSURErrorDomain代码-=3000(Swift)
这是我的密码:AVAssetExportSession导出失败NSURErrorDomain代码-=3000(Swift),swift,avfoundation,avassetexportsession,Swift,Avfoundation,Avassetexportsession,这是我的密码: startTime = endTime endTime = CMTimeMake(startTime.value + chunkSize, duration!.timescale) if endTime > duration { endTime = duration! } let composition = AVMutab
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]导出失败:
可选(错误域=nsurErrorDomain代码=-3000“无法创建文件”
UserInfo={NSLocalizedDescription=无法创建文件,
NSUnderlyingError=0x7ff5ee076460{错误域=NSOSStatusErrorDomain
代码=-12115“(空)”})
非常感谢您的帮助,谢谢 发现了我的错误。chunkURL不是有效的urlHey@THall您能告诉我应该是什么chnkURL吗?我也有同样的问题。