From b8bd4b6961361aa6a8eb88206d2bc1f7f27e8463 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 2 Nov 2020 16:34:00 -0500 Subject: [PATCH] Add fallback for now to endtime. Set endtime in AddFramesInternal as well just in case there was never another frame. --- src/zm_event.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index f5d93f151..e762698fa 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -256,6 +256,11 @@ Event::~Event() { videowriter = nullptr; } + // endtime is set in AddFrame, so SHOULD be set to the value of the last frame timestamp. + if ( ! end_time.tv_sec ) { + Warning("Empty endtime for event. Should not happen. Setting to now."); + gettimeofday(&end_time, nullptr); + } struct DeltaTimeval delta_time; DELTA_TIMEVAL(delta_time, end_time, start_time, DT_PREC_2); Debug(2, "start_time:%d.%d end_time%d.%d", start_time.tv_sec, start_time.tv_usec, end_time.tv_sec, end_time.tv_usec); @@ -569,6 +574,7 @@ void Event::AddFramesInternal(int n_frames, int start_frame, Image **images, str } else { Debug(1, "No valid pre-capture frames to add"); } + end_time = *timestamps[n_frames-1]; } // void Event::AddFramesInternal(int n_frames, int start_frame, Image **images, struct timeval **timestamps) void Event::WriteDbFrames() {