diff --git a/docs/static/frigate-api.yaml b/docs/static/frigate-api.yaml index 2e18cad6f..ee7b719ff 100644 --- a/docs/static/frigate-api.yaml +++ b/docs/static/frigate-api.yaml @@ -3133,6 +3133,7 @@ paths: duration: 30 include_recording: true draw: {} + pre_capture: null responses: "200": description: Successful Response @@ -4935,6 +4936,12 @@ components: - type: "null" title: Draw default: {} + pre_capture: + anyOf: + - type: integer + - type: "null" + title: Pre Capture Seconds + default: null type: object title: EventsCreateBody EventsDeleteBody: diff --git a/frigate/api/defs/request/events_body.py b/frigate/api/defs/request/events_body.py index 6110e34f5..a2df4d85f 100644 --- a/frigate/api/defs/request/events_body.py +++ b/frigate/api/defs/request/events_body.py @@ -34,6 +34,7 @@ class EventsCreateBody(BaseModel): duration: Optional[int] = 30 include_recording: Optional[bool] = True draw: Optional[dict] = {} + pre_capture: Optional[int] = None class EventsEndBody(BaseModel): diff --git a/frigate/api/event.py b/frigate/api/event.py index fc78ac0e5..256488984 100644 --- a/frigate/api/event.py +++ b/frigate/api/event.py @@ -1622,6 +1622,7 @@ def create_event( body.duration, "api", body.draw, + body.pre_capture, ), EventMetadataTypeEnum.manual_event_create.value, ) diff --git a/frigate/track/object_processing.py b/frigate/track/object_processing.py index 83b72d661..fd4a626c6 100644 --- a/frigate/track/object_processing.py +++ b/frigate/track/object_processing.py @@ -515,6 +515,7 @@ class TrackedObjectProcessor(threading.Thread): duration, source_type, draw, + pre_capture, ) = payload # save the snapshot image @@ -522,6 +523,7 @@ class TrackedObjectProcessor(threading.Thread): None, event_id, label, draw ) end_time = frame_time + duration if duration is not None else None + start_time = frame_time - self.config.cameras[camera_name].record.event_pre_capture if pre_capture is None else frame_time - pre_capture # send event to event maintainer self.event_sender.publish( @@ -536,7 +538,7 @@ class TrackedObjectProcessor(threading.Thread): "sub_label": sub_label, "score": score, "camera": camera_name, - "start_time": frame_time, + "start_time": start_time, "end_time": end_time, "has_clip": self.config.cameras[camera_name].record.enabled and include_recording,