Преглед изворни кода

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

wenweiwei пре 3 година
родитељ
комит
ba4476dad7

+ 30 - 2
BFFramework/Classes/PQGPUImage/akfilters/Tools/PQCompositionExporter.swift

@@ -8,6 +8,7 @@
 
 import AVFoundation
 import Foundation
+import ObjectMapper
 // import GPUImage
 
 public class PQCompositionExporter {
@@ -32,6 +33,9 @@ public class PQCompositionExporter {
     
     //最后一次显示的 sticker
     var lastshowSticker:PQEditVisionTrackMaterialsModel?
+    
+    //是否显示高斯
+    var showGaussianBlur:Bool = false
 
      init(asset: AVAsset, videoComposition: AVVideoComposition? = nil, audioMix: AVAudioMix? = nil, filters: [ImageProcessingOperation]? = nil,stickers:[PQEditVisionTrackMaterialsModel]? = nil, animationTool: AVVideoCompositionCoreAnimationTool? = nil, exportURL: URL) {
         self.asset = asset
@@ -163,8 +167,32 @@ public class PQCompositionExporter {
             }
             input!.removeAllTargets()
             let currentTarget: ImageSource = input!
-            currentTarget.addTarget(showFitler!, atTargetIndex: 0)
-            showFitler?.addTarget(output!, atTargetIndex: 0)
+            if(currentSticker?.type == StickerType.IMAGE.rawValue && showGaussianBlur){
+                //高斯层
+                let json = currentSticker?.toJSONString(prettyPrint: false)
+                if json == nil {
+                    BFLog(message: "数据转换有问题 跳转")
+                    return
+                }
+                let blurStickerModel: PQEditVisionTrackMaterialsModel? = Mapper<PQEditVisionTrackMaterialsModel>().map(JSONString: json!)
+                blurStickerModel?.canvasFillType = stickerContentMode.aspectFillStr.rawValue
+                let showGaussianFitler:PQBaseFilter = PQImageFilter(sticker: blurStickerModel!)
+                
+                let iosb:GaussianBlur = GaussianBlur.init()
+                iosb.blurRadiusInPixels = 20
+                showGaussianFitler.addTarget(iosb)
+                
+                currentTarget.addTarget(showGaussianFitler, atTargetIndex: 0)
+                
+                iosb.addTarget(showFitler!)
+     
+                showFitler?.addTarget(output!, atTargetIndex: 0)
+            }else{
+                currentTarget.addTarget(showFitler!, atTargetIndex: 0)
+                showFitler?.addTarget(output!, atTargetIndex: 0)
+
+            }
+
             lastshowSticker = currentSticker
         }
  

+ 1 - 0
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -57,6 +57,7 @@ class PQStuckPointEditerController: PQBaseViewController {
         let playerView = PQGPUImagePlayerView(frame: CGRect(x: 0, y: navHeadImageView?.frame.maxY ?? 0, width: playerHeight, height: playerHeight))
         playerView.backgroundColor = PQBFConfig.shared.styleBackGroundColor
         playerView.isShowLine = false
+        playerView.showGaussianBlur = true
         return playerView
     }()
 

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

@@ -256,26 +256,32 @@ class PQStuckPointPublicController: PQBaseViewController {
 
     
     override func backBtnClick() {
-        view.endEditing(true)
-        let remindData = PQBaseModel()
-        remindData.title = "编辑的内容,将不会被保存"
-        let remindView = PQRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
-        remindView.isBanned = true
-        remindView.confirmBtn.setTitle("确认", for: .normal)
-        remindView.cancelBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#333333"), for: .normal)
-        remindView.confirmBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#EE0051"), for: .normal)
-        UIApplication.shared.keyWindow?.addSubview(remindView)
-        remindView.remindData = remindData
-        remindView.remindBlock = { [weak self] item, _ in
-            if item.tag == 2 {
-                // 取消导出
-                if self?.exporter != nil {
-                    self?.exporter.cancel()
+        
+        if(isExportSuccess){
+            navigationController?.popViewController(animated: true)
+        }else{
+            view.endEditing(true)
+            let remindData = PQBaseModel()
+            remindData.title = "编辑的内容,将不会被保存"
+            let remindView = PQRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
+            remindView.isBanned = true
+            remindView.confirmBtn.setTitle("确认", for: .normal)
+            remindView.cancelBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#333333"), for: .normal)
+            remindView.confirmBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#EE0051"), for: .normal)
+            UIApplication.shared.keyWindow?.addSubview(remindView)
+            remindView.remindData = remindData
+            remindView.remindBlock = { [weak self] item, _ in
+                if item.tag == 2 {
+                    // 取消导出
+                    if self?.exporter != nil {
+                        self?.exporter.cancel()
+                    }
+                    self?.navigationController?.popViewController(animated: true)
+                 
                 }
-                self?.navigationController?.popViewController(animated: true)
-             
             }
         }
+   
     }
     
     override func viewDidLoad() {
@@ -411,6 +417,7 @@ extension PQStuckPointPublicController {
         let inputAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + (audioMixModel?.localPath ?? "")), options: avAssertOptions)
         // 每次初始化的时候设置初始值 为 nIl
         exporter = PQCompositionExporter(asset: inputAsset, videoComposition: nil, audioMix: nil, filters: nil, stickers: mStickers, animationTool: nil, exportURL: outPutMP4URL)
+        exporter.showGaussianBlur = true
         if exporter.prepare(videoSize: CGSize(width: editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0, height: editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0)) {
             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))")

+ 32 - 4
BFFramework/Classes/Stuckpoint/ViewModel/PQGPUImagePlayerView.swift

@@ -9,6 +9,7 @@
 import AVFoundation
 import AVKit
 import UIKit
+import ObjectMapper
 
 // import GPUImage
 struct AVAssetKey {
@@ -151,6 +152,9 @@ public class PQGPUImagePlayerView: UIView, RenderViewDelegate {
     var showProgressLab: Bool = true
 
     var cacheFilters: [PQBaseFilter] = Array()
+    
+    //是否显示高斯
+    var showGaussianBlur:Bool = false
 
     // 渲染区view
     private lazy var renderView: RenderView = {
@@ -445,10 +449,34 @@ public class PQGPUImagePlayerView: UIView, RenderViewDelegate {
 
             movie!.removeAllTargets()
             let currentTarget: ImageSource = movie!
-//
-            currentTarget.addTarget(showFitler!, atTargetIndex: 0)
-//
-            showFitler?.addTarget(renderView, atTargetIndex: 0)
+            
+               if(currentSticker?.type == StickerType.IMAGE.rawValue && showGaussianBlur){
+                   //高斯层
+                   let json = currentSticker?.toJSONString(prettyPrint: false)
+                   if json == nil {
+                       BFLog(message: "数据转换有问题 跳转")
+                       return
+                   }
+                   let blurStickerModel: PQEditVisionTrackMaterialsModel? = Mapper<PQEditVisionTrackMaterialsModel>().map(JSONString: json!)
+                   blurStickerModel?.canvasFillType = stickerContentMode.aspectFillStr.rawValue
+                   let showGaussianFitler:PQBaseFilter = PQImageFilter(sticker: blurStickerModel!)
+                   
+                   let iosb:GaussianBlur = GaussianBlur.init()
+                   iosb.blurRadiusInPixels = 20
+                   showGaussianFitler.addTarget(iosb)
+                   
+                   currentTarget.addTarget(showGaussianFitler, atTargetIndex: 0)
+                   
+                   iosb.addTarget(showFitler!)
+        
+                   showFitler?.addTarget(renderView, atTargetIndex: 0)
+               }else{
+                   currentTarget.addTarget(showFitler!, atTargetIndex: 0)
+                   showFitler?.addTarget(renderView, atTargetIndex: 0)
+
+               }
+           
+
 
             lastshowSticker = currentSticker
         }