From 18a05d269516a5e33d8460291c2f93e73d95adce Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 26 十二月 2023 10:45:31 +0800
Subject: [PATCH] GetYUV format is NV12

---
 csrc/worker/rec.cpp |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/csrc/worker/rec.cpp b/csrc/worker/rec.cpp
index 9cecfb0..28a7401 100644
--- a/csrc/worker/rec.cpp
+++ b/csrc/worker/rec.cpp
@@ -16,13 +16,13 @@
 using namespace ffwrapper;
 using namespace cffmpeg_wrap::buz;
 
-static const int cache_time = 6 * 60;
+static const int cache_time = 3 * 60 + 30;
 
 namespace cffmpeg_wrap
 {
     rec::rec()
     :recRef_(NULL)
-    ,min_cache_len_(cache_time * 25) // 鏈�灏忕紦瀛�?鍒嗛挓鐨勮棰�,鍥犱负鏁翠釜娴佺▼浼氭湁寤惰繜,鏆傚畾?鍒嗛挓
+    ,min_cache_len_(cache_time * 25)
     {}
 
     rec::~rec()
@@ -45,7 +45,7 @@
         list_recInfo_.emplace_back(info);
     }
 
-    void rec::findRecFramesIndex(const int64_t &fired_id, const int duration, int &start, int &end){
+    void rec::findRecFramesIndex(int64_t &fired_id, const int duration, int &start, int &end){
 
         start = end = -1;
 
@@ -75,7 +75,7 @@
                         start_id = i.v_id;
                     }
                 }
-            }else if (recRef_->isVideoPkt(&i.data->getAVPacket())){
+            }else {
                 // 瑙嗛甯�,鐪嬫槸鍚︾紦瀛樹腑鏈夋墍鏈夌殑duration鏁版嵁
                 if (i.v_id - start_id == duration){
                     end = index;
@@ -83,6 +83,9 @@
             }
             
         }
+
+        // 濡傛灉fired_id鍦╯tartid涔嬪墠,灏嗗叾鏀惧叆start_id涔嬪悗
+        if (start_id > fired_id) fired_id = start_id + duration / 2;
 
         if (end < 0) end = index;
     }
@@ -113,8 +116,10 @@
             std::lock_guard<std::mutex> locker(mtx_pkt_);
             logIt("cache size: %ld", list_pkt_.size());
             // 棣栨鑾峰彇褰曞儚淇℃伅,鍏堝瓨涓�涓渶鐭椂闀�
-            findRecFramesIndex(frameID, duration, start, end);
-            rec->StartWritePacket(list_pkt_, frameID, start, end);
+            // maybe fired_id changed by findRecFramesIndex
+            int64_t fired_id = frameID;
+            findRecFramesIndex(fired_id, duration, start, end);
+            rec->StartWritePacket(list_pkt_, fired_id, start, end);
 
             return rec;
         }

--
Gitblit v1.8.0