错误域= AVFoundationErrorDomain代码= -11800“操作无法完成”{错误域= NSOSStatusErrorDomain代码= -16976“(null)”}

我正在使用Swift3 iOS中的video应用程序。 基本上我必须将video资产和音频合并为一个具有淡入淡出效果并将其保存到iPhone库。 为此,我使用以下方法:

private func doMerge(arrayVideos:[AVAsset], arrayAudios:[AVAsset], animation:Bool, completion:@escaping Completion) -> Void { var insertTime = kCMTimeZero var audioInsertTime = kCMTimeZero var arrayLayerInstructions:[AVMutableVideoCompositionLayerInstruction] = [] var outputSize = CGSize.init(width: 0, height: 0) // Determine video output size for videoAsset in arrayVideos { let videoTrack = videoAsset.tracks(withMediaType: AVMediaTypeVideo)[0] let assetInfo = orientationFromTransform(transform: videoTrack.preferredTransform) var videoSize = videoTrack.naturalSize if assetInfo.isPortrait == true { videoSize.width = videoTrack.naturalSize.height videoSize.height = videoTrack.naturalSize.width } outputSize = videoSize } // Init composition let mixComposition = AVMutableComposition.init() for index in 0..<arrayVideos.count { // Get video track guard let videoTrack = arrayVideos[index].tracks(withMediaType: AVMediaTypeVideo).first else { continue } // Get audio track var audioTrack:AVAssetTrack? if index  0 { audioTrack = arrayAudios[index].tracks(withMediaType: AVMediaTypeAudio).first } } // Init video & audio composition track let videoCompositionTrack = mixComposition.addMutableTrack(withMediaType: AVMediaTypeVideo, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) let audioCompositionTrack = mixComposition.addMutableTrack(withMediaType: AVMediaTypeAudio, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) do { let startTime = kCMTimeZero let duration = arrayVideos[index].duration // Add video track to video composition at specific time try videoCompositionTrack.insertTimeRange(CMTimeRangeMake(startTime, duration), of: videoTrack, at: insertTime) // Add audio track to audio composition at specific time var audioDuration = kCMTimeZero if index  Void { if exporter?.status == AVAssetExportSessionStatus.completed { print("Exported file: \(videoURL.absoluteString)") completion(videoURL,nil) } else if exporter?.status == AVAssetExportSessionStatus.failed { completion(videoURL,exporter?.error) print(exporter?.error as Any) } } 

问题:在我的exportDidFinish方法中,AVAssetExportSessionStatus失败并显示以下错误消息:

错误域= AVFoundationErrorDomain代码= -11800“操作无法完成”UserInfo = {NSLocalizedFailureReason =发生未知错误(-16976),NSLocalizedDescription =操作无法完成,NSUnderlyingError = 0x1c065fb30 {错误域= NSOSStatusErrorDomain代码= – 16976“(null)”}}

任何人都可以建议我这个。