video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-10-21 c60d61c48c7a1e7b693d4c3f6427e3b616d1f471
csrc/worker/rec.cpp
@@ -20,8 +20,7 @@
{
    rec::rec()
    :recRef_(NULL)
    ,min_cache_len_(125)
    ,time_offset_(5)
    ,min_cache_len_(10 * 60 * 25) // 最小缓存?分钟的视频,因为整个流程会有延迟,暂定?分钟
    {}
    rec::~rec()
@@ -44,7 +43,7 @@
        list_recInfo_.emplace_back(info);
    }
    std::unique_ptr<buz::Recorder> rec::startRec(std::string id, std::string dir, const int mind, const int maxd, const bool audio){
    std::unique_ptr<buz::Recorder> rec::startRec(std::string id, std::string dir, const int64_t &frameID, const int mind, const int maxd, const bool audio){
        if(!recRef_){
            logIt("Init wrapper first");
            return nullptr;
@@ -62,6 +61,7 @@
            if(ret == 0) break;
            usleep(200000);
        }
        if (trycnt < 100){
            std::lock_guard<std::mutex> locker(mtx_pkt_);
            rec->PushPackets(list_pkt_);
@@ -137,7 +137,7 @@
        return recRef_ != NULL;
    }
    
    void rec::NewRec(const char* id, const char *output, const int mindur, const int maxdur, const bool audio){
    void rec::NewRec(const char* id, const char *output, const int64_t &frameID, const int mindur, const int maxdur, const bool audio){
        std::string rid(id);
        std::string dir(output);
        
@@ -146,7 +146,7 @@
            if (map_rec_.find(rid) != map_rec_.end()){
                map_rec_.erase(rid);
            }
            map_rec_[rid] = startRec(rid, dir, mindur, maxdur, audio);
            map_rec_[rid] = startRec(rid, dir, frameID, mindur, maxdur, audio);
        }
        
    }
@@ -200,7 +200,7 @@
        if (recRef_){
            fps = recRef_->getFPS();
        }
        min_cache_len_ = (min + time_offset_) * fps;
        min_cache_len_ += min * fps;
    }
    int rec::shrinkCache(){