From 7632ba3312e0ed4c9473b1036167f25eccbffbd2 Mon Sep 17 00:00:00 2001 From: bluesea <307723040@qq.com> Date: Mon, 11 Mar 2024 17:08:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=97=A0=E6=95=88=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRVideoTransformController.swift | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) 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)")