| | |
| | | return bufsize; |
| | | } |
| | | |
| | | /*** |
| | | * 解码线程 |
| | | * @param p_this |
| | | */ |
| | | void BASICGB28181::FFmpegDecoderJPG::BareFlowDecoderThd(FFmpegDecoderJPG *p_this) { |
| | | DBG(p_this->m_camIdx << " BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx); |
| | | p_this->m_running = true; |
| | |
| | | //# todo save package |
| | | p_this->frame_number++; |
| | | |
| | | //DBG("GotPicture "<<m_camId<<":"<<frame_number); |
| | | //放在此处是因为之前放在前面,收到的帧不完成 |
| | | p_this->SaveToPacketVector(pkt); |
| | | p_this->CheckSave(); |
| | | |
| | | int err6 = avcodec_send_packet(ctx, &pkt); |
| | | av_packet_unref(&pkt); |
| | | int err7 = avcodec_receive_frame(ctx, frame); |
| | |
| | | usleep(40000); |
| | | continue; |
| | | } |
| | | //DBG("GotPicture "<<m_camId<<":"<<frame_number); |
| | | //放在此处是因为之前放在前面,收到的帧不完成 |
| | | p_this->SaveToPacketVector(pkt); |
| | | p_this->CheckSave(); |
| | | |
| | | // BASICGB28181::avframe_to_cvmat(frame).copyTo(p_this->m_image); |
| | | p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(frame)); |
| | | |
| | | #ifdef TestCode |
| | | { |
| | | // TestCode |
| | | // TestCode 测试代码保存图片到本地 |
| | | ClockTimer cl("TestCode"); |
| | | std::string strNewTime2 = AppUtil::getTimeUSecString(); |
| | | cv::putText(p_this->m_image, strNewTime2, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN, |
| | |
| | | #ifdef TestCode |
| | | DBG("emitSigal(\"DecoderImageOK\") begin"); |
| | | #endif |
| | | |
| | | //触发信号 |
| | | gSignalLock.emitSigal(p_this->m_camIdx + "DecoderImageOK"); |
| | | //#ifdef TestCode |
| | | // DBG("emitSigal(\"DecoderImageOK\") after"); |
| | |
| | | |
| | | bool BASICGB28181::FFmpegDecoderJPG::stopThd() { |
| | | TryCath( |
| | | DBG(m_camIdx << " FFmpegDecoderJPG stopThd ... "); |
| | | DBG(m_camIdx << " FFmpegDecoderJPG stopThd ... " << m_camIdx); |
| | | m_running = false; |
| | | ); |
| | | return true; |
| | |
| | | int64_t firstKeyFrameDts = m_packetsVec[0].m_packet.dts; |
| | | for (const auto &item:m_packetsVec) { |
| | | if (item.m_frameId < lastFrameId) { |
| | | DBG("item.m_frameId < lastFrameId " << item.m_frameId << " " << lastFrameId); |
| | | conversion(const_cast<AVPacket *> (&item.m_packet), firstKeyFramePts, firstKeyFrameDts, video_st); |
| | | av_write_frame(m_pOutFmtCtx, &item.m_packet); |
| | | } else { |
| | | DBG("item.m_frameId > lastFrameId " << item.m_frameId << " " << lastFrameId); |
| | | break; |
| | | } |
| | | } |