mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 05:35:25 +03:00
added preview.gif for label
This commit is contained in:
parent
63d81bef45
commit
11d77964c3
@ -195,6 +195,10 @@ Returns the thumbnail from the latest event for the given camera and label combo
|
||||
|
||||
Returns the clip from the latest event for the given camera and label combo. Using `any` as the label will return the latest clip regardless of type.
|
||||
|
||||
### `GET /api/<camera_name>/<label>/preview.gif`
|
||||
|
||||
Returns the Gif covering the first 20 seconds of the latest event for the given camera and label combo. Using `any` as the label will return the latest Gif regardless of type.
|
||||
|
||||
### `GET /api/<camera_name>/<label>/snapshot.jpg`
|
||||
|
||||
Returns the snapshot image from the latest event for the given camera and label combo. Using `any` as the label will return the latest thumbnail regardless of type.
|
||||
|
||||
@ -724,6 +724,28 @@ def label_clip(camera_name, label):
|
||||
return make_response(
|
||||
jsonify({"success": False, "message": "Event not found"}), 404
|
||||
)
|
||||
|
||||
@MediaBp.route("/<camera_name>/<label>/preview.gif")
|
||||
def label_preview(camera_name, label):
|
||||
label = unquote(label)
|
||||
event_query = Event.select(fn.MAX(Event.id), Event.start_time, Event.end_time, Event.camera).where(
|
||||
Event.camera == camera_name
|
||||
)
|
||||
if label != "any":
|
||||
event_query = event_query.where(Event.label == label)
|
||||
|
||||
try:
|
||||
event = event_query.get()
|
||||
|
||||
|
||||
except DoesNotExist:
|
||||
return make_response(
|
||||
jsonify({"success": False, "message": "Event not found"}), 404
|
||||
)
|
||||
|
||||
start_ts = event.start_time
|
||||
end_ts = start_ts + (min(event.end_time - event.start_time, 20) if event.end_time else 20)
|
||||
return preview_gif(event.camera, start_ts, end_ts)
|
||||
|
||||
|
||||
@MediaBp.route("/<camera_name>/grid.jpg")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user