Skip to content

Commit

Permalink
Fix shm count calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Sep 3, 2024
1 parent c0c65b7 commit 243eb79
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions frigate/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit 243eb79

Please sign in to comment.