video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-09-25 1d2e7ce97e33c74a949d443a226df531fbf5c7dd
bug fix
2个文件已修改
19 ■■■■ 已修改文件
csrc/ffmpeg/format/FormatOut.cpp 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/wrapper.cpp 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/ffmpeg/format/FormatOut.cpp
@@ -393,9 +393,8 @@
        in_stream = in_ctx_->streams[pkt->stream_index];
        out_stream = ctx_->streams[pkt->stream_index];
        
        // if (type == "audio")
        // logIt("BEFORE stream %d type: %s, pts: %lld, dts: %lld, duration: %lld",
        // pkt.stream_index, type.c_str(), pkt.pts, pkt.pts, pkt.duration);
        // logIt("BEFORE stream %d, pts: %lld, dts: %lld, duration: %lld",
        // pkt->stream_index, pkt->pts, pkt->dts, pkt->duration);
        //转换 PTS/DTS 时序
        pkt->pts = av_rescale_q_rnd(pkt->pts,in_stream->time_base,out_stream->time_base,(enum AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
@@ -403,10 +402,8 @@
        pkt->duration = av_rescale_q(pkt->duration, in_stream->time_base, out_stream->time_base); 
        pkt->pos = -1;  
        // if (type == "audio")
        // logIt("AFTER stream %d type: %s, pts: %lld, dts: %lld, duration: %lld",
        // pkt.stream_index, type.c_str(), pkt.pts, pkt.pts, pkt.duration);
        // logIt("AFTER stream %d, pts: %lld, dts: %lld, duration: %lld",
        // pkt->stream_index, pkt->pts, pkt->dts, pkt->duration);
    }
    bool FormatOut::writeFrame(AVPacket *pkt, const int64_t &frame_cnt,
csrc/wrapper.cpp
@@ -170,14 +170,18 @@
            init_worker(in.get());
            int64_t id = 0;
            int64_t id = -1;
            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 (id < 0){
                    id++;
                    continue;
                }
                run_worker(in.get(), data, id);
                usleep(wTime);