视频转码页面增加转码等待界面
This commit is contained in:
parent
53f570d6d0
commit
2ebfc413f0
@ -7,7 +7,7 @@
|
|||||||
<key>Alamofire.xcscheme_^#shared#^_</key>
|
<key>Alamofire.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>6</integer>
|
<integer>7</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>CocoaAsyncSocket.xcscheme_^#shared#^_</key>
|
<key>CocoaAsyncSocket.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -17,52 +17,52 @@
|
|||||||
<key>DeviceKit.xcscheme_^#shared#^_</key>
|
<key>DeviceKit.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>17</integer>
|
<integer>14</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>FirebaseCore.xcscheme_^#shared#^_</key>
|
<key>FirebaseCore.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>16</integer>
|
<integer>15</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>FirebaseCoreExtension.xcscheme_^#shared#^_</key>
|
<key>FirebaseCoreExtension.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>10</integer>
|
<integer>5</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>FirebaseCoreInternal.xcscheme_^#shared#^_</key>
|
<key>FirebaseCoreInternal.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>14</integer>
|
<integer>17</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>FirebaseCrashlytics.xcscheme_^#shared#^_</key>
|
<key>FirebaseCrashlytics.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>18</integer>
|
<integer>2</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>FirebaseInstallations.xcscheme_^#shared#^_</key>
|
<key>FirebaseInstallations.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>3</integer>
|
<integer>21</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>FirebaseMessaging.xcscheme_^#shared#^_</key>
|
<key>FirebaseMessaging.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>5</integer>
|
<integer>10</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>FirebaseSessions.xcscheme_^#shared#^_</key>
|
<key>FirebaseSessions.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>21</integer>
|
<integer>12</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>GoogleDataTransport.xcscheme_^#shared#^_</key>
|
<key>GoogleDataTransport.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>19</integer>
|
<integer>20</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>GoogleUtilities.xcscheme_^#shared#^_</key>
|
<key>GoogleUtilities.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>8</integer>
|
<integer>9</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>KTVHTTPCache.xcscheme_^#shared#^_</key>
|
<key>KTVHTTPCache.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -72,52 +72,52 @@
|
|||||||
<key>Kingfisher-Kingfisher.xcscheme_^#shared#^_</key>
|
<key>Kingfisher-Kingfisher.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>9</integer>
|
<integer>6</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Kingfisher.xcscheme_^#shared#^_</key>
|
<key>Kingfisher.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>4</integer>
|
<integer>3</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>LLCycleScrollView.xcscheme_^#shared#^_</key>
|
<key>LLCycleScrollView.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>20</integer>
|
<integer>4</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Pods-SwiftProject.xcscheme_^#shared#^_</key>
|
<key>Pods-SwiftProject.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>7</integer>
|
<integer>19</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>PromisesObjC.xcscheme_^#shared#^_</key>
|
<key>PromisesObjC.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>15</integer>
|
<integer>16</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>PromisesSwift.xcscheme_^#shared#^_</key>
|
<key>PromisesSwift.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>12</integer>
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SVProgressHUD.xcscheme_^#shared#^_</key>
|
<key>SVProgressHUD.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>1</integer>
|
<integer>13</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SnapKit.xcscheme_^#shared#^_</key>
|
<key>SnapKit.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>11</integer>
|
<integer>18</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>TZImagePickerController.xcscheme_^#shared#^_</key>
|
<key>TZImagePickerController.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>0</integer>
|
<integer>1</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>nanopb.xcscheme_^#shared#^_</key>
|
<key>nanopb.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>2</integer>
|
<integer>11</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<key>SwiftProject.xcscheme_^#shared#^_</key>
|
<key>SwiftProject.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>13</integer>
|
<integer>8</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
|||||||
Binary file not shown.
@ -238,8 +238,8 @@
|
|||||||
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController.swift"
|
filePath = "SwiftProject/Project/Controller/RecordingVideo/CCSpatialVideoDisplayController.swift"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "437"
|
startingLineNumber = "440"
|
||||||
endingLineNumber = "437"
|
endingLineNumber = "440"
|
||||||
landmarkName = "setttinisScreenMirroring(isScreenMirroring:)"
|
landmarkName = "setttinisScreenMirroring(isScreenMirroring:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
|
|||||||
23
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Contents.json
vendored
Normal file
23
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Empty_state_导出成功.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "Empty_state_导出成功@2x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "Empty_state_导出成功@3x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Empty_state_导出成功.png
vendored
Normal file
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Empty_state_导出成功.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Empty_state_导出成功@2x.png
vendored
Normal file
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Empty_state_导出成功@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Empty_state_导出成功@3x.png
vendored
Normal file
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exported.imageset/Empty_state_导出成功@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
23
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Contents.json
vendored
Normal file
23
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Empty_state_导出中.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "Empty_state_导出中@2x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "Empty_state_导出中@3x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Empty_state_导出中.png
vendored
Normal file
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Empty_state_导出中.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Empty_state_导出中@2x.png
vendored
Normal file
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Empty_state_导出中@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Empty_state_导出中@3x.png
vendored
Normal file
BIN
SwiftProject/SwiftProject/Assets.xcassets/asset_exporting.imageset/Empty_state_导出中@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
@ -163,7 +163,7 @@ func KColorFromRGB(rgbValue: UInt32,alpha: CGFloat) -> UIColor {
|
|||||||
let green = ((rgbValue & 0xFF00) >> 8) / temp
|
let green = ((rgbValue & 0xFF00) >> 8) / temp
|
||||||
let blue = (rgbValue & 0xFF) / temp
|
let blue = (rgbValue & 0xFF) / temp
|
||||||
|
|
||||||
return UIColor(red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: 1)
|
return UIColor(red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: alpha)
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - 控件按照屏宽比例尺寸
|
//MARK: - 控件按照屏宽比例尺寸
|
||||||
|
|||||||
@ -397,10 +397,13 @@ class CCSpatialVideoDisplayController: BaseController, AVPlayerViewControllerDel
|
|||||||
|
|
||||||
override func viewDidDisappear(_ animated: Bool) {
|
override func viewDidDisappear(_ animated: Bool) {
|
||||||
super.viewDidDisappear(animated)
|
super.viewDidDisappear(animated)
|
||||||
|
|
||||||
let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_VideoDisplayController)
|
let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_VideoDisplayController)
|
||||||
Analytics.logEvent("preview_pv", parameters: ["refer_page":"视频预览页面","duration":sec])
|
Analytics.logEvent("preview_pv", parameters: ["refer_page":"视频预览页面","duration":sec])
|
||||||
|
player?.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
super.viewDidAppear(animated)
|
super.viewDidAppear(animated)
|
||||||
// 检查当前是否已连接到 AirPlay 设备
|
// 检查当前是否已连接到 AirPlay 设备
|
||||||
|
|||||||
@ -63,11 +63,12 @@ class VRVideoTransformController: BaseController {
|
|||||||
var mBottomBtn:UIButton?
|
var mBottomBtn:UIButton?
|
||||||
lazy var progressView:CCTransformProgressPopView? = {
|
lazy var progressView:CCTransformProgressPopView? = {
|
||||||
let pv = CCTransformProgressPopView.init(frame: view.bounds)
|
let pv = CCTransformProgressPopView.init(frame: view.bounds)
|
||||||
pv.closeActionBlock = {
|
pv.closeActionBlock = { [weak self] in
|
||||||
|
self?.navigationController?.popToRootViewController(animated: true)
|
||||||
|
pv.removeFromSuperview()
|
||||||
}
|
}
|
||||||
pv.transformActionBlock = {
|
pv.transformActionBlock = {
|
||||||
|
pv.isHidden = true
|
||||||
}
|
}
|
||||||
return pv
|
return pv
|
||||||
}()
|
}()
|
||||||
@ -93,15 +94,17 @@ class VRVideoTransformController: BaseController {
|
|||||||
//显示进度条
|
//显示进度条
|
||||||
func showProgress() {
|
func showProgress() {
|
||||||
if self.progressView?.superview == nil {
|
if self.progressView?.superview == nil {
|
||||||
self.view .addSubview(self.progressView!)
|
self.view.addSubview(self.progressView!)
|
||||||
}
|
}
|
||||||
//还未处理完毕...
|
//还未处理完毕...
|
||||||
|
self.progressView?.resetUI()
|
||||||
self.progressView?.isHidden = false
|
self.progressView?.isHidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
self.setNavgationBarColor(color: UIColor.clear)
|
self.setNavgationBarColor(color: UIColor.clear)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidDisappear(_ animated: Bool) {
|
override func viewDidDisappear(_ animated: Bool) {
|
||||||
@ -110,8 +113,13 @@ class VRVideoTransformController: BaseController {
|
|||||||
Analytics.logEvent("transcode_video_pv", parameters: ["refer_page":"视频转码页面","duration":sec])
|
Analytics.logEvent("transcode_video_pv", parameters: ["refer_page":"视频转码页面","duration":sec])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
print("deinit--class:\(String(describing: object_getClass(self))) objc:\(self)")
|
||||||
|
}
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_VideoTransformController)
|
ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_VideoTransformController)
|
||||||
self.view.backgroundColor = UIColor.black
|
self.view.backgroundColor = UIColor.black
|
||||||
self.navLine?.isHidden = true
|
self.navLine?.isHidden = true
|
||||||
@ -557,7 +565,8 @@ extension VRVideoTransformController {
|
|||||||
@objc private func videoTransformAction() {
|
@objc private func videoTransformAction() {
|
||||||
// let path = Bundle.main.path(forResource: "IMG_0071", ofType: "MOV")
|
// let path = Bundle.main.path(forResource: "IMG_0071", ofType: "MOV")
|
||||||
// let videoURL = URL.init(filePath: path!)
|
// let videoURL = URL.init(filePath: path!)
|
||||||
|
self.showProgress()
|
||||||
|
self.mAvPlayer?.player?.pause()
|
||||||
let videoURL = sourceVideoURL
|
let videoURL = sourceVideoURL
|
||||||
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||||
let outputURL = documentsDirectory.appendingPathComponent("output_path.mov")
|
let outputURL = documentsDirectory.appendingPathComponent("output_path.mov")
|
||||||
@ -587,14 +596,24 @@ extension VRVideoTransformController {
|
|||||||
let outputVideoURL = URL.documentsDirectory.appending(path:"convertor_one.mov")
|
let outputVideoURL = URL.documentsDirectory.appending(path:"convertor_one.mov")
|
||||||
let videoOriginalAsset:AVAsset? = AVAsset(url: sourceVideoURL!)
|
let videoOriginalAsset:AVAsset? = AVAsset(url: sourceVideoURL!)
|
||||||
Task {
|
Task {
|
||||||
try await spatialVideoConver.convertVideo(asset: videoOriginalAsset!, outputFile: outputVideoURL ,type: self.selected3DFormat) { [self] (progress,state) in
|
try await spatialVideoConver.convertVideo(asset: videoOriginalAsset!, outputFile: outputVideoURL ,type: self.selected3DFormat) { [weak self] (progress,state) in
|
||||||
print(progress)
|
if(state){
|
||||||
if(state){
|
DispatchQueue.main.async {
|
||||||
print("zzh the progress \(progress)")
|
self?.progressView?.updateProgress(value: 0.8)
|
||||||
// 要执行的任务
|
}
|
||||||
self.exportVideo(url: outputVideoURL, outputURL: outputURL, width: width, height: height,codecType:codecType, dataRate: dataRate, horizontalDisparity: horizontalDisparity, horizontalFieldOfView: horizontalFieldOfView) { exportedAsset in
|
|
||||||
}
|
// 要执行的任务
|
||||||
}
|
self?.exportVideo(url: outputVideoURL, outputURL: outputURL, width: width, height: height,codecType:codecType, dataRate: dataRate, horizontalDisparity: horizontalDisparity, horizontalFieldOfView: horizontalFieldOfView) { exportedAsset in
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print(".....out pro:\(progress)")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
print(".....in pro:\(progress)")
|
||||||
|
self?.progressView?.updateProgress(value: progress)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,7 +623,11 @@ extension VRVideoTransformController {
|
|||||||
let asset = AVAsset(url: url)
|
let asset = AVAsset(url: url)
|
||||||
|
|
||||||
guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetPassthrough) else {
|
guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetPassthrough) else {
|
||||||
print("Failed to create export session")
|
// print("Failed to create export session")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.progressView?.updateInfo(title: "转码失败", desc: "导出会话创建失败")
|
||||||
|
}
|
||||||
|
|
||||||
completion(nil)
|
completion(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -613,7 +636,10 @@ extension VRVideoTransformController {
|
|||||||
let videoTrack = composition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid)
|
let videoTrack = composition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid)
|
||||||
|
|
||||||
guard let assetTrack = asset.tracks(withMediaType: .video).first else {
|
guard let assetTrack = asset.tracks(withMediaType: .video).first else {
|
||||||
print("Failed to get video track from asset")
|
// print("Failed to get video track from asset")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.progressView?.updateInfo(title: "转码失败", desc: "未能成功加载视频轨道")
|
||||||
|
}
|
||||||
completion(nil)
|
completion(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -621,7 +647,10 @@ extension VRVideoTransformController {
|
|||||||
do {
|
do {
|
||||||
try videoTrack?.insertTimeRange(CMTimeRange(start: .zero, duration: asset.duration), of: assetTrack, at: .zero)
|
try videoTrack?.insertTimeRange(CMTimeRange(start: .zero, duration: asset.duration), of: assetTrack, at: .zero)
|
||||||
} catch {
|
} catch {
|
||||||
print("Failed to insert video track into composition")
|
// print("Failed to insert video track into composition")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.progressView?.updateInfo(title: "转码失败", desc: "未能成功插入视频轨道")
|
||||||
|
}
|
||||||
completion(nil)
|
completion(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -673,14 +702,20 @@ extension VRVideoTransformController {
|
|||||||
|
|
||||||
guard let writer = try? AVAssetWriter(outputURL: outputURL, fileType: AVFileType.mp4) else {
|
guard let writer = try? AVAssetWriter(outputURL: outputURL, fileType: AVFileType.mp4) else {
|
||||||
print("Failed to create AVAssetWriter")
|
print("Failed to create AVAssetWriter")
|
||||||
|
// DispatchQueue.main.async {
|
||||||
|
// SVProgressHUD.showInfo(withStatus: "视频转码失败")
|
||||||
|
// }
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
SVProgressHUD.showInfo(withStatus: "视频转码失败")
|
self.progressView?.updateInfo(title: "转码失败", desc: "创建媒体写入失败")
|
||||||
}
|
}
|
||||||
completion(nil)
|
completion(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.add(writerInput)
|
writer.add(writerInput)
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.progressView?.updateProgress(value: 1)
|
||||||
|
}
|
||||||
|
|
||||||
exportSession.videoComposition = AVMutableVideoComposition(propertiesOf: composition)
|
exportSession.videoComposition = AVMutableVideoComposition(propertiesOf: composition)
|
||||||
exportSession.outputFileType = AVFileType.mov
|
exportSession.outputFileType = AVFileType.mov
|
||||||
@ -698,12 +733,14 @@ extension VRVideoTransformController {
|
|||||||
if let error = exportSession.error {
|
if let error = exportSession.error {
|
||||||
print("Export failed with error: \(error.localizedDescription)")
|
print("Export failed with error: \(error.localizedDescription)")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
SVProgressHUD.showInfo(withStatus: "视频导出失败:\(error.localizedDescription)")
|
// SVProgressHUD.showInfo(withStatus: "视频导出失败:\(error.localizedDescription)")
|
||||||
|
self.progressView?.updateInfo(title: "转码完成", desc: "导出内容失败")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print("Export failed")
|
print("Export failed")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
SVProgressHUD.showInfo(withStatus: "视频导出失败")
|
// SVProgressHUD.showInfo(withStatus: "视频导出失败")
|
||||||
|
self.progressView?.updateInfo(title: "转码完成", desc: "导出内容失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -711,7 +748,8 @@ extension VRVideoTransformController {
|
|||||||
case .cancelled:
|
case .cancelled:
|
||||||
print("Export cancelled")
|
print("Export cancelled")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
SVProgressHUD.showInfo(withStatus: "视频导出失败 cancelled")
|
// SVProgressHUD.showInfo(withStatus: "视频导出失败 cancelled")
|
||||||
|
self.progressView?.updateInfo(title: "转码完成", desc: "导出内容失败")
|
||||||
}
|
}
|
||||||
completion(nil)
|
completion(nil)
|
||||||
default:
|
default:
|
||||||
@ -728,13 +766,16 @@ extension VRVideoTransformController {
|
|||||||
if success {
|
if success {
|
||||||
print("Video saved to album")
|
print("Video saved to album")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
SVProgressHUD.showSuccess(withStatus: "视频转码成功,已保存到相册")
|
//SVProgressHUD.showSuccess(withStatus: "视频转码成功,已保存到相册")
|
||||||
|
self.progressView?.updateInfo(title: "转码完成", desc: "导出内容已存储到相册中")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print("Failed to save video to album: \(error?.localizedDescription ?? "Unknown error")")
|
print("Failed to save video to album: \(error?.localizedDescription ?? "Unknown error")")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
SVProgressHUD.showInfo(withStatus: "视频转码失败:\(error?.localizedDescription ?? "Unknown error")")
|
//SVProgressHUD.showInfo(withStatus: "视频转码失败:\(error?.localizedDescription ?? "Unknown error")")
|
||||||
|
self.progressView?.updateInfo(title: "转码完成", desc: "导出内容失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,7 +136,7 @@ class SpatialVideoConvertor {
|
|||||||
vw = VideoWriter(url: outputFile, width: Int(cwidth), height: Int(cheight), orientation: orientation, sessionStartTime: CMTimeMake(value: 0, timescale: 1), isRealTime: true, queue: .main)
|
vw = VideoWriter(url: outputFile, width: Int(cwidth), height: Int(cheight), orientation: orientation, sessionStartTime: CMTimeMake(value: 0, timescale: 1), isRealTime: true, queue: .main)
|
||||||
}
|
}
|
||||||
_ = vw!.add(image: newpb!, presentationTime: time)
|
_ = vw!.add(image: newpb!, presentationTime: time)
|
||||||
print( "Added frame at \(time)")
|
// print( "Added frame at \(time)")
|
||||||
|
|
||||||
// callback with progress
|
// callback with progress
|
||||||
progress?( Float(time.value)/Float(duration.value),false)
|
progress?( Float(time.value)/Float(duration.value),false)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class CCTransformProgressPopView: UIView {
|
|||||||
|
|
||||||
lazy var iconImageView: UIImageView = {
|
lazy var iconImageView: UIImageView = {
|
||||||
let imageView = UIImageView()
|
let imageView = UIImageView()
|
||||||
imageView.image = UIImage.init(named: "info_step_head_img_default")
|
imageView.image = UIImage.init(named: "asset_exporting")
|
||||||
// imageView.layer.cornerRadius = KHZSize(40)
|
// imageView.layer.cornerRadius = KHZSize(40)
|
||||||
// imageView.clipsToBounds = true
|
// imageView.clipsToBounds = true
|
||||||
// imageView.layer.borderWidth = KHZSize(2)
|
// imageView.layer.borderWidth = KHZSize(2)
|
||||||
@ -48,7 +48,7 @@ class CCTransformProgressPopView: UIView {
|
|||||||
label.backgroundColor = UIColor.clear
|
label.backgroundColor = UIColor.clear
|
||||||
label.font = KFont_Medium(18)
|
label.font = KFont_Medium(18)
|
||||||
label.textColor = KTextColor_White
|
label.textColor = KTextColor_White
|
||||||
label.text = "10%"
|
label.text = "0%"
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -99,9 +99,9 @@ class CCTransformProgressPopView: UIView {
|
|||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
|
|
||||||
progressView.progress = 0.5 //默认进度50%
|
progressView.progress = 0.0 //默认进度50%
|
||||||
|
|
||||||
self.backgroundColor = .clear
|
self.backgroundColor = KColorFromRGB(rgbValue: 0x000000, alpha: 0.9)
|
||||||
|
|
||||||
//加载
|
//加载
|
||||||
self.addSubview(iconImageView)
|
self.addSubview(iconImageView)
|
||||||
@ -116,7 +116,7 @@ class CCTransformProgressPopView: UIView {
|
|||||||
//布局
|
//布局
|
||||||
iconImageView.snp.makeConstraints { (make) in
|
iconImageView.snp.makeConstraints { (make) in
|
||||||
make.centerX.equalTo(self.snp.centerX)
|
make.centerX.equalTo(self.snp.centerX)
|
||||||
make.centerY.equalTo(self.snp.centerY)
|
make.centerY.equalTo(self.snp.centerY).offset(KVZSize(-60))
|
||||||
make.width.equalTo(KHZSize(232))
|
make.width.equalTo(KHZSize(232))
|
||||||
make.height.equalTo(KHZSize(176))
|
make.height.equalTo(KHZSize(176))
|
||||||
}
|
}
|
||||||
@ -158,23 +158,43 @@ class CCTransformProgressPopView: UIView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resetUI() {
|
||||||
func updateProgress(value:CGFloat) {
|
titleLabel.text = "导出中..."
|
||||||
if value > 0.9 {
|
detailLabel.text = "请不要锁屏或者退出APP"
|
||||||
titleLabel.text = "导出成功"
|
progressLabel.text = "0%"
|
||||||
detailLabel.text = "导出内容以存储到相册中"
|
transformButton.isHidden = true
|
||||||
progressLabel.text = "100%"
|
closeButton.isHidden = true
|
||||||
|
progressView.progress = Float(0)
|
||||||
|
progressView.isHidden = false
|
||||||
|
progressLabel.isHidden = false
|
||||||
|
}
|
||||||
|
func updateProgress(value:Float) {
|
||||||
|
|
||||||
|
if value > 0.98 {
|
||||||
|
titleLabel.text = "转码完成"
|
||||||
|
detailLabel.text = "正在导出内容至相册中"//"导出内容已存储到相册中"
|
||||||
|
progressLabel.isHidden = true
|
||||||
transformButton.setTitle("继续转码", for: .normal)
|
transformButton.setTitle("继续转码", for: .normal)
|
||||||
}else{
|
transformButton.isHidden = false
|
||||||
titleLabel.text = "导出中..."
|
closeButton.isHidden = false
|
||||||
detailLabel.text = "请不要锁屏或者退出APP"
|
progressView.isHidden = true
|
||||||
progressLabel.text = "10%"
|
iconImageView.image = UIImage.init(named: "asset_exported")
|
||||||
transformButton.setTitle("转码导出", for: .normal)
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
titleLabel.text = "转码中..."
|
||||||
|
detailLabel.text = "请不要锁屏或者退出APP"
|
||||||
|
progressLabel.text = String.init(format: "%.f%%", value*100)
|
||||||
|
transformButton.isHidden = true
|
||||||
|
closeButton.isHidden = true
|
||||||
|
progressView.progress = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateInfo(title:String,desc:String) {
|
||||||
|
titleLabel.text = title
|
||||||
|
detailLabel.text = desc
|
||||||
|
}
|
||||||
|
|
||||||
@objc func transformButtonAction(_ btn:UIButton) {
|
@objc func transformButtonAction(_ btn:UIButton) {
|
||||||
|
|
||||||
print("点击了确认")
|
print("点击了确认")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user