Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AVAssetExportSession导出失败NSURErrorDomain代码-=3000(Swift)_Swift_Avfoundation_Avassetexportsession - Fatal编程技术网

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不是有效的url

Hey@THall您能告诉我应该是什么chnkURL吗?我也有同样的问题。