From f946a62d3921e86b44ff8e2973138304b9cd53cd Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期二, 16 四月 2019 16:36:32 +0800
Subject: [PATCH] 解决修改参数和推流画面跳跃问题

---
 QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
index a6871d4..7787821 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -278,6 +278,10 @@
 
 //        BASICGB28181::avframe_to_cvmat(frame).copyTo(p_this->m_image);
             p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(p_this->frame));
+            if(p_this->m_image.empty()) {
+                ERR("camID:" << p_this->m_camIdx << " frameW:" << p_this->frame->width);
+                continue;
+            }
 //            灏唅甯т繚瀛樹负蹇収
             if (p_this->m_SnapshotNotSaveRet && (p_this->pkt.flags & AV_PKT_FLAG_KEY)) {
                 try {
@@ -369,7 +373,7 @@
 
 bool BASICGB28181::FFmpegDecoderJPG::stopThd() {
     TryCath(
-        DBG(m_camIdx << "  FFmpegDecoderJPG stopThd ... " << m_camIdx);
+        DBG("FFmpegDecoderJPG stopThd ... " << m_camIdx);
         m_running = false;
     );
     return true;
@@ -434,7 +438,7 @@
         if (!m_packetsVec.empty()) {
             auto iter = m_packetsVec.begin();
             while (iter->m_frameId < lastFrameId) {
-                INFO("DropFrame: " << iter->m_frameId);
+//                INFO("DropFrame: " << iter->m_frameId);
                 delete iter->m_packet.data;
                 iter = m_packetsVec.erase(iter);
             }
@@ -464,7 +468,7 @@
 
 bool BASICGB28181::FFmpegDecoderJPG::SaveVideo(std::string path, int64_t lastFrameId) {
     std::lock_guard<std::mutex> lock(g_mutex);
-    INFO("SaveVideo: " << path << "m_packetsVec.size : " << m_packetsVec.size());
+//    INFO("SaveVideo: " << path << "m_packetsVec.size : " << m_packetsVec.size());
     if (!m_packetsVec.empty()) {
         startWrite(path.c_str());
         int64_t firstKeyFramePts = m_packetsVec[0].m_packet.pts;
@@ -472,7 +476,7 @@
         unsigned long int frame_index = 0;
         for (const auto &item:m_packetsVec) {
             if (item.m_frameId < lastFrameId) {
-                DBG("item.m_frameId < lastFrameId   " << item.m_frameId << "  " << lastFrameId);
+//                DBG("item.m_frameId < lastFrameId   " << item.m_frameId << "  " << lastFrameId);
                 conversion(const_cast<AVPacket *> (&item.m_packet), firstKeyFramePts, firstKeyFrameDts, video_st,
                            frame_index);
                 frame_index++;
@@ -618,7 +622,7 @@
         AVPacket *pkg = static_cast<AVPacket *>(packet);
 
 
-        DBG("frame_index==%d\n" << frame_index);
+//        DBG("frame_index==\n" << frame_index);
         //Write PTS
         AVRational time_base1 = inStream->time_base;
         //Duration between 2 frames (us)

--
Gitblit v1.8.0