mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-21 00:06:44 +01:00
Various fixes (#14703)
* Fix not retaining custom events * Fix media apis
This commit is contained in:
parent
885485da70
commit
ac8ddada0b
@ -917,7 +917,7 @@ def grid_snapshot(
|
|||||||
ret, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])
|
ret, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
jpg.tobytes,
|
jpg.tobytes(),
|
||||||
media_type="image/jpeg",
|
media_type="image/jpeg",
|
||||||
headers={"Cache-Control": "no-store"},
|
headers={"Cache-Control": "no-store"},
|
||||||
)
|
)
|
||||||
@ -1453,7 +1453,6 @@ def preview_thumbnail(file_name: str):
|
|||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
jpg_bytes,
|
jpg_bytes,
|
||||||
# FIXME: Shouldn't it be either jpg or webp depending on the endpoint?
|
|
||||||
media_type="image/webp",
|
media_type="image/webp",
|
||||||
headers={
|
headers={
|
||||||
"Content-Type": "image/webp",
|
"Content-Type": "image/webp",
|
||||||
@ -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])
|
ret, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
jpg.tobytes,
|
jpg.tobytes(),
|
||||||
media_type="image/jpeg",
|
media_type="image/jpeg",
|
||||||
headers={"Cache-Control": "no-store"},
|
headers={"Cache-Control": "no-store"},
|
||||||
)
|
)
|
||||||
@ -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])
|
_, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
jpg.tobytes,
|
jpg.tobytes(),
|
||||||
media_type="image/jpeg",
|
media_type="image/jpeg",
|
||||||
)
|
)
|
||||||
|
@ -94,3 +94,10 @@ class RecordConfig(FrigateBaseModel):
|
|||||||
enabled_in_config: Optional[bool] = Field(
|
enabled_in_config: Optional[bool] = Field(
|
||||||
default=None, title="Keep track of original state of recording."
|
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,
|
||||||
|
)
|
||||||
|
@ -70,7 +70,7 @@ class ExternalEventProcessor:
|
|||||||
"sub_label": sub_label,
|
"sub_label": sub_label,
|
||||||
"score": score,
|
"score": score,
|
||||||
"camera": camera,
|
"camera": camera,
|
||||||
"start_time": now,
|
"start_time": now - camera_config.record.event_pre_capture,
|
||||||
"end_time": end,
|
"end_time": end,
|
||||||
"thumbnail": thumbnail,
|
"thumbnail": thumbnail,
|
||||||
"has_clip": camera_config.record.enabled and include_recording,
|
"has_clip": camera_config.record.enabled and include_recording,
|
||||||
|
@ -299,16 +299,12 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
# if it doesn't overlap with an event, go ahead and drop the 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
|
# if it ends more than the configured pre_capture for the camera
|
||||||
else:
|
else:
|
||||||
pre_capture = max(
|
|
||||||
record_config.alerts.pre_capture,
|
|
||||||
record_config.detections.pre_capture,
|
|
||||||
)
|
|
||||||
camera_info = self.object_recordings_info[camera]
|
camera_info = self.object_recordings_info[camera]
|
||||||
most_recently_processed_frame_time = (
|
most_recently_processed_frame_time = (
|
||||||
camera_info[-1][0] if len(camera_info) > 0 else 0
|
camera_info[-1][0] if len(camera_info) > 0 else 0
|
||||||
)
|
)
|
||||||
retain_cutoff = datetime.datetime.fromtimestamp(
|
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)
|
).astimezone(datetime.timezone.utc)
|
||||||
if end_time < retain_cutoff:
|
if end_time < retain_cutoff:
|
||||||
Path(cache_path).unlink(missing_ok=True)
|
Path(cache_path).unlink(missing_ok=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user