From d2a26aee590cf1a4aa04de5e8c84e14b574bf403 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 7 Mar 2026 11:09:43 -0500 Subject: [PATCH] fix: use +1 instead of +last_duration for equal DTS fixup When two packets have the same DTS (common with B-frames near keyframes), bumping by last_duration overshoots and causes a cascading misalignment where every subsequent packet triggers a "non increasing dts" warning with a growing gap. The comment already said "add 1" but the code used last_duration. Co-Authored-By: Claude Opus 4.6 --- src/zm_videostore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 6fd634773..f69f38743 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -1497,7 +1497,7 @@ int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) { Debug(1, "non increasing dts, fixing. our dts %" PRId64 " stream %d last_dts %" PRId64 " stream %d. reorder_queue_size=%zu", pkt->dts, stream->index, last_dts[stream->index], stream->index, reorder_queue_size); // dts MUST monotonically increase, so add 1 which should be a small enough time difference to not matter. - pkt->dts = last_dts[stream->index]+last_duration[stream->index]; + pkt->dts = last_dts[stream->index]+1; if (pkt->dts > pkt->pts) pkt->pts = pkt->dts; // Do it here to avoid warning below } }