فهرست منبع

1,修改卡点创建sticker 数据逻辑 会导致一些视频预览时黑屏

jsonwang 3 سال پیش
والد
کامیت
e76da47570
1فایلهای تغییر یافته به همراه24 افزوده شده و 11 حذف شده
  1. 24 11
      BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

+ 24 - 11
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -108,6 +108,7 @@ class PQStuckPointEditerController: PQBaseViewController {
                 let seekTimeRange: CMTimeRange = CMTimeRange(start: CMTime(value: CMTimeValue(Int64(newBeginSconds)), timescale: 600), end:
                     CMTime(value: CMTimeValue(Int64(endTime * 600)), timescale: 600))
                 BFLog(message: "修改的开始 \(CMTimeGetSeconds(seekTimeRange.start)) 结束  \(CMTimeGetSeconds(seekTimeRange.end))")
+                self?.playerView.configCache(beginTime: CMTimeGetSeconds(seekTimeRange.start))
                 self?.playerView.play(pauseFirstFrame: false, playeTimeRange: seekTimeRange)
 
             } else {
@@ -403,7 +404,7 @@ class PQStuckPointEditerController: PQBaseViewController {
 
                 // 5,开始播放
                 self.playerView.isLoop = false
-                self.playerView.showProgressLab = false
+                self.playerView.showProgressLab = true
 
                 // 初始化音频的开始和结束时间
                 BFLog(message: "播放的器 开始\(String(describing: CMTimeGetSeconds(self.playeTimeRange.start))) 结束 \(String(describing: CMTimeGetSeconds(self.playeTimeRange.end)))")
@@ -464,8 +465,8 @@ extension PQStuckPointEditerController {
            3, 视频素材a1需要切分的个数clipNum = max (round (kongduan * a1 / L) , 1)
          */
         // 要补的空位数
-        let kongduan: Int = Int(stuckPoints.count) - 1 - Int(section.sectionTimeline!.visionTrack?.getEnableVisionTrackMaterials().count ?? 0)
-
+        let kongduan: Int = Int(stuckPoints.count) -  Int(section.sectionTimeline!.visionTrack?.getEnableVisionTrackMaterials().count ?? 0)
+ 
         // 所有视频总时长
         var videoTotalDuration: Float64 = 0.0
         for video in section.sectionTimeline!.visionTrack!.getEnableVisionTrackMaterials(type: "video") {
@@ -483,8 +484,7 @@ extension PQStuckPointEditerController {
                 let clipNum = Int(max(round(Double(kongduan) * CMTimeGetSeconds(asset.duration) / videoTotalDuration), 1))
                 sticker.duration = CMTimeGetSeconds(asset.duration)
                 BFLog(message: "单个视频\(sticker.locationPath)时长::\(CMTimeGetSeconds(asset.duration)) ,clipNum is:\(clipNum)")
-
-                for clipindex in 0 ... clipNum {
+                for clipindex in 0 ... clipNum - 1 {
                     // deep copy sticker model 防止只有一个对象
                     let stickerjson = sticker.toJSONString(prettyPrint: false)
                     let deepCopySticker = Mapper<PQEditVisionTrackMaterialsModel>().map(JSONString: stickerjson!)
@@ -614,25 +614,38 @@ extension PQStuckPointEditerController {
                         // 第二种情况:有视频要进行分割
                         let clipFilters = clipVideoMerage(section: section, stuckPoints: stuckPoints)
                         for (index, point) in stuckPoints.enumerated() {
+                            BFLog(message: "aaaaaindexindeindexxindexindexindex \(index)")
                             if index + 1 < stuckPoints.count, index < clipFilters.count {
+                                BFLog(message: "bbbbbindexindeindexxindexindexindex \(index)")
                                 let sticker: PQEditVisionTrackMaterialsModel = clipFilters[index]
                                 sticker.timelineIn = Float64(stuckPoints[index])
-                                sticker.timelineOut = Float64(stuckPoints[index + 1])
-
-                                // 卡点的时间 >  in out 值
+                                // TODO 不是最好方案
+                                sticker.timelineOut = Float64(stuckPoints[index + 1]) + 1
+                                // 卡点的时间 >  in out 值 这里就会出现鬼畜效果
                                 let timelineInterval = sticker.timelineOut - sticker.timelineIn
                                 let inOutInterval = sticker.out - sticker.model_in
                                 if timelineInterval > inOutInterval {
-                                    sticker.out = sticker.model_in + timelineInterval
+                                    BFLog(message: "实际要显示卡点时长\(timelineInterval) 素材裁剪时长:\(inOutInterval)")
+                                    sticker.out = sticker.model_in + timelineInterval + 0.01
+                                    
+                                    //下面只是 LOG 方便查问题
+                                    let stickerInOut = sticker.out - sticker.model_in
+                                    let stickerTimelineInOut = sticker.timelineOut - sticker.timelineIn
+                                    if(stickerInOut != stickerTimelineInOut){
+                                        BFLog(message: "sticker.timelineIn \(sticker.timelineIn) stickerTimelineInOut is\(stickerTimelineInOut) stickerInOut is\(stickerInOut) 相差\(stickerTimelineInOut - stickerInOut)")
+                                    }
                                 }
+                                
+                            
                                 // out > 素材的总时长in out 进行前移操作
                                 let offsetAssetDuration = sticker.out - sticker.duration
                                 if offsetAssetDuration > 0 {
-                                    sticker.model_in = sticker.model_in - offsetAssetDuration
+                                    sticker.model_in = sticker.model_in - offsetAssetDuration - 0.01
                                     sticker.out = sticker.out - offsetAssetDuration
                                 }
 
-                                BFLog(message: "分割后 创建 filter start :\(sticker.timelineIn) end :\(sticker.timelineOut) type is \(sticker.type)")
+                                BFLog(message: "index is \(index)分割后 创建 filter timelineIn :\(sticker.timelineIn) timelineOut :\(sticker.timelineOut)  in :\(sticker.model_in) out:\(sticker.out) type is \(sticker.type) 显示总时长为:\(sticker.timelineOut - sticker.timelineIn)  裁剪总时长\(sticker.out - sticker.model_in)")
+
                                 stickers.append(sticker)
                             }
                         }