From 36e5ab9cdf3a4fa1c86863439534756af40c4df4 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 30 Nov 2024 11:10:17 -0700 Subject: [PATCH 1/4] Use env var to control max number of frames --- frigate/app.py | 6 +++++- frigate/const.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frigate/app.py b/frigate/app.py index 6518c1ddf0..2f7541cf9c 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -36,6 +36,7 @@ EXPORT_DIR, MODEL_CACHE_DIR, RECORD_DIR, + SHM_FRAMES_VAR, ) from frigate.db.sqlitevecq import SqliteVecQueueDatabase from frigate.embeddings import EmbeddingsContext, manage_embeddings @@ -523,7 +524,10 @@ def shm_frame_count(self) -> int: if cam_total_frame_size == 0.0: return 0 - shm_frame_count = min(200, int(available_shm / (cam_total_frame_size))) + shm_frame_count = min( + os.environ.get(SHM_FRAMES_VAR, 50), + int(available_shm / (cam_total_frame_size)), + ) logger.debug( f"Calculated total camera size {available_shm} / {cam_total_frame_size} :: {shm_frame_count} frames for each camera in SHM" diff --git a/frigate/const.py b/frigate/const.py index c83b10e73a..5976f47b1d 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -13,6 +13,8 @@ PLUS_ENV_VAR = "PLUS_API_KEY" PLUS_API_HOST = "https://api.frigate.video" +SHM_FRAMES_VAR = "SHM_MAX_FRAMES" + # Attribute & Object constants DEFAULT_ATTRIBUTE_LABEL_MAP = { From 76a9742ddcfe168b61217c98c96765ce3d778c16 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 1 Dec 2024 07:32:30 -0700 Subject: [PATCH 2/4] Handle type --- frigate/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frigate/app.py b/frigate/app.py index 2f7541cf9c..ba82757f99 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -525,7 +525,7 @@ def shm_frame_count(self) -> int: return 0 shm_frame_count = min( - os.environ.get(SHM_FRAMES_VAR, 50), + int(os.environ.get(SHM_FRAMES_VAR, "50")), int(available_shm / (cam_total_frame_size)), ) From 4116ef8c100a5c483e1ce206227b25069ddcb36d Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 1 Dec 2024 07:40:44 -0700 Subject: [PATCH 3/4] Fix frame_name not being sent --- frigate/review/maintainer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frigate/review/maintainer.py b/frigate/review/maintainer.py index 23a42e7a7a..ee4bfff18c 100644 --- a/frigate/review/maintainer.py +++ b/frigate/review/maintainer.py @@ -480,7 +480,7 @@ def run(self) -> None: if not self.config.cameras[camera].record.enabled: if current_segment: - self.update_existing_segment(current_segment, frame_time, []) + self.update_existing_segment(current_segment, frame_name, frame_time, []) continue From d322989a19d0d85d37884b040005f2888c5e043c Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 1 Dec 2024 07:41:40 -0700 Subject: [PATCH 4/4] Formatting --- frigate/review/maintainer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frigate/review/maintainer.py b/frigate/review/maintainer.py index ee4bfff18c..de137cb268 100644 --- a/frigate/review/maintainer.py +++ b/frigate/review/maintainer.py @@ -480,7 +480,9 @@ def run(self) -> None: if not self.config.cameras[camera].record.enabled: if current_segment: - self.update_existing_segment(current_segment, frame_name, frame_time, []) + self.update_existing_segment( + current_segment, frame_name, frame_time, [] + ) continue