mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-19 19:06:16 +01:00
store start/end event with pre/post capture to avoid expiring wanted recordings
This commit is contained in:
parent
5a209caed3
commit
89e317a6bb
@ -6,12 +6,12 @@ import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from frigate.config import FrigateConfig, RecordConfig
|
||||
from frigate.const import CLIPS_DIR
|
||||
from frigate.models import Event, Recordings
|
||||
|
||||
from peewee import fn
|
||||
|
||||
from frigate.config import EventsConfig, FrigateConfig, RecordConfig
|
||||
from frigate.const import CLIPS_DIR
|
||||
from frigate.models import Event
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -74,17 +74,17 @@ class EventProcessor(threading.Thread):
|
||||
self.events_in_process[event_data["id"]] = event_data
|
||||
|
||||
if event_type == "end":
|
||||
record_config: RecordConfig = self.config.cameras[camera].record
|
||||
|
||||
has_clip = self.should_create_clip(camera, event_data)
|
||||
|
||||
event_config: EventsConfig = self.config.cameras[camera].record.events
|
||||
|
||||
if has_clip or event_data["has_snapshot"]:
|
||||
Event.create(
|
||||
id=event_data["id"],
|
||||
label=event_data["label"],
|
||||
camera=camera,
|
||||
start_time=event_data["start_time"],
|
||||
end_time=event_data["end_time"],
|
||||
start_time=event_data["start_time"] - event_config.pre_capture,
|
||||
end_time=event_data["end_time"] + event_config.post_capture,
|
||||
top_score=event_data["top_score"],
|
||||
false_positive=event_data["false_positive"],
|
||||
zones=list(event_data["entered_zones"]),
|
||||
|
@ -242,14 +242,11 @@ def event_clip(id):
|
||||
if not event.has_clip:
|
||||
return "Clip not available", 404
|
||||
|
||||
event_config = current_app.frigate_config.cameras[event.camera].record.events
|
||||
start_ts = event.start_time - event_config.pre_capture
|
||||
end_ts = event.end_time + event_config.post_capture
|
||||
file_name = f"{event.camera}-{id}.mp4"
|
||||
clip_path = os.path.join(CLIPS_DIR, file_name)
|
||||
|
||||
if not os.path.isfile(clip_path):
|
||||
return recording_clip(event.camera, start_ts, end_ts)
|
||||
return recording_clip(event.camera, event.start_time, event.end_time)
|
||||
|
||||
response = make_response()
|
||||
response.headers["Content-Description"] = "File Transfer"
|
||||
@ -697,15 +694,12 @@ def vod_event(id):
|
||||
if not event.has_clip:
|
||||
return "Clip not available", 404
|
||||
|
||||
event_config = current_app.frigate_config.cameras[event.camera].record.events
|
||||
start_ts = event.start_time - event_config.pre_capture
|
||||
end_ts = event.end_time + event_config.post_capture
|
||||
clip_path = os.path.join(CLIPS_DIR, f"{event.camera}-{id}.mp4")
|
||||
|
||||
if not os.path.isfile(clip_path):
|
||||
return vod_ts(event.camera, start_ts, end_ts)
|
||||
return vod_ts(event.camera, event.start_time, event.end_time)
|
||||
|
||||
duration = int((end_ts - start_ts) * 1000)
|
||||
duration = int((event.end_time - event.start_time) * 1000)
|
||||
return jsonify(
|
||||
{
|
||||
"cache": True,
|
||||
|
Loading…
Reference in New Issue
Block a user