From 6151028a8e0e63ed6967faa7c23ff56b076879df Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期五, 05 四月 2019 11:22:03 +0800
Subject: [PATCH] 解决GB28181推多路流问题
---
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
index 0cfd3b4..f1386f5 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -5,6 +5,7 @@
#include <zconf.h>
#include <opencv2/opencv.hpp>
#include "FFmpegDecoderJPG.h"
+#include <cstring>
void BASICGB28181::initFFmpeg() {
av_register_all();
@@ -32,7 +33,7 @@
dst.data, dst.linesize);
sws_freeContext(convert_ctx);
- DBG("m.size is " << m.size());
+// DBG("m.size is " << m.size());
// LOG_IF();
return m;
@@ -145,7 +146,8 @@
* @param p_this
*/
void BASICGB28181::FFmpegDecoderJPG::BareFlowDecoderThd(FFmpegDecoderJPG *p_this) {
- DBG(p_this->m_camIdx << " BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx);
+ DBG(p_this->m_camIdx << " BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx);
+ DBG("p_thisADDR:" << p_this << "p_this->m_running" << p_this->m_running);
while (!p_this->m_running) {
p_this->m_running = true;
@@ -197,6 +199,12 @@
vi = i;
break;
}
+ }
+ if(vi == -1)//鏃犺棰戝寘
+ {
+ ERR("no video packet!!");
+ p_this->m_running = false;
+ continue;
}
p_this->stream = p_this->ic->streams[vi];
p_this->video_st = p_this->stream;
@@ -271,6 +279,20 @@
// 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 << "frame.data.len" << strlen(p_this->frame->data[0]));
+ continue;
+ }
+// else {
+// static int count =0;
+// count ++;
+// if(count > 100){
+// ERR("camID:" << p_this->m_camIdx << " cols:" << p_this->m_image.cols <<\
+// " rows:" << p_this->m_image.rows << " channels:" << p_this->m_image.channels());
+// count = 0;
+// }
+//
+// }
// 灏唅甯т繚瀛樹负蹇収
if (p_this->m_SnapshotNotSaveRet && (p_this->pkt.flags & AV_PKT_FLAG_KEY)) {
try {
@@ -310,6 +332,7 @@
#endif
//瑙﹀彂涓婂眰淇″彿
gSignalLock.emitSigal(p_this->m_camIdx + "DecoderImageOK");
+// DBG("emitSigal: " << p_this->m_camIdx);
//#ifdef TestCode
// DBG("emitSigal(\"DecoderImageOK\") after");
//#endif
@@ -446,7 +469,7 @@
delete iter->m_packet.data;
iter = m_packetsVec.erase(iter);
while (!(iter->m_packet.flags & AV_PKT_FLAG_KEY)) {
- INFO("DropFrame: " << iter->m_frameId);
+// INFO("DropFrame: " << iter->m_frameId);
delete iter->m_packet.data;
iter = m_packetsVec.erase(iter);
}
@@ -529,7 +552,7 @@
m_frameIndex++;
m_packetsVec.push_back({m_frameIndex, newPacket});
if (newPacket.flags & AV_PKT_FLAG_KEY) {
- DBG("newPacket.flags & AV_PKT_FLAG_KEY ");
+// DBG("newPacket.flags & AV_PKT_FLAG_KEY ");
m_last_I_FrameId = m_frameIndex;
}
}
--
Gitblit v1.8.0