Jelajahi Sumber

Merge branch 'master' of https://git.yishihui.com/iOS/BFFramework

* 'master' of https://git.yishihui.com/iOS/BFFramework:
  1,修改重试 BTN 变量名, 2,添加是否生成水印参数。
  视频析构数据
harry 3 tahun lalu
induk
melakukan
91957989c9

+ 14 - 1
BFFramework/Classes/PQGPUImage/akfilters/PQMovieFilter.swift

@@ -111,6 +111,8 @@ class PQMovieFilter: PQBaseFilter {
     
     // 当前帧 id
     var framebufferIndex:Int = 0
+    
+    var imageVertexBuffer: GLuint = 0
 
     deinit {
         BFLog(1, message: "movie filter release")
@@ -122,6 +124,11 @@ class PQMovieFilter: PQBaseFilter {
         if assetReader != nil {
             assetReader?.cancelReading()
         }
+        
+        if(imageVertexBuffer != 0){
+            PQGPUImageTools.deleteVBO(imageVertexBuffer)
+            imageVertexBuffer = 0
+        }
     }
 
     public init(url: URL) {
@@ -545,11 +552,17 @@ class PQMovieFilter: PQBaseFilter {
 
         let verticesPoint: [GLfloat] = PQGPUImageTools.getVerticesPoint(sticker: moveSticker!, textureSize: (moveAssetRotation() == .rotateLeftTextureCoordinates || moveAssetRotation() == .rotateRightTextureCoordinates) ? CGSize(width: videoSize.height, height: videoSize.width) : videoSize, cannvasSize: inputSize)
 
+        imageVertexBuffer = PQGPUImageTools.NXGenerateVBO(for: verticesPoint)
         renderQuadWithShader(shader,
                              uniformSettings: uniformSettings,
-                             vertexBufferObject: PQGPUImageTools.NXGenerateVBO(for: verticesPoint),
+                             vertexBufferObject: imageVertexBuffer,
                              inputTextures: cropTextureProperties)
         releaseIncomingFramebuffers()
+        
+        if(imageVertexBuffer != 0){
+            PQGPUImageTools.deleteVBO(imageVertexBuffer)
+            imageVertexBuffer = 0
+        }
 
         luminanceFramebuffer.unlock()
         chrominanceFramebuffer.unlock()

+ 31 - 17
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointPublicController.swift

@@ -25,7 +25,8 @@ class PQStuckPointPublicController: PQBaseViewController {
     private var isSaveProjectSuccess: Bool = false // 是否保存项目完成
     private var isUploadSuccess: Bool = false // 是否上传完成
     private var isPublicSuccess: Bool = false // 是否发布完成
-    private var exportLocalURL: URL? // 导出的地址
+    // 导出正片的地址
+    private var exportLocalURL: URL?
     // 再创作数据
     private var reCreateData: PQReCreateModel?
     // 确定上传的数据
@@ -447,16 +448,16 @@ class PQStuckPointPublicController: PQBaseViewController {
     
     // 保存重试
     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.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
-        finishedBtn.tag = 97
-        finishedBtn.isHidden = true
-        finishedBtn.addCorner(corner: 5)
-        finishedBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
-        return finishedBtn
+        let saveRetryBtn = UIButton(type: .custom)
+        saveRetryBtn.setTitle("重试", for: .normal)
+        saveRetryBtn.setTitleColor(UIColor.white, for: .normal)
+        saveRetryBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
+        saveRetryBtn.backgroundColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
+        saveRetryBtn.tag = 97
+        saveRetryBtn.isHidden = true
+        saveRetryBtn.addCorner(corner: 5)
+        saveRetryBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
+        return saveRetryBtn
 
     }()
 
@@ -861,8 +862,11 @@ extension PQStuckPointPublicController {
                 BFLog(message: "拼接后音频时长\(asset.duration.seconds)  url is \(String(describing: completURL)) 用时\(CFAbsoluteTimeGetCurrent() - startMergeTime)")
                 //导出不带水印的正片
                 self?.beginExport(inputAsset: asset)
-                //导出带水印的正片
-                self?.beginExportWatermarkMovie(inputAsset:asset)
+                
+                if(PQBFConfig.shared.enableWatermarkMovie){
+                    //导出带水印的正片
+                    self?.beginExportWatermarkMovie(inputAsset:asset)
+                }
             }else{
                 cShowHUB(superView: self?.view, msg: "合成失败请重试。")
             }
@@ -928,8 +932,15 @@ extension PQStuckPointPublicController {
                 self?.isExportSuccess = true
                 self?.exportEndDate = Date().timeIntervalSince1970
                 BFLog(message: "视频导出完成-开始去发布视频 总时长为\((self?.exportEndDate ?? 0) - (self?.startExportDate ?? 0) * 1000)")
-
+   
                 self?.exportLocalURL = url
+                
+                
+                // add by ak 不生成水印视频时直接自动保存系统相册,e.g. 乐活圈中会执行
+                if(!PQBFConfig.shared.enableWatermarkMovie){
+                    self?.authorizationStatus()
+                }
+       
                 /// fp2-1-1 - 请求权限
 //                self?.authorizationStatus()
                 /// fp2-2 - 保存草稿
@@ -966,7 +977,9 @@ extension PQStuckPointPublicController {
     /// - Returns: <#description#>
     func saveStuckPointVideo() {
         
-        if(saveMovieLocalURL == nil){
+        let tempSaveMoveiLocal:URL? = PQBFConfig.shared.enableWatermarkMovie ? saveMovieLocalURL : exportLocalURL
+        
+        if(tempSaveMoveiLocal == nil){
             BFLog(message: "保存相册的视频导出地址无效!!!")
             cShowHUB(superView: nil, msg: "保存相册的视频导出地址无效")
             saveVideoTipsLabel.text = "视频保存失败"
@@ -982,7 +995,7 @@ extension PQStuckPointPublicController {
             let photoLibrary = PHPhotoLibrary.shared()
             photoLibrary.performChanges({ [weak self] in
                 self?.isSaveingLocalVideo = true
-                PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: (self?.saveMovieLocalURL)!)
+                PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: (tempSaveMoveiLocal)!)
             }) { [weak self] isFinished, _ in
                 self?.isSaveingLocalVideo = false
                 DispatchQueue.main.async { [weak self] in
@@ -1326,7 +1339,8 @@ extension PQStuckPointPublicController {
             bottomOprationBgView.isHidden = false
             //add by ak 发布成功后如果带片尾的视频还没有生成成功时,出提示
             self.saveRetryBtn.isHidden = true
-            if(saveMovieLocalURL == nil && self.isSaveingLocalVideo){
+            self.saveVideoTipsBgView.isHidden = false
+            if(self.isSaveingLocalVideo){
                 saveVideoTipsLabel.text = "视频保存中..."
             }else{
                 self.saveVideoTipsLabel.text = "视频已保存到相册"