|
@@ -47,8 +47,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
// 导出进度
|
|
|
private var exportProgrss = 0
|
|
|
var mStickers: [PQEditVisionTrackMaterialsModel]?
|
|
|
-
|
|
|
- var remindView:PQRemindView?
|
|
|
+
|
|
|
+ var remindView: PQRemindView?
|
|
|
// 预览大小
|
|
|
private var preViewSize: CGSize {
|
|
|
switch aspectRatio {
|
|
@@ -351,6 +351,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
}
|
|
|
// 开始导出
|
|
|
beginExport()
|
|
|
+ /// 保存草稿
|
|
|
+ saveDraftbox()
|
|
|
// 曝光上报:窗口曝光
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_publishSyncedUp, pageSource: .sp_stuck_publishSyncedUp, extParams: nil, remindmsg: "卡点视频数据上报-(曝光上报:窗口曝光)")
|
|
|
}
|
|
@@ -423,23 +425,22 @@ extension PQStuckPointPublicController {
|
|
|
let inputAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + (audioMixModel?.localPath ?? "")), options: nil)
|
|
|
// 每次初始化的时候设置初始值 为 nIl
|
|
|
exporter = PQCompositionExporter(asset: inputAsset, videoComposition: nil, audioMix: nil, filters: nil, stickers: mStickers, animationTool: nil, exportURL: outPutMP4URL)
|
|
|
-
|
|
|
+
|
|
|
var orgeBitRate = (editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) * (editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 3
|
|
|
-
|
|
|
- for stick in mStickers!{
|
|
|
- if(stick.type == StickerType.VIDEO.rawValue){
|
|
|
- let asset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + stick.locationPath), options: avAssertOptions)
|
|
|
-
|
|
|
+
|
|
|
+ for stick in mStickers! {
|
|
|
+ if stick.type == StickerType.VIDEO.rawValue {
|
|
|
+ let asset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + stick.locationPath), options: avAssertOptions)
|
|
|
+
|
|
|
let cbr = asset.tracks(withMediaType: .video).first?.estimatedDataRate
|
|
|
- if(Int(cbr ?? 0) > orgeBitRate){
|
|
|
+ if Int(cbr ?? 0) > orgeBitRate {
|
|
|
orgeBitRate = Int(cbr ?? 0)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
BFLog(message: "导出设置的码率为:\(orgeBitRate)")
|
|
|
exporter.showGaussianBlur = true
|
|
|
- if exporter.prepare(videoSize: CGSize(width: editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0),videoAverageBitRate: orgeBitRate) {
|
|
|
+ if exporter.prepare(videoSize: CGSize(width: editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0), videoAverageBitRate: orgeBitRate) {
|
|
|
let playeTimeRange: CMTimeRange = CMTimeRange(start: CMTime(value: CMTimeValue(Int((audioMixModel?.startTime ?? 0) * 600)), timescale: 600), end: CMTime(value: CMTimeValue(Int((audioMixModel?.endTime ?? 0) * 600)), timescale: 600))
|
|
|
BFLog(message: "开始导出 \(String(describing: audioMixModel?.startTime)) 结束 \(String(describing: audioMixModel?.endTime))")
|
|
|
exporter.start(playeTimeRange: playeTimeRange)
|
|
@@ -449,14 +450,8 @@ extension PQStuckPointPublicController {
|
|
|
BFLog(message: "合成进度 \(progress)")
|
|
|
let useProgress = progress > 1 ? 1 : progress
|
|
|
if progress > 0, Int(useProgress * 100) > (self?.exportProgrss ?? 0) {
|
|
|
- self?.exportProgrss = Int(useProgress * 100)
|
|
|
- if (self?.exportProgrss ?? 0) >= 100 {
|
|
|
- self?.exportProgrss = 99
|
|
|
- }
|
|
|
- self?.progressView.setProgress(useProgress, animated: true)
|
|
|
- let attributedText = NSMutableAttributedString(string: "\(self?.exportProgrss ?? 0)%\n视频正在处理中,请勿离开")
|
|
|
- attributedText.addAttributes([.font: UIFont.systemFont(ofSize: 34)], range: NSRange(location: 0, length: "\(self?.exportProgrss ?? 0)%".count))
|
|
|
- self?.progressTipsLab.attributedText = attributedText
|
|
|
+ // 更新进度
|
|
|
+ self?.updatePublicCurrentProgress(useProgress: useProgress * 0.88)
|
|
|
}
|
|
|
}
|
|
|
exporter.completion = { [weak self] url in
|
|
@@ -474,7 +469,9 @@ extension PQStuckPointPublicController {
|
|
|
/// fp2-1-1 - 请求权限
|
|
|
// self?.authorizationStatus()
|
|
|
/// fp2-2 - 保存草稿
|
|
|
- self?.saveDraftbox()
|
|
|
+// self?.saveDraftbox()
|
|
|
+ /// fp2 - 处理视频数据
|
|
|
+ self?.dealWithVideoData()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -543,7 +540,7 @@ extension PQStuckPointPublicController {
|
|
|
self?.saveProject()
|
|
|
} else {
|
|
|
// 保存草稿失败-播放视频
|
|
|
- self?.publicEnd(isError: true)
|
|
|
+// self?.publicEnd(isError: true)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -557,7 +554,7 @@ extension PQStuckPointPublicController {
|
|
|
/// fp3 - 保存项目
|
|
|
/// - Returns: description
|
|
|
func saveProject() {
|
|
|
- if isSaveDraftSuccess, isExportSuccess, exportLocalURL != nil {
|
|
|
+ if isSaveDraftSuccess {
|
|
|
let sdata = editProjectModel?.sData?.toJSONString(prettyPrint: false) ?? ""
|
|
|
let draftboxId: String? = editProjectModel?.draftboxId
|
|
|
PQBaseViewModel.saveProject(draftboxId: draftboxId, sdata: sdata, videoFromScene: .stuckPoint) { [weak self] projectId, msg in
|
|
@@ -572,18 +569,18 @@ extension PQStuckPointPublicController {
|
|
|
self?.editProjectModel?.projectId = projectId ?? ""
|
|
|
}
|
|
|
/// fp4 - 处理视频数据
|
|
|
- self?.dealWithVideoData()
|
|
|
+// self?.dealWithVideoData()
|
|
|
}
|
|
|
} else {
|
|
|
self?.editProjectModel?.projectId = projectId ?? ""
|
|
|
/// fp4 - 处理视频数据
|
|
|
- self?.dealWithVideoData()
|
|
|
+// self?.dealWithVideoData()
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
self?.editProjectModel?.projectId = projectId ?? ""
|
|
|
/// fp4 - 处理视频数据
|
|
|
- self?.dealWithVideoData()
|
|
|
+// self?.dealWithVideoData()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -648,12 +645,16 @@ extension PQStuckPointPublicController {
|
|
|
if uploadRequest != nil, "\(uploadRequest?.callbackParam["code"] ?? "0")" == "1" {
|
|
|
return
|
|
|
}
|
|
|
+ // 更新进度
|
|
|
+ updatePublicCurrentProgress(useProgress: 0.89)
|
|
|
DispatchQueue.global().async {
|
|
|
PQBaseViewModel.getStsToken { [weak self] response, _ in
|
|
|
if response == nil {
|
|
|
self?.showUploadRemindView(isNetCollected: false, msg: "获取数据失败了哦~")
|
|
|
return
|
|
|
}
|
|
|
+ // 更新进度
|
|
|
+ self?.updatePublicCurrentProgress(useProgress: 0.90)
|
|
|
BFLog(message: "取我方服务器STS 返回数据 \(String(describing: response))")
|
|
|
self?.multipartUpload(response: response)
|
|
|
}
|
|
@@ -693,6 +694,15 @@ extension PQStuckPointPublicController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ PQAliOssUtil.shared.aliOssProgressHander = { [weak self] bytesSent, totalBytesSent, totalBytesExpectedToSend, _, _ in
|
|
|
+ let progress: Float = 0.90 + Float(Float(totalBytesSent) / Float(totalBytesExpectedToSend)) * 0.09
|
|
|
+ BFLog(message: "卡点视频上传:bytesSent = \(bytesSent),totalBytesSent = \(totalBytesSent),totalBytesExpectedToSend = \(totalBytesExpectedToSend),progress = \(progress)")
|
|
|
+ if progress >= 0.90, progress <= 0.99 {
|
|
|
+ // 更新进度
|
|
|
+ self?.updatePublicCurrentProgress(useProgress: progress)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// fp6 - 视频上传成功,处理要发布视频数据
|
|
@@ -782,43 +792,48 @@ extension PQStuckPointPublicController {
|
|
|
videoData.eventTrackData?.endUploadDate = Date().timeIntervalSince1970
|
|
|
}
|
|
|
DispatchQueue.global().async {
|
|
|
- PQBaseViewModel.ossTempToken { [weak self] response, _ in
|
|
|
- let image: UIImage = videoData.uplpadImage ?? UIImage()
|
|
|
- let data = image.jpegData(compressionQuality: 1)
|
|
|
- let accessKeyId: String = "\(response?["accessKeyId"] ?? "")"
|
|
|
- let secretKeyId: String = "\(response?["accessKeySecret"] ?? "")"
|
|
|
- let securityToken: String = "\(response?["securityToken"] ?? "")"
|
|
|
- let endpoint: String = "\(response?["endPoint"] ?? "")"
|
|
|
- let bucketName: String = "\(response?["bucketName"] ?? "")"
|
|
|
- let objectKey: String = "\(response?["objectKey"] ?? "")"
|
|
|
- BFLog(message: "开始上传视频图片==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? ""),objectKey =\(objectKey)")
|
|
|
- PQAliOssUtil.shared
|
|
|
- .startClient(
|
|
|
- accessKeyId: accessKeyId,
|
|
|
- secretKeyId: secretKeyId,
|
|
|
- securityToken: securityToken,
|
|
|
- endpoint: endpoint
|
|
|
- )
|
|
|
- .uploadObjectAsync(bucketName: bucketName, objectKey: objectKey, data: data!, fileExtensions: "png", imageUploadBlock: { _, code, ossObjectKey, _ in
|
|
|
- BFLog(message: "图片上传完成==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? ""),objectKey =\(objectKey),ossObjectKey = \(ossObjectKey)")
|
|
|
- if code == 1 && ossObjectKey == objectKey && objectKey.count > 0 {
|
|
|
- BFLog(message: "开始发布==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? ""),objectKey =\(objectKey),ossObjectKey = \(ossObjectKey)")
|
|
|
- PQUploadViewModel.publishVideo(projectId: videoData.projectId, fileExtensions: videoData.localPath?.pathExtension, title: videoData.title ?? "", videoPath: videoData.uplpadBucketKey ?? "", coverImgPath: objectKey, descr: videoData.summary ?? "", videoFromScene: .stuckPoint, reCreateData: videoData.reCreateVideoData, eventTrackData: videoData.eventTrackData) { [weak self] newVideoData, _, _ in
|
|
|
- postNotification(name: cPublishStuckPointSuccessKey, userInfo: ["newVideoData": newVideoData!])
|
|
|
- BFLog(message: "发布成功==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? ""),objectKey =\(objectKey),ossObjectKey = \(ossObjectKey)")
|
|
|
+// PQBaseViewModel.ossTempToken { [weak self] response, _ in
|
|
|
+// let image: UIImage = videoData.uplpadImage ?? UIImage()
|
|
|
+// let data = image.jpegData(compressionQuality: 1)
|
|
|
+// let accessKeyId: String = "\(response?["accessKeyId"] ?? "")"
|
|
|
+// let secretKeyId: String = "\(response?["accessKeySecret"] ?? "")"
|
|
|
+// let securityToken: String = "\(response?["securityToken"] ?? "")"
|
|
|
+// let endpoint: String = "\(response?["uploadDomain"] ?? "")"
|
|
|
+// let bucketName: String = "\(response?["bucketName"] ?? "")"
|
|
|
+// let objectKey: String = "\(response?["objectKey"] ?? "")"
|
|
|
+// BFLog(message: "开始上传视频图片==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? ""),objectKey =\(objectKey)")
|
|
|
+// PQAliOssUtil.shared
|
|
|
+// .startClient(
|
|
|
+// accessKeyId: accessKeyId,
|
|
|
+// secretKeyId: secretKeyId,
|
|
|
+// securityToken: securityToken,
|
|
|
+// endpoint: endpoint
|
|
|
+// )
|
|
|
+// .uploadObjectAsync(bucketName: bucketName, objectKey: objectKey, data: data!, fileExtensions: "png", imageUploadBlock: { _, code, ossObjectKey, _ in
|
|
|
+// BFLog(message: "图片上传完成==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? ""),objectKey =\(objectKey),ossObjectKey = \(ossObjectKey)")
|
|
|
+// if code == 1 && ossObjectKey == objectKey && objectKey.count > 0 {
|
|
|
+// BFLog(message: "开始发布==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? ""),objectKey =\(objectKey),ossObjectKey = \(ossObjectKey)")
|
|
|
+ PQUploadViewModel.publishVideo(projectId: videoData.projectId, fileExtensions: videoData.localPath?.pathExtension, title: videoData.title ?? "", videoPath: videoData.uplpadBucketKey ?? "", coverImgPath: nil, descr: videoData.summary ?? "", videoFromScene: .stuckPoint, reCreateData: videoData.reCreateVideoData, eventTrackData: videoData.eventTrackData) { [weak self] newVideoData, _, _ in
|
|
|
+ self?.videoData = newVideoData
|
|
|
+ if self?.videoData?.reCreateVideoData == nil {
|
|
|
+ let reCreateVideo = PQReCreateModel()
|
|
|
+ reCreateVideo.reProduceVideoFlag = 1
|
|
|
+ self?.videoData?.reCreateVideoData = reCreateVideo
|
|
|
+ }
|
|
|
+ postNotification(name: cPublishStuckPointSuccessKey, userInfo: ["newVideoData": self?.videoData!])
|
|
|
+ BFLog(message: "发布成功==\(videoData.title ?? ""),uplpadBucketKey = \(videoData.uplpadBucketKey ?? "")")
|
|
|
// cShowHUB(superView: nil, msg: "视频发布成功")
|
|
|
- self?.videoData = newVideoData
|
|
|
- // 发布成功后续操作
|
|
|
- self?.publicEnd()
|
|
|
- PQEventTrackViewModel.publishReportUpload(projectId: videoData.projectId, businessType: .bt_publish_success, ossInfo: videoData.stsToken ?? [:], params: ["title": videoData.title ?? "", "videoPath": videoData.uplpadBucketKey ?? "", "coverImgPath": objectKey, "descr": videoData.summary ?? ""])
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 图片上传失败
|
|
|
- BFLog(message: "图片上传失败重新发布视频==\(videoData.title ?? ""),\(videoData.uplpadBucketKey ?? "")")
|
|
|
- self?.publicVideo(videoData: videoData)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ // 发布成功后续操作
|
|
|
+ self?.publicEnd()
|
|
|
+ PQEventTrackViewModel.publishReportUpload(projectId: videoData.projectId, businessType: .bt_publish_success, ossInfo: videoData.stsToken ?? [:], params: ["title": videoData.title ?? "", "videoPath": videoData.uplpadBucketKey ?? "", "descr": videoData.summary ?? ""])
|
|
|
+ }
|
|
|
+// } else {
|
|
|
+// // 图片上传失败
|
|
|
+// BFLog(message: "图片上传失败重新发布视频==\(videoData.title ?? ""),\(videoData.uplpadBucketKey ?? "")")
|
|
|
+// self?.publicVideo(videoData: videoData)
|
|
|
+// }
|
|
|
+// })
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -992,4 +1007,14 @@ extension PQStuckPointPublicController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// 更新进度
|
|
|
+ /// - Returns: <#description#>
|
|
|
+ func updatePublicCurrentProgress(useProgress: Float) {
|
|
|
+ exportProgrss = Int(useProgress * 100)
|
|
|
+ progressView.setProgress(useProgress, animated: true)
|
|
|
+ let attributedText = NSMutableAttributedString(string: "\(exportProgrss)%\n视频正在处理中,请勿离开")
|
|
|
+ attributedText.addAttributes([.font: UIFont.systemFont(ofSize: 34)], range: NSRange(location: 0, length: "\(exportProgrss)%".count))
|
|
|
+ progressTipsLab.attributedText = attributedText
|
|
|
+ }
|
|
|
}
|