|
@@ -433,8 +433,24 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
saveVideoTipsLabel.textAlignment = .center
|
|
|
saveVideoTipsLabel.font = UIFont.boldSystemFont(ofSize: 17)
|
|
|
saveVideoTipsLabel.text = "视频保存中..."
|
|
|
+ saveVideoTipsLabel.sizeToFit()
|
|
|
return saveVideoTipsLabel
|
|
|
}()
|
|
|
+
|
|
|
+ // 保存重试
|
|
|
+ lazy var saveRetryBtn: UIButton = {
|
|
|
+ let finishedBtn = UIButton(type: .custom)
|
|
|
+ finishedBtn.setTitle("重试", for: .normal)
|
|
|
+ finishedBtn.setTitleColor(UIColor.white, for: .normal)
|
|
|
+ finishedBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
|
|
|
+ finishedBtn.backgroundColor = UIColor.green
|
|
|
+ finishedBtn.tag = 97
|
|
|
+ finishedBtn.isHidden = true
|
|
|
+ finishedBtn.addCorner(corner: 5)
|
|
|
+ finishedBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
|
|
|
+ return finishedBtn
|
|
|
+
|
|
|
+ }()
|
|
|
|
|
|
override func backBtnClick() {
|
|
|
if isExportSuccess {
|
|
@@ -510,7 +526,18 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
|
|
|
view.addSubview(saveVideoTipsBgView)
|
|
|
saveVideoTipsBgView.addSubview(saveVideoTipsLabel)
|
|
|
-
|
|
|
+ saveVideoTipsBgView.addSubview(saveRetryBtn)
|
|
|
+ saveVideoTipsLabel.snp.makeConstraints { make in
|
|
|
+ make.top.height.equalToSuperview()
|
|
|
+ make.centerX.equalToSuperview()
|
|
|
+ }
|
|
|
+ saveRetryBtn.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(saveVideoTipsLabel.snp.right).offset(10)
|
|
|
+ make.top.equalTo(6)
|
|
|
+ make.bottom.equalTo(-6)
|
|
|
+ make.width.equalTo(50)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
coverImageTitle.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(settingCoverImage)))
|
|
|
coverImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(settingCoverImage)))
|
|
@@ -651,7 +678,7 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
}
|
|
|
|
|
|
deinit {
|
|
|
- BFLog(message: "发布界面析构 1")
|
|
|
+ BFLog(1, message: "发布界面析构release")
|
|
|
view.endEditing(true)
|
|
|
PQNotification.removeObserver(self)
|
|
|
// 取消导出
|
|
@@ -919,9 +946,11 @@ extension PQStuckPointPublicController {
|
|
|
if(saveMovieLocalURL == nil){
|
|
|
BFLog(message: "保存相册的视频导出地址无效!!!")
|
|
|
saveVideoTipsLabel.text = "视频已经保存失败"
|
|
|
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.8) { [weak self] in
|
|
|
- self?.saveVideoTipsBgView.isHidden = true
|
|
|
- }
|
|
|
+ saveRetryBtn.isHidden = false
|
|
|
+ saveVideoTipsBgView.isHidden = false
|
|
|
+// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.8) { [weak self] in
|
|
|
+// self?.saveVideoTipsBgView.isHidden = true
|
|
|
+// }
|
|
|
return
|
|
|
}
|
|
|
let authStatus = PHPhotoLibrary.authorizationStatus()
|
|
@@ -934,15 +963,17 @@ extension PQStuckPointPublicController {
|
|
|
if self?.view != nil {
|
|
|
if isFinished {
|
|
|
self?.saveVideoTipsLabel.text = "视频已经保存到相册"
|
|
|
+ self?.saveRetryBtn.isHidden = true
|
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.8) { [weak self] in
|
|
|
self?.saveVideoTipsBgView.isHidden = true
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
self?.saveVideoTipsLabel.text = "视频已经保存失败"
|
|
|
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.8) { [weak self] in
|
|
|
- self?.saveVideoTipsBgView.isHidden = true
|
|
|
- }
|
|
|
+ self?.saveRetryBtn.isHidden = false
|
|
|
+// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.8) { [weak self] in
|
|
|
+// self?.saveVideoTipsBgView.isHidden = true
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|
|
@@ -1083,7 +1114,7 @@ extension PQStuckPointPublicController {
|
|
|
DispatchQueue.global().async {
|
|
|
PQBaseViewModel.getStsToken { [weak self] response, _ in
|
|
|
if response == nil {
|
|
|
- self?.showUploadRemindView(isNetCollected: false, msg: "获取数据失败了哦~")
|
|
|
+ self?.showUploadRemindView(isNetCollected: false, msg: "token获取数据失败了哦~")
|
|
|
return
|
|
|
}
|
|
|
// 更新进度
|
|
@@ -1382,7 +1413,10 @@ extension PQStuckPointPublicController {
|
|
|
navigationController?.viewControllers = [(navigationController?.viewControllers.first)!]
|
|
|
// 发送通知
|
|
|
postNotification(name: cFinishedPublishedNotiKey)
|
|
|
-
|
|
|
+ case 97:
|
|
|
+ saveRetryBtn.isHidden = true
|
|
|
+ saveVideoTipsLabel.text = "视频保存中..."
|
|
|
+ self.saveStuckPointVideo()
|
|
|
default:
|
|
|
break
|
|
|
}
|
|
@@ -1392,14 +1426,44 @@ extension PQStuckPointPublicController {
|
|
|
/// - Parameters:
|
|
|
/// - isNetCollected: <#isNetCollected description#>
|
|
|
/// - msg: <#msg description#>
|
|
|
- func showUploadRemindView(isNetCollected _: Bool = true, msg _: String? = nil) {
|
|
|
+ func showUploadRemindView(isNetCollected _: Bool = true, msg: String? = nil) {
|
|
|
view.endEditing(true)
|
|
|
-// PQUploadRemindView.showUploadRemindView(title: isNetCollected ? "上传中断" : "上传失败", summary: (isNetCollected ? "似乎已断开与互联网的连接" : (msg != nil ? msg : "视频文件已丢失"))!, confirmTitle: isNetCollected ? "重新连接网络" : "重新上传") { [weak self] _, _ in
|
|
|
-// if isNetCollected {
|
|
|
-// openAppSetting()
|
|
|
-// } else {
|
|
|
-// self?.navigationController?.popToViewController((self?.navigationController?.viewControllers[1])!, animated: true)
|
|
|
-// }
|
|
|
+
|
|
|
+ let emptyData = PQEmptyModel()
|
|
|
+ emptyData.isRefreshHidden = false
|
|
|
+ emptyData.title = "上传失败"
|
|
|
+ emptyData.titleColor = UIColor.hexColor(hexadecimal: "#353535")
|
|
|
+ emptyData.summary = "建议切换 WIFI/移动网络后再重试"
|
|
|
+ emptyData.summaryColor = UIColor.hexColor(hexadecimal: "#353535")
|
|
|
+ emptyData.refreshBgColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
|
|
|
+ emptyData.refreshTitle = NSMutableAttributedString(string: "立即重试", attributes: [.foregroundColor:UIColor.white])
|
|
|
+ emptyData.emptySoureImage = UIImage.moduleImage(named: "stuckPoint_video_empty", moduleName: "BFMaterialKit",isAssets: false)
|
|
|
+ emptyData.netDisRefreshBgColor = UIColor.hexColor(hexadecimal: "#FA6400")
|
|
|
+ emptyData.netDisTitle = "内容加载失败"
|
|
|
+ emptyData.netDisTitleColor = UIColor.hexColor(hexadecimal: "#333333")
|
|
|
+ emptyData.netemptyDisImage = UIImage.moduleImage(named: "empty_netDis_icon", moduleName: "BFMaterialKit",isAssets: false)
|
|
|
+ emptyData.netDisRefreshTitle = NSMutableAttributedString(string: "重新加载", attributes: [.font: UIFont.systemFont(ofSize: 16, weight: .medium), .foregroundColor: UIColor.white])
|
|
|
+
|
|
|
+ let emptyRemindView = PQEmptyRemindView(frame: CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: view.frame.width, height: view.frame.height - cDevice_iPhoneNavBarAndStatusBarHei))
|
|
|
+// emptyRemindView.isHidden = true
|
|
|
+ emptyRemindView.emptyData = emptyData
|
|
|
+ emptyRemindView.backgroundColor = PQBFConfig.shared.styleBackGroundColor
|
|
|
+ emptyRemindView.fullRefreshBloc = {[weak self] _, _ in
|
|
|
+ if emptyRemindView.refreshBtn.currentAttributedTitle?.string == "立即重试" {
|
|
|
+ emptyRemindView.isHidden = true
|
|
|
+ // 重试逻辑
|
|
|
+ if let message = msg{
|
|
|
+ if message.contains("token") {
|
|
|
+ self?.uploadVideo()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ emptyRemindView.refreshBtn.addCorner(corner: 4)
|
|
|
+ view.addSubview(emptyRemindView)
|
|
|
+
|
|
|
+// PQRemindView.showUploadRemindView(title: "上传失败", summary: (msg != nil ? msg! : "视频文件已丢失"), confirmTitle: "立即重试") { [weak self] _, _ in
|
|
|
+// self?.navigationController?.popToViewController((self?.navigationController?.viewControllers[1])!, animated: true)
|
|
|
// }
|
|
|
}
|
|
|
|
|
@@ -1705,125 +1769,127 @@ extension PQStuckPointPublicController {
|
|
|
BFLog(message: "头像的网络地址\(BFLoginUserInfo.shared.avatarUrl)")
|
|
|
let avatarFilePath = NSHomeDirectory().appending("/Documents/").appending("user_avatar.jpg")
|
|
|
|
|
|
- ImageDownloader.default.downloadImage(with: URL(string: BFLoginUserInfo.shared.avatarUrl)!, options: nil) { result in
|
|
|
+ // warning:给默认头像吧
|
|
|
+ ImageDownloader.default.downloadImage(with: URL(string: BFLoginUserInfo.shared.avatarUrl)!, options: nil) {[weak self] result in
|
|
|
+ var image : UIImage?
|
|
|
switch result {
|
|
|
case let .success(imageResult):
|
|
|
- let image = UIImage.nx_circleImage(imageResult.image)
|
|
|
- if(image == nil){
|
|
|
- BFLog(message: "image date is error!!")
|
|
|
- return
|
|
|
- }
|
|
|
- UIImage.saveImage(currentImage: image!, outFilePath: avatarFilePath)
|
|
|
+ image = UIImage.nx_circleImage(imageResult.image)
|
|
|
|
|
|
- //1,背景视频素材
|
|
|
- let bgMovieInfo:PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel.init()
|
|
|
- bgMovieInfo.type = StickerType.VIDEO.rawValue
|
|
|
- bgMovieInfo.locationPath = moveResPath ?? ""
|
|
|
- bgMovieInfo.timelineIn = 0
|
|
|
- bgMovieInfo.timelineOut = CMTimeGetSeconds(movieAsset.duration)
|
|
|
- bgMovieInfo.model_in = bgMovieInfo.timelineIn
|
|
|
- bgMovieInfo.out = bgMovieInfo.timelineOut
|
|
|
- bgMovieInfo.canvasFillType = stickerContentMode.aspectFitStr.rawValue
|
|
|
- //2,用户头像素材
|
|
|
- BFLog(message: "头像的沙盒地址:\(avatarFilePath)")
|
|
|
- let avatarSticker:PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel.init()
|
|
|
- avatarSticker.locationPath = avatarFilePath.replacingOccurrences(of: documensDirectory, with: "")
|
|
|
- avatarSticker.timelineIn = bgMovieInfo.timelineIn
|
|
|
- avatarSticker.timelineOut = bgMovieInfo.timelineOut
|
|
|
- avatarSticker.canvasFillType = stickerContentMode.aspectFitStr.rawValue
|
|
|
-
|
|
|
- //头像绘制大小\位置
|
|
|
- var avatarSize:Float = 0.0
|
|
|
- var avatarTop:Float = 0.0
|
|
|
- if((self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) > (self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0)){
|
|
|
- //竖屏
|
|
|
- avatarSize = Float(self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) * 360.0 / 1080.0
|
|
|
- avatarTop = 430
|
|
|
- }else{
|
|
|
- //横屏屏
|
|
|
- avatarSize = Float(self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 300.0 / 1080.0
|
|
|
- avatarTop = Float(self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 130.0 / 1080.0
|
|
|
- }
|
|
|
+ case let .failure(error):
|
|
|
+ image = UIImage.moduleImage(named: "user_avatar_normal", moduleName: "BFFramework", isAssets:false)
|
|
|
+ BFLog(message: "下载头像图片失败:\(error.localizedDescription)")
|
|
|
+ }
|
|
|
+ if(image == nil){
|
|
|
+ BFLog(message: "image date is error!!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ UIImage.saveImage(currentImage: image!, outFilePath: avatarFilePath)
|
|
|
+
|
|
|
+ //1,背景视频素材
|
|
|
+ let bgMovieInfo:PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel.init()
|
|
|
+ bgMovieInfo.type = StickerType.VIDEO.rawValue
|
|
|
+ bgMovieInfo.locationPath = moveResPath ?? ""
|
|
|
+ bgMovieInfo.timelineIn = 0
|
|
|
+ bgMovieInfo.timelineOut = CMTimeGetSeconds(movieAsset.duration)
|
|
|
+ bgMovieInfo.model_in = bgMovieInfo.timelineIn
|
|
|
+ bgMovieInfo.out = bgMovieInfo.timelineOut
|
|
|
+ bgMovieInfo.canvasFillType = stickerContentMode.aspectFitStr.rawValue
|
|
|
+ //2,用户头像素材
|
|
|
+ BFLog(message: "头像的沙盒地址:\(avatarFilePath)")
|
|
|
+ let avatarSticker:PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel.init()
|
|
|
+ avatarSticker.locationPath = avatarFilePath.replacingOccurrences(of: documensDirectory, with: "")
|
|
|
+ avatarSticker.timelineIn = bgMovieInfo.timelineIn
|
|
|
+ avatarSticker.timelineOut = bgMovieInfo.timelineOut
|
|
|
+ avatarSticker.canvasFillType = stickerContentMode.aspectFitStr.rawValue
|
|
|
+
|
|
|
+ //头像绘制大小\位置
|
|
|
+ var avatarSize:Float = 0.0
|
|
|
+ var avatarTop:Float = 0.0
|
|
|
+ if((self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) > (self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0)){
|
|
|
+ //竖屏
|
|
|
+ avatarSize = Float(self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) * 360.0 / 1080.0
|
|
|
+ avatarTop = 430
|
|
|
+ }else{
|
|
|
+ //横屏屏
|
|
|
+ avatarSize = Float(self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 300.0 / 1080.0
|
|
|
+ avatarTop = Float(self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 130.0 / 1080.0
|
|
|
+ }
|
|
|
+
|
|
|
+ let avatarPostion:PQEditMaterialPositionModel = PQEditMaterialPositionModel.init()
|
|
|
+ avatarPostion.width = Int(avatarSize)
|
|
|
+ avatarPostion.height = Int(avatarSize)
|
|
|
+ avatarPostion.x = ((self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) - Int(avatarSize)) / 2
|
|
|
+ avatarPostion.y = Int(avatarTop)
|
|
|
+ avatarSticker.materialPosition = avatarPostion
|
|
|
+
|
|
|
+ //3,用户名素材
|
|
|
+ let userNameSticker:PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel.init()
|
|
|
+ userNameSticker.timelineIn = bgMovieInfo.timelineIn
|
|
|
+ userNameSticker.timelineOut = bgMovieInfo.timelineOut
|
|
|
+ userNameSticker.type = StickerType.SUBTITLE.rawValue
|
|
|
+
|
|
|
|
|
|
- let avatarPostion:PQEditMaterialPositionModel = PQEditMaterialPositionModel.init()
|
|
|
- avatarPostion.width = Int(avatarSize)
|
|
|
- avatarPostion.height = Int(avatarSize)
|
|
|
- avatarPostion.x = ((self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) - Int(avatarSize)) / 2
|
|
|
- avatarPostion.y = Int(avatarTop)
|
|
|
- avatarSticker.materialPosition = avatarPostion
|
|
|
-
|
|
|
- //3,用户名素材
|
|
|
- let userNameSticker:PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel.init()
|
|
|
- userNameSticker.timelineIn = bgMovieInfo.timelineIn
|
|
|
- userNameSticker.timelineOut = bgMovieInfo.timelineOut
|
|
|
- userNameSticker.type = StickerType.SUBTITLE.rawValue
|
|
|
-
|
|
|
-
|
|
|
- //用户名绘制用到的参数
|
|
|
- var userNameTop:Float = 0.0
|
|
|
- var userNameFontSize:Float = 0.0
|
|
|
- if((self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) > (self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0)){
|
|
|
- //竖屏
|
|
|
- userNameTop = 870
|
|
|
- userNameFontSize = Float(self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) * 100.0 / 1080.0
|
|
|
- }else{
|
|
|
- //横屏
|
|
|
- userNameTop = Float(self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 480 / 1080.0
|
|
|
- userNameFontSize = Float(self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 70.0 / 1080.0
|
|
|
- }
|
|
|
-
|
|
|
- let subtitleInfo:PQEditSubtitleInfoModel = PQEditSubtitleInfoModel.init()
|
|
|
- subtitleInfo.fontSize = Int(userNameFontSize)
|
|
|
- subtitleInfo.text = BFLoginUserInfo.shared.nickName
|
|
|
- userNameSticker.subtitleInfo = subtitleInfo
|
|
|
-
|
|
|
- let userNamePostion:PQEditMaterialPositionModel = PQEditMaterialPositionModel.init()
|
|
|
- userNamePostion.width = Int(userNameFontSize ) * 10
|
|
|
- userNamePostion.height = Int(userNameFontSize ) * 3
|
|
|
- userNamePostion.x = ((self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) - userNamePostion.width) / 2
|
|
|
- userNamePostion.y = Int(userNameTop)
|
|
|
- userNameSticker.materialPosition = userNamePostion
|
|
|
-
|
|
|
- //4,音频
|
|
|
- let soundResPath = currentBundlePath()!.path(forResource: "endMovieSound", ofType: "mp3")
|
|
|
- let soundAsset = AVURLAsset(url: URL(fileURLWithPath: soundResPath ?? ""), options: nil)
|
|
|
- self.endMovieExporter = PQCompositionExporter(asset: soundAsset, videoComposition: nil, audioMix: nil, filters: nil, stickers: [bgMovieInfo,avatarSticker,userNameSticker], animationTool: nil, exportURL: outPutMP4URL)
|
|
|
- self.endMovieExporter.isEndMovie = true
|
|
|
- if self.endMovieExporter.prepare(videoSize: CGSize(width: self.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: self.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0), videoAverageBitRate: orgeBitRate) {
|
|
|
-
|
|
|
- self.endMovieExporter.start(playeTimeRange: CMTimeRange.init(start: CMTime.zero, duration: CMTimeMakeWithSeconds(Float64(bgMovieInfo.out), preferredTimescale: BASE_FILTER_TIMESCALE)))
|
|
|
- BFLog(message: "开始导出")
|
|
|
+ //用户名绘制用到的参数
|
|
|
+ var userNameTop:Float = 0.0
|
|
|
+ var userNameFontSize:Float = 0.0
|
|
|
+ if((self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) > (self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0)){
|
|
|
+ //竖屏
|
|
|
+ userNameTop = 870
|
|
|
+ userNameFontSize = Float(self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) * 100.0 / 1080.0
|
|
|
+ }else{
|
|
|
+ //横屏
|
|
|
+ userNameTop = Float(self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 480 / 1080.0
|
|
|
+ userNameFontSize = Float(self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 70.0 / 1080.0
|
|
|
+ }
|
|
|
+
|
|
|
+ let subtitleInfo:PQEditSubtitleInfoModel = PQEditSubtitleInfoModel.init()
|
|
|
+ subtitleInfo.fontSize = Int(userNameFontSize)
|
|
|
+ subtitleInfo.text = BFLoginUserInfo.shared.nickName
|
|
|
+ userNameSticker.subtitleInfo = subtitleInfo
|
|
|
+
|
|
|
+ let userNamePostion:PQEditMaterialPositionModel = PQEditMaterialPositionModel.init()
|
|
|
+ userNamePostion.width = Int(userNameFontSize ) * 10
|
|
|
+ userNamePostion.height = Int(userNameFontSize ) * 3
|
|
|
+ userNamePostion.x = ((self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) - userNamePostion.width) / 2
|
|
|
+ userNamePostion.y = Int(userNameTop)
|
|
|
+ userNameSticker.materialPosition = userNamePostion
|
|
|
+
|
|
|
+ //4,音频
|
|
|
+ let soundResPath = currentBundlePath()!.path(forResource: "endMovieSound", ofType: "mp3")
|
|
|
+ let soundAsset = AVURLAsset(url: URL(fileURLWithPath: soundResPath ?? ""), options: nil)
|
|
|
+ self?.endMovieExporter = PQCompositionExporter(asset: soundAsset, videoComposition: nil, audioMix: nil, filters: nil, stickers: [bgMovieInfo,avatarSticker,userNameSticker], animationTool: nil, exportURL: outPutMP4URL)
|
|
|
+ self?.endMovieExporter.isEndMovie = true
|
|
|
+ if ((self?.endMovieExporter.prepare(videoSize: CGSize(width: self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0), videoAverageBitRate: orgeBitRate)) != nil) {
|
|
|
+
|
|
|
+ self?.endMovieExporter.start(playeTimeRange: CMTimeRange.init(start: CMTime.zero, duration: CMTimeMakeWithSeconds(Float64(bgMovieInfo.out), preferredTimescale: BASE_FILTER_TIMESCALE)))
|
|
|
+ BFLog(message: "开始导出")
|
|
|
+ }
|
|
|
+ self?.endMovieExporter.progressClosure = { _, _, progress in
|
|
|
+ BFLog(message: "片尾合成进度 \(progress) ")
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ self?.endMovieExporter.completion = { [weak self] url in
|
|
|
+ BFLog(message: "片尾的视频导出完成: \(String(describing: url)) 生成视频时长为:\(CMTimeGetSeconds(AVAsset(url: url ?? URL(string: "https://media.w3.org/2010/05/sintel/trailer.mp4")!).duration))")
|
|
|
+
|
|
|
+ // 导出完成后取消导出
|
|
|
+ if self?.endMovieExporter != nil {
|
|
|
+ self?.endMovieExporter.cancel()
|
|
|
}
|
|
|
- self.endMovieExporter.progressClosure = { _, _, progress in
|
|
|
- BFLog(message: "片尾合成进度 \(progress) ")
|
|
|
-
|
|
|
+ self?.endMovieLocalURL = url
|
|
|
+ //拼接水印正片和片尾
|
|
|
+ if(self?.watermarkMovieLocalURL != nil && self?.endMovieLocalURL != nil){
|
|
|
+ let videoMerge:NXVideoMerge = NXVideoMerge.init()
|
|
|
+ videoMerge.mergeAndExportVideos(withFileURLs: [self!.watermarkMovieLocalURL!,self!.endMovieLocalURL!], renderSize:CGSize(width: self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0)) { isSuccess, outFileURL in
|
|
|
+ if(isSuccess){
|
|
|
+ BFLog(message: "合并视频成功 outFilePath is \(outFileURL ?? "")")
|
|
|
+ self?.saveMovieLocalURL = outFileURL as? URL
|
|
|
+ //保存到相册 fp2-1-1 - 请求权限
|
|
|
+ self?.authorizationStatus()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- self.endMovieExporter.completion = { [weak self] url in
|
|
|
- BFLog(message: "片尾的视频导出完成: \(String(describing: url)) 生成视频时长为:\(CMTimeGetSeconds(AVAsset(url: url ?? URL(string: "https://media.w3.org/2010/05/sintel/trailer.mp4")!).duration))")
|
|
|
-
|
|
|
- // 导出完成后取消导出
|
|
|
- if self?.endMovieExporter != nil {
|
|
|
- self?.endMovieExporter.cancel()
|
|
|
- }
|
|
|
- self?.endMovieLocalURL = url
|
|
|
- //拼接水印正片和片尾
|
|
|
- if(self?.watermarkMovieLocalURL != nil && self?.endMovieLocalURL != nil){
|
|
|
- let videoMerge:NXVideoMerge = NXVideoMerge.init()
|
|
|
- videoMerge.mergeAndExportVideos(withFileURLs: [self!.watermarkMovieLocalURL!,self!.endMovieLocalURL!], renderSize:CGSize(width: self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0)) { isSuccess, outFileURL in
|
|
|
- if(isSuccess){
|
|
|
- BFLog(message: "合并视频成功 outFilePath is \(outFileURL ?? "")")
|
|
|
- self?.saveMovieLocalURL = outFileURL as? URL
|
|
|
- //保存到相册 fp2-1-1 - 请求权限
|
|
|
- self?.authorizationStatus()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- case let .failure(error):
|
|
|
- BFLog(message: "下载头像图片失败:\(error.localizedDescription)")
|
|
|
}
|
|
|
}
|
|
|
|