video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-10-19 6de0bbb3eb860934bbe1c5e53a7ff02b8c0844f5
csrc/wrapper.cpp
@@ -2,6 +2,7 @@
#include <thread>
#include <unistd.h>
#include <sys/time.h>
extern "C"{
#include <libavformat/avformat.h>
@@ -196,6 +197,8 @@
            init_worker(in.get());
            int64_t id = gb_ ? 0 : -1;
            bool exist = access(input_url_.c_str(), 0) == 0 ? true : false;
            while(!stop_stream_.load()){
                auto data(std::make_shared<CodedData>());
@@ -203,20 +206,23 @@
                    logIt("read packet error, id: %lld", id);
                    break;
                }
                if (in->notVideoAudio(&data->getAVPacket())){
                    continue;
                }
                if (!gb_ && id < 0){
                    id++;
                    continue;
                }
               // decode error
                if (run_worker(in.get(), data, id) == -1){
                    break;
                }
                // usleep(wTime);
                if (exist){
                    usleep(wTime);
                }
                id++;
            }
@@ -228,7 +234,7 @@
    void Wrapper::SetRecMinCacheTime(const int mind){
        rec_->SetRecMinCacheTime(mind);
    }
    void Wrapper::BuildRecorder(const char* id, const char *output, const int mindur, const int maxdur, const bool audio){
        bool a = audio;
        if (gb_) a = false;