Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #14703

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions frigate/api/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ def grid_snapshot(
ret, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])

return Response(
jpg.tobytes,
jpg.tobytes(),
media_type="image/jpeg",
headers={"Cache-Control": "no-store"},
)
Expand Down Expand Up @@ -1453,7 +1453,6 @@ def preview_thumbnail(file_name: str):

return Response(
jpg_bytes,
# FIXME: Shouldn't it be either jpg or webp depending on the endpoint?
media_type="image/webp",
headers={
"Content-Type": "image/webp",
Expand Down Expand Up @@ -1482,7 +1481,7 @@ def label_thumbnail(request: Request, camera_name: str, label: str):
ret, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])

return Response(
jpg.tobytes,
jpg.tobytes(),
media_type="image/jpeg",
headers={"Cache-Control": "no-store"},
)
Expand Down Expand Up @@ -1535,6 +1534,6 @@ def label_snapshot(request: Request, camera_name: str, label: str):
_, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])

return Response(
jpg.tobytes,
jpg.tobytes(),
media_type="image/jpeg",
)
7 changes: 7 additions & 0 deletions frigate/config/camera/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ class RecordConfig(FrigateBaseModel):
enabled_in_config: Optional[bool] = Field(
default=None, title="Keep track of original state of recording."
)

@property
def event_pre_capture(self) -> int:
return max(
self.alerts.pre_capture,
self.detections.pre_capture,
)
2 changes: 1 addition & 1 deletion frigate/events/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_manual_event(
"sub_label": sub_label,
"score": score,
"camera": camera,
"start_time": now,
"start_time": now - camera_config.record.event_pre_capture,
"end_time": end,
"thumbnail": thumbnail,
"has_clip": camera_config.record.enabled and include_recording,
Expand Down
6 changes: 1 addition & 5 deletions frigate/record/maintainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,12 @@ async def validate_and_move_segment(
# if it doesn't overlap with an event, go ahead and drop the segment
# if it ends more than the configured pre_capture for the camera
else:
pre_capture = max(
record_config.alerts.pre_capture,
record_config.detections.pre_capture,
)
camera_info = self.object_recordings_info[camera]
most_recently_processed_frame_time = (
camera_info[-1][0] if len(camera_info) > 0 else 0
)
retain_cutoff = datetime.datetime.fromtimestamp(
most_recently_processed_frame_time - pre_capture
most_recently_processed_frame_time - record_config.event_pre_capture
).astimezone(datetime.timezone.utc)
if end_time < retain_cutoff:
Path(cache_path).unlink(missing_ok=True)
Expand Down