空间视频转换页面:

1,增加平行眼选项;
2,修正切换红蓝立体、交叉眼选项之后无法再次转码的问题,主要是使用了转码后的非空间视频进行转码失败导致,需要使用原空间视频转码才正确;
This commit is contained in:
bluesea 2024-03-06 16:54:01 +08:00
parent 4ea2164b9e
commit 06ab0e319d

View File

@ -45,7 +45,7 @@ class CCSpatialVideoDisplayController: BaseController {
var imgData:Data?
//
//
var type = 0
var player:AVPlayer = AVPlayer()
@ -110,6 +110,7 @@ class CCSpatialVideoDisplayController: BaseController {
}()
var typeData:[(icon:String,title:String,isHiden:Bool)] = [(icon:"type_check",title:"单眼2D",isHiden:false),
(icon:"type_check",title:"平行眼",isHiden:false),
(icon:"type_check",title:"红蓝立体",isHiden:false),
(icon:"type_check",title:"交叉眼",isHiden:false)]
@ -283,6 +284,9 @@ class CCSpatialVideoDisplayController: BaseController {
}else if self.selectedIndex == .crossedEyes {
mTopCenterTypeButton.setTitle("交叉眼", for: UIControl.State.normal)
}
else if self.selectedIndex == .parallelEyes {
mTopCenterTypeButton.setTitle("平行眼", for: UIControl.State.normal)
}
mTopCenterTypeButton.setImage(UIImage.init(named: "type_button_arrow_down"), for: .normal)
mTopCenterTypeButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
@ -377,38 +381,44 @@ class CCSpatialVideoDisplayController: BaseController {
func selectedSpatialType(selectedIndex:Int) {
if selectedIndex == 0 {
self.selectedIndex = .monocular2D
}else if selectedIndex == 1 {
self.selectedIndex = .redBlueSolid
}else if selectedIndex == 2 {
self.selectedIndex = .crossedEyes
// if selectedIndex == 0 {
// self.selectedIndex = .monocular2D
// }else if selectedIndex == 1 {
// self.selectedIndex = .redBlueSolid
// }else if selectedIndex == 2 {
// self.selectedIndex = .crossedEyes
// }
self.selectedIndex = SpatialType(rawValue: selectedIndex) ?? .monocular2D
player.pause()
NotificationCenter.default.removeObserver(self)
//
if(selectedIndex == 0){
videoTempAsset = videoOriginalAsset
play()
}
else{
outputVideoURL = URL.documentsDirectory.appending(path:"output11112.mp4")
}
player.pause()
NotificationCenter.default.removeObserver(self)
//
if(selectedIndex == 0){
videoTempAsset = videoOriginalAsset
play()
}
else{
outputVideoURL = URL.documentsDirectory.appending(path:"output11112.mp4")
}
//
if(selectedIndex == 1){
if(self.selectedIndex == .redBlueSolid){
Task {
convertor2.type = 3
try await convertor2.convertVideo(asset: videoTempAsset!, outputFile: outputVideoURL! ) { [self] progress in
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()
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
//
self!.play()
}
}
}
@ -417,11 +427,11 @@ class CCSpatialVideoDisplayController: BaseController {
}
//
if(selectedIndex == 2){
if(self.selectedIndex == .crossedEyes){
Task {
convertor2.type = 2
try await convertor2.convertVideo(asset: videoTempAsset!, outputFile: outputVideoURL! ) { [self] progress in
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)
@ -435,6 +445,11 @@ class CCSpatialVideoDisplayController: BaseController {
}
}
//
if(self.selectedIndex == .crossedEyes){
}