Commit 967c00fb547a16c0f94ae812f75e2aed23679d11

Authored by Hu Chunming
2 parents 9b8c645d a63dd3d2

Merge branch 'dev-cmhu' into 'master'

修复recode初始化崩溃问题

See merge request !8
src/decoder/dvpp/FFRecoder.cpp
... ... @@ -122,7 +122,18 @@ bool FFRecoder::init(int w, int h, AVRational time_base, AVCodecContext* avctx,
122 122  
123 123 bool FFRecoder::init(AVStream* stream, AVCodecContext* avctx, const char* outfile_name) {
124 124  
125   - codec_ctx_ = (AVCodecContext*)av_malloc(sizeof(AVCodecContext));
  125 + const AVCodec* encoder = avcodec_find_encoder(avctx->codec_id);
  126 + if (!encoder) {
  127 + LOG_ERROR("Find encoder AV_CODEC_ID_H264 failed!");
  128 + return false;
  129 + }
  130 + // 获取解码器上下文
  131 + codec_ctx_ = avcodec_alloc_context3(encoder);
  132 + if (!codec_ctx_) {
  133 + LOG_ERROR("Alloc context for encoder contx failed!");
  134 + return false;
  135 + }
  136 +
126 137 avcodec_copy_context(codec_ctx_, avctx);
127 138 codec_ctx_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
128 139 m_inStream = stream;
... ...
src/decoder/dvpp/FFRecoderTaskManager.cpp
... ... @@ -400,7 +400,7 @@ void FFRecoderTaskManager::recode_thread2() {
400 400 // 发送mq消息
401 401 if(mq_publish_func && recoderinfo.mq_info.length() > 0) {
402 402 mq_publish_func(recoderinfo.mq_info.c_str());
403   - LOG_INFO("record save: {}", recoderinfo.mq_info.c_str());
  403 + // LOG_INFO("record save: {}", recoderinfo.mq_info.c_str());
404 404 }
405 405  
406 406 LOG_INFO("record end, total save: {} start_frame_nb: {} end_frame_nb: {} file_path: {}", count, start_frame_nb, end_frame_nb, file_name);
... ...
src/demo/demo.cpp
... ... @@ -642,10 +642,10 @@ string createTask(void *handle, std::vector<algorithm_type_t> algor_vec, int gi)
642 642 tparam.ipc_url = "rtsp://admin:ad123456@192.168.60.165:554/cam/realmonitor?channel=1&subtype=0";
643 643 break;
644 644 case 1:
645   - tparam.ipc_url = "/opt/cmhu/data/bayue.mp4";
  645 + tparam.ipc_url = "/opt/share/data/bayue.mp4";
646 646 break;
647 647 case 2:
648   - tparam.ipc_url = "/opt/cmhu/data/Street.uvf";
  648 + tparam.ipc_url = "/opt/share/data/Street.uvf";
649 649 break;
650 650 case 3:
651 651 tparam.ipc_url = "rtsp://122.97.218.170:8604/openUrl/V5nXRHa?params=eyJwcm90b2NhbCI6InJ0c3AiLCJjbGllbnRUeXBlIjoib3Blbl9hcGkiLCJleHByaWVUaW1lIjotMSwicHJvdG9jb2wiOiJydHNwIiwiZXhwaXJlVGltZSI6MzAwLCJlbmFibGVNR0MiOnRydWUsImV4cGFuZCI6InN0YW5kYXJkPXJ0c3Amc3RyZWFtZm9ybT1ydHAiLCJhIjoiMTBjZjM4N2JjY2Y5NDg3YzhjNWYzNjE2M2ViMWUyNTJ8MXwwfDEiLCJ0IjoxfQ==";
... ... @@ -654,13 +654,13 @@ string createTask(void *handle, std::vector<algorithm_type_t> algor_vec, int gi)
654 654 tparam.ipc_url = "rtsp://admin:ad123456@192.168.60.165:554/cam/realmonitor?channel=1&subtype=0";
655 655 break;
656 656 case 5:
657   - tparam.ipc_url = "/opt/shzhao/vpt_ascend/data/公安局老桥头_CVR15F89410_1465819864_1B.mp4";
  657 + tparam.ipc_url = "/opt/share/data/公安局老桥头_CVR15F89410_1465819864_1B.mp4";
658 658 break;
659 659 case 6:
660   - tparam.ipc_url = "/opt/shzhao/vpt_ascend/data/不带头盔2.mp4";
  660 + tparam.ipc_url = "/opt/share/data/不带头盔2.mp4";
661 661 break;
662 662 default:
663   - tparam.ipc_url = "/opt/cmhu/data/Street.uvf";
  663 + tparam.ipc_url = "/opt/share/data/Street.uvf";
664 664 break;
665 665 }
666 666  
... ...