From 2429df6010dbd1de0d3b923286da5122fbc3ec0a Mon Sep 17 00:00:00 2001 From: bluesea <307723040@qq.com> Date: Wed, 6 Mar 2024 17:32:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B9=B3=E8=A1=8C=E7=9C=BC?= =?UTF-8?q?=E8=BD=AC=E7=A0=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CCSpatialVideoDisplayController.swift | 18 ++++++++++++++++-- .../Project/Util/VideoConvertor2.swift | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController.swift b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController.swift index 9a96e8c..424ee70 100644 --- a/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController.swift +++ b/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController.swift @@ -446,8 +446,22 @@ class CCSpatialVideoDisplayController: BaseController { } //平行眼 - if(self.selectedIndex == .crossedEyes){ - + if(self.selectedIndex == .parallelEyes){ + Task { + convertor2.type = 5 + + try await convertor2.convertVideo(asset: videoOriginalAsset!, outputFile: outputVideoURL! ) { [self] progress in + print(progress) + DispatchQueue.main.async { [weak self] in + self?.progressView.setProgress(progress, animated: true) + if(progress > 0.99){ + self!.videoTempAsset = AVAsset(url: self!.outputVideoURL!) + self!.play() + } + } + + } + } } diff --git a/SwiftProject/SwiftProject/Project/Util/VideoConvertor2.swift b/SwiftProject/SwiftProject/Project/Util/VideoConvertor2.swift index e18a1b4..d19fee6 100644 --- a/SwiftProject/SwiftProject/Project/Util/VideoConvertor2.swift +++ b/SwiftProject/SwiftProject/Project/Util/VideoConvertor2.swift @@ -156,6 +156,20 @@ class VideoConvertor2 { try await Task.sleep(nanoseconds: 3_000_000) } + //平行眼 + if (type == 5){ + let newpb = joinImages( leftImage: rciImage, rightImage:lciImage ) + let time = CMSampleBufferGetOutputPresentationTimeStamp(nextSampleBuffer) + + _ = vw!.add(image: newpb, presentationTime: time) + print( "Added frame at \(time)") + + // callback with progress + progress?( Float(time.value)/Float(duration.value)) + + // This sleep is needed to stop memory blooming - keeps around 280Mb rather than spiraling up to 8+Gig! + try await Task.sleep(nanoseconds: 3_000_000) + } //红蓝立体 if(type == 3){