优化拍摄视频的逻辑

This commit is contained in:
bluesea 2024-04-15 16:50:47 +08:00
parent 8a6c0b365e
commit b902c2bda6
3 changed files with 38 additions and 8 deletions

View File

@ -387,8 +387,8 @@
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift" filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialShootController.swift"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "1223" startingLineNumber = "1237"
endingLineNumber = "1223" endingLineNumber = "1237"
landmarkName = "compositeSpatialPhoto()" landmarkName = "compositeSpatialPhoto()"
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
@ -662,6 +662,21 @@
endingLineNumber = "551" endingLineNumber = "551"
offsetFromSymbolStart = "56"> offsetFromSymbolStart = "56">
</Location> </Location>
<Location
uuid = "BB183D45-3193-4FC7-92DB-275D529A4AE6 - bc6a78627bfebc00"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SwiftProject.CCSpatialVideoDisplayController.displayUpdate(caDisplayLink: __C.CADisplayLink) -&gt; ()"
moduleName = "SwiftProject"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController/CCSpatialVideoDisplayController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "552"
endingLineNumber = "552"
offsetFromSymbolStart = "56">
</Location>
</Locations> </Locations>
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>

View File

@ -40,7 +40,7 @@ class CCSpatialShootController: BaseController {
var outputVideoURL: URL? var outputVideoURL: URL?
let motionManager = CMMotionManager() let motionManager = CMMotionManager()
var imgs:NSMutableArray = NSMutableArray() //广 var imgs:NSMutableArray = NSMutableArray() //广
let spatialVideoWriter = SpatialVideoWriter()
//================================ //================================
// //
@ -729,6 +729,8 @@ class CCSpatialShootController: BaseController {
let time = Date().timeIntervalSince1970 let time = Date().timeIntervalSince1970
let name1 = "wideAngleVideo" + String(time) + ".mov" let name1 = "wideAngleVideo" + String(time) + ".mov"
let name2 = "ultraWideVideo" + String(time) + ".mov" let name2 = "ultraWideVideo" + String(time) + ".mov"
leftEyeVideoURL = nil
rightEyeVideoURL = nil
let wideAngleCameraOutputURL = URL.documentsDirectory.appending(path:name1) let wideAngleCameraOutputURL = URL.documentsDirectory.appending(path:name1)
let fultraWideCameraOutputURL = URL.documentsDirectory.appending(path:name2) let fultraWideCameraOutputURL = URL.documentsDirectory.appending(path:name2)
@ -1044,6 +1046,7 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
DispatchQueue.main.async { DispatchQueue.main.async {
SVProgressHUD.show(withStatus: NSLocalizedString("处理中...", comment: "")) SVProgressHUD.show(withStatus: NSLocalizedString("处理中...", comment: ""))
print("....................................\n..................................")
} }
@ -1081,7 +1084,11 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
print("ultra Wide video recorded: \(outputFileURL)") print("ultra Wide video recorded: \(outputFileURL)")
rightEyeVideoURL = outputFileURL rightEyeVideoURL = outputFileURL
} }
createSpVideo() if let leftEyeVideoURL,
let rightEyeVideoURL {
createSpVideo()
}
} }
} }
} }
@ -1090,25 +1097,32 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
func createSpVideo(){ func createSpVideo(){
if(rightEyeVideoURL != nil && leftEyeVideoURL != nil){ if(rightEyeVideoURL != nil && leftEyeVideoURL != nil){
let spatialVideoWriter = SpatialVideoWriter()
Task { Task {
spatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: leftEyeVideoURL!, rightEyeVideoURL: rightEyeVideoURL!, outputVideoURL: outputVideoURL!) {[self] success, error in spatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: leftEyeVideoURL!, rightEyeVideoURL: rightEyeVideoURL!, outputVideoURL: outputVideoURL!) {[weak self] success, error in
DispatchQueue.main.async { DispatchQueue.main.async {
SVProgressHUD.dismiss() SVProgressHUD.dismiss()
print("SVProgressHUD.dismiss..2222.....")
} }
if success { if success {
print("空间视频生成成功") print("空间视频生成成功")
saveVideoToLibrary(videoURL:outputVideoURL!) if let ovrul = self?.outputVideoURL{
self?.saveVideoToLibrary(videoURL:ovrul)
}
// DispatchQueue.main.async { // DispatchQueue.main.async {
// SVProgressHUD.showSuccess(withStatus: "") // SVProgressHUD.showSuccess(withStatus: "")
// } // }
} else if let error = error { } else if let error = error {
print(".怎么失败了呢.....error\(error)")
DispatchQueue.main.async { DispatchQueue.main.async {
SVProgressHUD.showInfo(withStatus: "\(NSLocalizedString("空间视频保存失败", comment: "")):\(error.localizedDescription)") SVProgressHUD.showInfo(withStatus: "\(NSLocalizedString("空间视频保存失败", comment: "")):\(error.localizedDescription)")
} }
} }
else {
print("not success......")
}
} }
} }
} }
@ -1252,6 +1266,7 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
DispatchQueue.main.async { DispatchQueue.main.async {
SVProgressHUD.dismiss() SVProgressHUD.dismiss()
print("SVProgressHUD.dismiss..1111.....")
} }
if let error = error { if let error = error {