video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2020-09-01 d9952f61a53b693a75490e4932d7136e14e7dc08
csrc/wrapper.cpp
@@ -45,6 +45,7 @@
    ,audio_(false)
    ,gb_(0)
    ,cpu_(0)
    ,devid_(-1)
    ,run_dec_(false)
    ,run_stream_(true)
    ,run_rec_(false)
@@ -66,6 +67,7 @@
    ,audio_(false)
    ,gb_(0)
    ,cpu_(0)
    ,devid_(-1)
    ,run_dec_(false)
    ,run_stream_(true)
    ,run_rec_(false)
@@ -108,8 +110,9 @@
        prop.url_ = input;
        prop.rtsp_tcp_ = true;
        prop.gpu_acc_ = !cpu_;
        prop.gpu_index_ = devid_;
       std::unique_ptr<FormatIn> in(new FormatIn(prop.gpuAccl()));
       std::unique_ptr<FormatIn> in(new FormatIn(prop, prop.gpuAccl()));
       int flag = -1;
        if (gb_){
            flag = in->openGb28181(input, NULL);
@@ -222,7 +225,7 @@
            bool exist = access(input_url_.c_str(), 0) == 0;
            if (exist){
                wTime <<= 1;
                wTime += wTime/2;
                file_rebootime++;
            }
@@ -259,10 +262,10 @@
                id++;
                //本地文件太快sleep一下
                if (exist){
                    usleep(wTime);
                if (exist && in->isVideoPkt(&data->getAVPacket())){
                    // 记录解码的文件有多少帧
                    file_frame++;
                    usleep(wTime);
                }
            }
@@ -271,13 +274,17 @@
            if (exist) {
                // 三次一帧都没解出来,退出
                if (file_frame == 0 && file_rebootime < 3){
                    logIt("libcffmpeg.so-> run %lld time, current frames %lld", file_rebootime, file_frame);
                    continue;
                }
                // 最小需要解出多少帧
                if (file_frame < min_duration_ * fps_){
                    logIt("libcffmpeg.so-> run %lld time, current frames %lld, mind %d, fps: %d",
                     file_rebootime, file_frame, min_duration_, fps_);
                    continue;
                }
                logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld", input_url_.c_str(), file_rebootime, file_frame);
                logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld, mind %d, fps: %d",
                    input_url_.c_str(), file_rebootime, file_frame, min_duration_, fps_);
                file_finished_ = true;
                break;
            }