From 5b903d8f20b5c68ade174a6751922d48531bee6a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 8 May 2023 10:21:46 -0400 Subject: [PATCH] Add a detection for when keyframe interval backlog causes large time gap between first and second frames added to event. --- src/zm_monitor.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index e8c48ff42..f1120d135 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2219,14 +2219,30 @@ bool Monitor::Analyse() { event->updateNotes(noteSetMap); } else if (state == TAPE || state == IDLE) { if (event) { - if (section_length >= Seconds(min_section_length) && (event->Duration() >= section_length)) { - Debug(1, "%s: event %" PRIu64 ", has exceeded desired section length. %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64, - name.c_str(), event->Id(), - static_cast(std::chrono::duration_cast(snap->timestamp.time_since_epoch()).count()), - static_cast(std::chrono::duration_cast(event->StartTime().time_since_epoch()).count()), - static_cast(std::chrono::duration_cast(event->Duration()).count()), - static_cast(Seconds(section_length).count())); - closeEvent(); + if ( + section_length >= Seconds(min_section_length) + && + (event->Duration() >= section_length) + ) { + if (event->Frames() < min_section_length) { + /* This is a detection for the case where huge keyframe + * intervals cause a huge time gap between the first + * frame and second frame */ + Warning("%s: event %" PRIu64 ", has exceeded desired section length. %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64, + name.c_str(), event->Id(), + static_cast(std::chrono::duration_cast(snap->timestamp.time_since_epoch()).count()), + static_cast(std::chrono::duration_cast(event->StartTime().time_since_epoch()).count()), + static_cast(std::chrono::duration_cast(event->Duration()).count()), + static_cast(Seconds(section_length).count())); + } else { + Debug(1, "%s: event %" PRIu64 ", has exceeded desired section length. %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64, + name.c_str(), event->Id(), + static_cast(std::chrono::duration_cast(snap->timestamp.time_since_epoch()).count()), + static_cast(std::chrono::duration_cast(event->StartTime().time_since_epoch()).count()), + static_cast(std::chrono::duration_cast(event->Duration()).count()), + static_cast(Seconds(section_length).count())); + closeEvent(); + } } } } // end if state machine