diff --git a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift index d1d292b..1e9cae7 100644 --- a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift +++ b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/VRVideoTransformController.swift @@ -683,21 +683,12 @@ extension VRVideoTransformController { writer.add(writerInput) - guard let assetExportSession = exportSession as? AVAssetExportSession else { - print("Failed to cast export session to AVAssetExportSession") - DispatchQueue.main.async { - SVProgressHUD.showInfo(withStatus: "视频转码失败") - } - completion(nil) - return - } + exportSession.videoComposition = AVMutableVideoComposition(propertiesOf: composition) + exportSession.outputFileType = AVFileType.mov + exportSession.outputURL = outputURL - assetExportSession.videoComposition = AVMutableVideoComposition(propertiesOf: composition) - assetExportSession.outputFileType = AVFileType.mov - assetExportSession.outputURL = outputURL - - assetExportSession.exportAsynchronously { [self] in - switch assetExportSession.status { + exportSession.exportAsynchronously { [self] in + switch exportSession.status { case .completed: let exportedAsset = AVAsset(url: outputURL) DispatchQueue.main.async { @@ -705,7 +696,7 @@ extension VRVideoTransformController { completion(exportedAsset) } case .failed: - if let error = assetExportSession.error { + if let error = exportSession.error { print("Export failed with error: \(error.localizedDescription)") DispatchQueue.main.async { SVProgressHUD.showInfo(withStatus: "视频导出失败:\(error.localizedDescription)")