From f90150cf116742d07b33a29cf1582091dbfa43ea Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 10 Jun 2024 19:11:03 -0400 Subject: [PATCH] When dts==last_dts, don't log it as an error. It is too common. Just add duration and move on. --- src/zm_videostore.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 42ab54369..89b93f1c3 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -1384,12 +1384,20 @@ int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) { } pkt->dts = last_dts[stream->index]; } else { - if ((last_dts[stream->index] != AV_NOPTS_VALUE) and (pkt->dts <= last_dts[stream->index])) { - Warning("non increasing dts, fixing. our dts %" PRId64 " stream %d last_dts %" PRId64 ". reorder_queue_size=%zu", - pkt->dts, stream->index, last_dts[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]; - if (pkt->dts > pkt->pts) pkt->pts = pkt->dts; // Do it here to avoid warning below + if (last_dts[stream->index] != AV_NOPTS_VALUE) { + if (pkt->dts < last_dts[stream->index]) { + Warning("non increasing dts, fixing. our dts %" PRId64 " stream %d last_dts %" PRId64 ". reorder_queue_size=%zu", + pkt->dts, stream->index, last_dts[stream->index], reorder_queue_size); + pkt->dts = last_dts[stream->index]+last_duration[stream->index]; + if (pkt->dts > pkt->pts) pkt->pts = pkt->dts; // Do it here to avoid warning below + } else if (pkt->dts == last_dts[stream->index]) { + // Commonly seen + Debug(1, "non increasing dts, fixing. our dts %" PRId64 " stream %d last_dts %" PRId64 ". reorder_queue_size=%zu", + pkt->dts, stream->index, last_dts[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]; + if (pkt->dts > pkt->pts) pkt->pts = pkt->dts; // Do it here to avoid warning below + } } next_dts[stream->index] = pkt->dts + pkt->duration; last_dts[stream->index] = pkt->dts;