diff --git a/src/zm_event.cpp b/src/zm_event.cpp index d353552ca..d4d4527ec 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -60,6 +60,7 @@ Event::Event( max_score(-1), //path(""), //snapshit_file(), + snapshot_file_written(false), //alarm_file(""), videoStore(nullptr), //video_name(""), @@ -450,10 +451,11 @@ void Event::AddFrame(const std::shared_ptr&packet) { } // end if save_jpegs // If this is the first frame, we should add a thumbnail to the event directory - if ((frames == 1) || (score > max_score)) { + if ((frames == 1) || (score > max_score) || (!snapshot_file_written)) { write_to_db = true; // web ui might show this as thumbnail, so db needs to know about it. Debug(1, "Writing snapshot to %s", snapshot_file.c_str()); WriteFrameImage(packet->image, packet->timestamp, snapshot_file.c_str()); + snapshot_file_written = true; } else { Debug(1, "Not Writing snapshot because frames %d score %d > max %d", frames, score, max_score); } diff --git a/src/zm_event.h b/src/zm_event.h index 9adc7da68..31a5a6355 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -86,6 +86,7 @@ class Event { int max_score; std::string path; std::string snapshot_file; + bool snapshot_file_written; std::string alarm_file; VideoStore *videoStore;