Skip to content

Commit

Permalink
SHM tweaks (#15274)
Browse files Browse the repository at this point in the history
* Use env var to control max number of frames

* Handle type

* Fix frame_name not being sent

* Formatting
  • Loading branch information
NickM-27 authored Dec 1, 2024
1 parent 5802a66 commit 002fdea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion frigate/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
int(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"
Expand Down
2 changes: 2 additions & 0 deletions frigate/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion frigate/review/maintainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_time, [])
self.update_existing_segment(
current_segment, frame_name, frame_time, []
)

continue

Expand Down

2 comments on commit 002fdea

@kdill00
Copy link

@kdill00 kdill00 commented on 002fdea Dec 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After one of these recent builds, any cameras named like so:

cameraname < —— fails to get frames
cameraname2

The first one will fail to get the detect stream with a generic unable to read frames from the ffmpeg process. adding a character to the first one fixes it.

cameraname1 < —— works
cameraname2

I have multiple cameras named in this manner, I am okay if this is expected behavior moving forward but i just wanted to note it somewhere.

@NickM-27
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is a known issue, we should be able to make a tweak to fix this

Please sign in to comment.