huzhiqiang 3 سال پیش
والد
کامیت
ac81024410
1فایلهای تغییر یافته به همراه11 افزوده شده و 6 حذف شده
  1. 11 6
      BFFramework/Classes/PQGPUImage/akfilters/PQMovieInput.swift

+ 11 - 6
BFFramework/Classes/PQGPUImage/akfilters/PQMovieInput.swift

@@ -222,14 +222,18 @@ public class PQMovieInput: ImageSource {
             displayLink.isPaused = true
             return
         }
- 
+
+        if self.beginTime == 0 {
+            self.beginTime = CFAbsoluteTimeGetCurrent()
+        }
  
         autoreleasepool {
       
             let duration = CMTimeGetSeconds(playeTimeRange.end)
             
             self.currentTime = CMTimeMakeWithSeconds(self.beginTime +  CMTimeGetSeconds(startTime ?? CMTime.zero), preferredTimescale: BASE_FILTER_TIMESCALE)
-            self.beginTime = self.beginTime + 1 / 30
+            self.currentTime = CMTimeMakeWithSeconds(CFAbsoluteTimeGetCurrent() - self.beginTime +  CMTimeGetSeconds(startTime ?? CMTime.zero), preferredTimescale: BASE_FILTER_TIMESCALE)
+//            self.beginTime = self.beginTime + 1 / 30
             
             let currTime = CMTimeGetSeconds(self.currentTime)
   
@@ -374,6 +378,7 @@ public class PQMovieInput: ImageSource {
         FilterLog(message: "PQMoveInput恢复播放")
         mFreeBuffer = false
         isPlay = true
+        self.beginTime = CFAbsoluteTimeGetCurrent() - CMTimeGetSeconds(self.currentTime) + CMTimeGetSeconds(self.startTime ?? CMTime(value: 0, timescale: 1))
 
         // 暂停帧的刷新 true:停 ; false:开始
         displayLink?.isPaused = false
@@ -533,10 +538,10 @@ public class PQMovieInput: ImageSource {
 
     func process() {
         autoreleasepool {
-            let startTime = CFAbsoluteTimeGetCurrent()
+            let startPTime = CFAbsoluteTimeGetCurrent()
 
             imageFramebuffer.lock()
-            BFLog(message: "mIsExport:\(mIsExport) 实际设置的每一帧时间戳:\(CMTimeGetSeconds(currentTime))")
+            BFLog(1, message: "mIsExport:\(mIsExport) 实际设置的每一帧时间戳:\(CMTimeGetSeconds(currentTime))")
             // 设置当前帧的时间戳
             imageFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(currentTime))
  
@@ -549,7 +554,7 @@ public class PQMovieInput: ImageSource {
             }
 
             if runBenchmark {
-                let currentFrameTime = (CFAbsoluteTimeGetCurrent() - startTime)
+                let currentFrameTime = (CFAbsoluteTimeGetCurrent() - startPTime)
                 totalFrameTimeDuringCapture += currentFrameTime
                 
                 
@@ -713,7 +718,7 @@ extension PQMovieInput {
         }
         
 //        avPlayerTimeObserver = avPlayer!.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 4), queue: DispatchQueue.global()) {[weak self] time in
-//             进度监控
+//         //    进度监控
 //            BFLog(1, message: "cont:\(CMTimeGetSeconds(time) - CMTimeGetSeconds((self?.musicPlayRanges?.first!.start)!)), curr:\(CMTimeGetSeconds(time))")
 //        } as? NSKeyValueObservation
     }