| | |
| | | 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)); |
| | |
| | | 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, |
| | |
| | | |
| | | 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); |
| | | |