video analysis2.0拆分,ffmpeg封装go接口库
chenshijun
2019-07-17 0367d8e503ca5df1eae359929b8753050ccd9980
csrc/ffmpeg/format/FormatIn.cpp
@@ -21,6 +21,7 @@
#include "../data/FrameData.hpp"
#include "../../common/gpu/info.h"
#include "PsToEs.hpp"
using namespace logif;
@@ -52,7 +53,7 @@
   }
////////////////////////////////////////////////////////////////////////
   int FormatIn::openWithCustomIO(read_packet fn, AVDictionary **options/*=NULL*/){
   int FormatIn::openWithCustomIO(void *opaque, read_packet fn, AVDictionary **options/*=NULL*/){
      ctx_ = avformat_alloc_context();
      if(!ctx_){
         logIt("open with custom io create format error");
@@ -64,21 +65,43 @@
         return -1;
      }
      io_ctx_ = avio_alloc_context(read_io_buff_, read_io_buff_size_, 0, NULL, fn, NULL, NULL);
      io_ctx_ = avio_alloc_context(read_io_buff_, read_io_buff_size_, 0, opaque, fn, NULL, NULL);//opaque
      if(!io_ctx_){
         logIt("open with custom io create custom avio error");
         return -1;
      }
      ctx_->pb = io_ctx_;
      auto err = av_probe_input_buffer(io_ctx_, &ctx_->iformat, NULL, NULL, 0, read_io_buff_size_);
      auto err = av_probe_input_buffer(ctx_->pb, &ctx_->iformat, NULL, NULL, 0, read_io_buff_size_);
      if(err != 0){
         logIt("open with custom io prob input buffer error");
         logIt("open with custom io prob input buffer error:%d", err);
            logIt("failed:%s", getAVErrorDesc(err).c_str());
         return -1;
      }
      return 0;
   }
   int FormatIn::openGb28181(const char *filename, AVDictionary **options){
       std::string fn = filename;
      addCamera(fn);
        int ret = openWithCustomIO(NULL, readData, options);
        if(ret < 0){
            logIt("do openWithCustomIO failed:%d",ret);
        }
        ret = avformat_open_input(&ctx_, "", NULL, options);
        if(ret < 0){
            logIt("open %s failed:%s",filename,
                  getAVErrorDesc(ret).c_str());
        }
      return ret;
   }
/////////////////////////////////////////////////////////////////////////
   int FormatIn::open(const char *filename, AVDictionary **options){