| | |
| | | } |
| | | |
| | | BASICGB28181::FFmpegDecoderJPG::~FFmpegDecoderJPG() { |
| | | |
| | | while (m_rtpQueue.count_queue()) { |
| | | m_rtpQueue.popNotWait(); |
| | | } |
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | */ |
| | | 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) { |
| | |
| | | return -1; |
| | | } |
| | | |
| | | avformat_write_header(m_pOutFmtCtx, NULL); |
| | | DBG(" avformat_write_header " << avformat_write_header(m_pOutFmtCtx, NULL)); |
| | | |
| | | m_bstartWrite = true; |
| | | m_bFirstKeyFrame = true; |