From 76267bc57f48ec4ab4fda7cf506aeff25db6d35b Mon Sep 17 00:00:00 2001
From: Isaac Connor <isaac@zoneminder.com>
Date: Tue, 16 Mar 2021 12:08:11 -0400
Subject: [PATCH] put back deleting the raw image when not saving jpegs.  We
 only need it for the snapshot and that should be the alarmed image anyways.

---
 src/zm_monitor.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp
index 0ea6b5fb6..4097036ae 100644
--- a/src/zm_monitor.cpp
+++ b/src/zm_monitor.cpp
@@ -2286,6 +2286,15 @@ bool Monitor::Analyse() {
 
   if (event) event->AddPacket(snap);
 
+  // In the case where people have pre-alarm frames, the web ui will generate the frame images
+  // from the mp4. So no one will notice anyways.
+  if ((videowriter == PASSTHROUGH) and !savejpegs) {
+    Debug(1, "Deleting image data for %d", snap->image_index);
+    // Don't need raw images anymore
+    delete snap->image;
+    snap->image = nullptr;
+  }
+
   // popPacket will have placed a second lock on snap, so release it here.
   delete packet_lock;