From aa1aee230ff2e474482e6bf34b4eb33a3cd3f271 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 3 Jul 2024 08:54:46 -0400 Subject: [PATCH] If camera time jumps back more than 10 seconds, fail the capture. --- src/zm_ffmpeg_camera.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index aba3fe1a8..bf3eb8a87 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -258,11 +258,11 @@ int FfmpegCamera::Capture(std::shared_ptr &zm_packet) { // 32-bit wrap around? Info("Suspected 32bit wraparound in input pts. %" PRId64, packet->pts); return -1; - } else if (packet->pts - lastPTS < -20*stream->time_base.den) { - // -20 is for 20 seconds. Avigilon cameras seem to jump around by about 36 constantly + } else if (packet->pts - lastPTS < -10*stream->time_base.den) { + // -10 is for 10 seconds. Avigilon cameras seem to jump around by about 36 constantly double pts_time = static_cast(av_rescale_q(packet->pts, stream->time_base, AV_TIME_BASE_Q)) / AV_TIME_BASE; double last_pts_time = static_cast(av_rescale_q(lastPTS, stream->time_base, AV_TIME_BASE_Q)) / AV_TIME_BASE; - logPrintf(Logger::WARNING + monitor->Importance(), "Stream pts jumped back in time too far. pts %.2f - last pts %.2f = %.2f > 40seconds", + logPrintf(Logger::WARNING + monitor->Importance(), "Stream pts jumped back in time too far. pts %.2f - last pts %.2f = %.2f > 10seconds", pts_time, last_pts_time, pts_time - last_pts_time); if (error_count > 5) return -1;