update plugins/publish/publish_node.cpp

This commit is contained in:
sladro 2025-12-16 17:10:03 +08:00
parent ff3c00be9b
commit c29def9254

View File

@ -136,8 +136,14 @@ public:
std::memcpy(out.data, pkt.data.data(), pkt.data.size());
out.stream_index = stream_->index;
out.flags = pkt.key ? AV_PKT_FLAG_KEY : 0;
out.pts = av_rescale_q(pkt.pts_ms, AVRational{1, 1000}, stream_->time_base);
out.dts = out.pts;
int64_t pts = av_rescale_q(pkt.pts_ms, AVRational{1, 1000}, stream_->time_base);
// Ensure monotonically increasing PTS/DTS
if (pts <= last_pts_) {
pts = last_pts_ + 1;
}
last_pts_ = pts;
out.pts = pts;
out.dts = pts;
out.duration = av_rescale_q(1000 / std::max(1, fps_), AVRational{1, 1000}, stream_->time_base);
int ret = av_interleaved_write_frame(fmt_, &out);
@ -203,6 +209,7 @@ private:
bool ready_ = false;
bool warned_ = false;
uint64_t write_count_ = 0;
int64_t last_pts_ = -1;
};
class AvMuxerManager {