From 1d2e7ce97e33c74a949d443a226df531fbf5c7dd Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期三, 25 九月 2019 14:04:09 +0800 Subject: [PATCH] bug fix --- csrc/wrapper.cpp | 8 ++++++-- csrc/ffmpeg/format/FormatOut.cpp | 11 ++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/csrc/ffmpeg/format/FormatOut.cpp b/csrc/ffmpeg/format/FormatOut.cpp index 6b6c38e..dce3f7e 100644 --- a/csrc/ffmpeg/format/FormatOut.cpp +++ b/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, diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp index f1520df..9af3085 100644 --- a/csrc/wrapper.cpp +++ b/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); -- Gitblit v1.8.0