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>
@@ -197,13 +198,14 @@
            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>());
                if (in->readPacket(&data->getAVPacket()) != 0){
                    logIt("read packet error, id: %lld", id);
                    break;
                }
                if (in->notVideoAudio(&data->getAVPacket())){
                    continue;
                }
@@ -212,11 +214,15 @@
                    id++;
                    continue;
                }
               // decode error
                if (run_worker(in.get(), data, id) == -1){
                    break;
                }
                // usleep(wTime);
                if (exist){
                    usleep(wTime);
                }
                id++;
            }