jsonwang пре 3 година
родитељ
комит
3f179625a2

+ 17 - 3
BFRecordScreenKit/Classes/RecordScreen/View/BFRecordAvatarView.swift

@@ -51,16 +51,29 @@ class BFRecordAvatarView: UIView {
         closedBtn.frame = CGRect.init(x: frame.maxX - 68, y: frame.maxY - 68, width: 68, height: 68)
         do {
             camera = try Camera(sessionPreset:.high,location: .frontFacing,captureAsYUV: true)
-            //            camera.runBenchmark = true
+            //camera.runBenchmark = true
            
             let conertFilter = PQCornerFilter.init()
             let cropFilter = Crop.init()
             cropFilter.cropSizeInPixels = videoPixelsSize
             cropFilter.cropSizeInPixels =  Size(width: 1080, height:1080)
             cropFilter.locationOfCropInPixels = Position.init(0, (1920 - 1080) / 2)
-            
+     
 //            camera  --> cropFilter --> conertFilter --> renderView
-            camera --> cropFilter --> conertFilter --> renderView
+     
+            //创建水印filter
+            let  weatMaskSticker:PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel.init()
+            weatMaskSticker.locationPath = "mask"
+            weatMaskSticker.timelineIn = 0
+            weatMaskSticker.timelineOut = 10000 * 100000
+     
+            let weatMaskFilter = PQImageFilter(sticker: weatMaskSticker, isExport: true,showUISize: CGSize.init(width: 1080, height: 1080))
+            
+            let alphaBlend = AlphaBlend.init()
+//            camera --> alphaBlend
+            camera --> renderView
+    
+//            alphaBlend  --> renderView
         } catch {
             fatalError("Could not initialize rendering pipeline: \(error)")
         }
@@ -119,6 +132,7 @@ class BFRecordAvatarView: UIView {
             cropFilter.cropSizeInPixels = videoPixelsSize
             cropFilter.locationOfCropInPixels = Position.init(0, 0)
             
+            
             camera  --> cropFilter --> conertFilter --> movieOutput!
            
             camera.audioEncodingTarget = movieOutput

+ 70 - 0
BFRecordScreenKit/Classes/RecordScreen/ViewModel/BFRecordScreenViewModel.swift

@@ -0,0 +1,70 @@
+//
+//  BFRecordScreenViewModel.swift
+//  Pods
+//
+//  Created by ak on 2021/12/7.
+//
+
+import Foundation
+import BFFramework
+import ObjectMapper
+import RealmSwift
+import BFVideoEditKit
+public class BFRecordScreenViewModel:NSObject{
+    
+    
+    /// 分段识别录音
+    /// - Parameters:
+    ///   - sectionIndex: 段落id
+    ///   - locationPaths: 分段录音
+    ///   - completeHander: <#completeHander description#>
+    /// - Returns: description
+    class public func batchUploadRecordVoiceMatarialData(beginTime: CMTime, locationPath: String, completeHander: @escaping (_ subTitleList: List<PQEditVisionTrackMaterialsModel>?, _ msg: String?) -> Void) {
+      
+        BFLog(message: "录音文件开始上传--\(locationPath)")
+     
+        if !FileManager.default.fileExists(atPath:documensDirectory + locationPath) {
+            BFLog(message: "上传录音-录音文件不存在")
+        } else {
+
+            let assert = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + locationPath), options: nil)
+            let voiceMaterials: PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel()
+            voiceMaterials.locationPath = locationPath
+            voiceMaterials.type = "voice"
+            voiceMaterials.duration = assert.duration.seconds * 1_000_000
+            BFLog(message: "上传录音-开始上传录音")
+            PQVideoEditViewModel.uploadMatarialData(isBatchUpload: false, materialData: voiceMaterials) { _, _, _, _, _, _, matarialInfo, _ in
+                let materialType: String = "\(matarialInfo?["materialType"] ?? "")"
+                let localPath: String = "\(matarialInfo?["localPath"] ?? "")"
+                
+                BFLog(message: "上传录音-录音上传返回--\(String(describing: matarialInfo))")
+                if matarialInfo != nil, matarialInfo?.keys.contains("localPath") ?? false, materialType == StickerType.VOICE.rawValue && localPath.contains("_noise_") {
+                    BFLog(message: "上传录音-录音上传成功开始转化字幕")
+                    let materialId: String = "\(matarialInfo?["materialId"] ?? "")"
+                    let duration: Float64 = Float64("\(matarialInfo?["duration"] ?? "")") ?? 0
+                    PQVideoEditViewModel.transferAudioMaterialToTextData(Int64(materialId) ?? 0, dutation: duration) { _, _, subTitleList, _ in
+                        BFLog(message: "上传录音-字幕转化完成:\(subTitleList.count)")
+ 
+                        if subTitleList.count > 0 {
+                    
+                        }
+                
+                    }
+                }
+            }
+        }
+        
+        //        dispatchGroup.notify(queue: DispatchQueue.main) {
+        //            BFLog(message: "语音均已识别完成")
+        //            let subTitleList: List<PQEditVisionTrackMaterialsModel> = List<PQEditVisionTrackMaterialsModel>.init()
+        //            BFLog(message: "tempSubTitles == \(String(describing: tempSubTitles.first))")
+        //            tempSubTitles.forEach { tempItems in
+        //                tempItems.forEach { item in
+        //                    subTitleList.append(item)
+        //                }
+        //            }
+        //            completeHander(sectionIndex, subTitleList, nil)
+        //        }
+    }
+    
+}