From 243eb799e5564dd2415e9a027d5023501bbda28e Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 2 Sep 2024 17:58:52 -0600 Subject: [PATCH] Fix shm count calculation --- frigate/app.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index 5023e66218..538c459317 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -610,16 +610,21 @@ def check_shm(self) -> None: min_req_shm += 8 available_shm = total_shm - min_req_shm - cam_average_shm = 0 + cam_total_frame_size = 0 for camera in self.config.cameras.values(): - cam_average_shm += round( - (camera.detect.width * camera.detect.height * 1.5 + 270480) / 1048576, - 1, - ) + if camera.enabled: + cam_total_frame_size += round( + (camera.detect.width * camera.detect.height * 1.5 + 270480) / 1048576, + 1, + ) - self.shm_frame_count = max( - 50, int(available_shm / (cam_average_shm / len(self.config.cameras))) + self.shm_frame_count = min( + 50, int(available_shm / (cam_total_frame_size)) + ) + + logger.info( + f"Calculated total camera size {available_shm} / {cam_total_frame_size} :: {self.shm_frame_count} frames for each camera in SHM" ) logger.info( @@ -628,7 +633,7 @@ def check_shm(self) -> None: if self.shm_frame_count < 10: logger.warning( - f"The current SHM size of {total_shm}MB is too small, recommend increasing it to at least {round(min_req_shm + (cam_average_shm * 10))}MB." + f"The current SHM size of {total_shm}MB is too small, recommend increasing it to at least {round(min_req_shm + cam_total_frame_size)}MB." ) def init_auth(self) -> None: