From d3b7bbe7102cd089680a828f5d8f6402c8cf6342 Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期四, 07 三月 2019 14:43:28 +0800
Subject: [PATCH] GB28181集成完成,集成推流模块
---
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp | 60 +++++++++++++++++++++++++++++++++++-------------------------
1 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
index 5106cbf..c353675 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -44,7 +44,6 @@
}
BASICGB28181::FFmpegDecoderJPG::~FFmpegDecoderJPG() {
-
while (m_rtpQueue.count_queue()) {
m_rtpQueue.popNotWait();
}
@@ -65,10 +64,20 @@
info->buffLen = datalen;
info->camIdx = camIdx;
memcpy(info->buff, data, datalen);
+ {
+// FILE *fp11 = NULL;
+// if (!fp11) {
+// fp11 = fopen(camIdx.c_str(), "a+");
+// }
+// fwrite(data, sizeof(char), datalen, fp11);
+// fclose(fp11);
+ }
+
#ifdef TestCode
DBG(" m_rtpQueue.push before ");
#endif
- m_rtpQueue.push(info);
+ m_rtpQueue.
+ push(info);
#ifdef TestCode
DBG(" m_rtpQueue.push after ");
#endif
@@ -193,7 +202,7 @@
p_this->frame_number++;
int err6 = avcodec_send_packet(ctx, &pkt);
- av_packet_unref(&pkt);
+// av_packet_unref(&pkt);
int err7 = avcodec_receive_frame(ctx, frame);
if ((err7 == AVERROR(EAGAIN)) || (err5 < 0) || (err6 < 0)) {
ERR(" error << err7:" << err7 << " err5: " << err5 << " err6: " << err6);
@@ -446,6 +455,7 @@
m_frameIndex++;
m_packetsVec.push_back({m_frameIndex, newPacket});
if (newPacket.flags & AV_PKT_FLAG_KEY) {
+ DBG("newPacket.flags & AV_PKT_FLAG_KEY ");
m_last_I_FrameId = m_frameIndex;
}
}
@@ -466,27 +476,27 @@
*/
m_pOutVideo_stream = avformat_new_stream(m_pOutFmtCtx, NULL);
{
-// AVCodecContext *c;
-// c = m_pOutVideo_stream->codec;
-// c->bit_rate = 400000;
-// c->codec_id = video_st->codec->codec_id;
-// c->codec_type = video_st->codec->codec_type;
-// c->time_base.num = video_st->time_base.num;
-// c->time_base.den = video_st->time_base.den;
-// fprintf(stderr, "time_base.num = %d time_base.den = %d\n", c->time_base.num, c->time_base.den);
-// c->width = video_st->codec->width;
-// c->height = video_st->codec->height;
-// c->pix_fmt = video_st->codec->pix_fmt;
-// printf("%d %d %d", c->width, c->height, c->pix_fmt);
-// c->flags = video_st->codec->flags;
-// c->flags |= CODEC_FLAG_GLOBAL_HEADER;
-// c->me_range = video_st->codec->me_range;
-// c->max_qdiff = video_st->codec->max_qdiff;
-//
-// c->qmin = video_st->codec->qmin;
-// c->qmax = video_st->codec->qmax;
-//
-// c->qcompress = video_st->codec->qcompress;
+ AVCodecContext *c;
+ c = m_pOutVideo_stream->codec;
+ c->bit_rate = 400000;
+ c->codec_id = video_st->codec->codec_id;
+ c->codec_type = video_st->codec->codec_type;
+ c->time_base.num = video_st->time_base.num;
+ c->time_base.den = video_st->time_base.den;
+ fprintf(stderr, "time_base.num = %d time_base.den = %d\n", c->time_base.num, c->time_base.den);
+ c->width = video_st->codec->width;
+ c->height = video_st->codec->height;
+ c->pix_fmt = video_st->codec->pix_fmt;
+ printf("%d %d %d", c->width, c->height, c->pix_fmt);
+ c->flags = video_st->codec->flags;
+ c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+ c->me_range = video_st->codec->me_range;
+ c->max_qdiff = video_st->codec->max_qdiff;
+
+ c->qmin = video_st->codec->qmin;
+ c->qmax = video_st->codec->qmax;
+
+ c->qcompress = video_st->codec->qcompress;
}
ret = avio_open(&m_pOutFmtCtx->pb, filename, AVIO_FLAG_WRITE);
if (ret < 0) {
@@ -494,7 +504,7 @@
return -1;
}
- avformat_write_header(m_pOutFmtCtx, NULL);
+ DBG(" avformat_write_header " << avformat_write_header(m_pOutFmtCtx, NULL));
m_bstartWrite = true;
m_bFirstKeyFrame = true;
--
Gitblit v1.8.0