NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Use custom body for the export recordings endpoint (#14908)
Rui Alvesd2b2f3d54d20
diff --git a/docs/static/frigate-api.yaml b/docs/static/frigate-api.yamlindex 9a6364e271..325af28500 100644--- a/docs/static/frigate-api.yaml+++ b/docs/static/frigate-api.yaml@@ -7,7 +7,7 @@ info:servers:- url: https://demo.frigate.video/api- - url: http://localhost:5001/+ - url: http://localhost:5001/apipaths:/auth:@@ -296,7 +296,7 @@ paths:content:application/json:schema:- $ref: '#/components/schemas/ReviewSetMultipleReviewedBody'+ $ref: '#/components/schemas/ReviewModifyMultipleBody'responses:'200':description: Successful Response@@ -321,7 +321,7 @@ paths:content:application/json:schema:- $ref: '#/components/schemas/ReviewDeleteMultipleReviewsBody'+ $ref: '#/components/schemas/ReviewModifyMultipleBody'responses:'200':description: Successful Response@@ -1141,11 +1141,11 @@ paths:type: numbertitle: End TimerequestBody:+ required: truecontent:application/json:schema:- type: object- title: Body+ $ref: '#/components/schemas/ExportRecordingsBody'responses:'200':description: Successful Response@@ -1408,6 +1408,14 @@ paths:- type: number- type: 'null'title: Max Length+ - name: event_id+ in: query+ required: false+ schema:+ anyOf:+ - type: string+ - type: 'null'+ title: Event Id- name: sortin: queryrequired: false@@ -1518,7 +1526,7 @@ paths:anyOf:- type: string- type: 'null'- default: thumbnail,description+ default: thumbnailtitle: Search Type- name: include_thumbnailsin: query@@ -1590,6 +1598,22 @@ paths:- type: 'null'default: 00:00,24:00title: Time Range+ - name: has_clip+ in: query+ required: false+ schema:+ anyOf:+ - type: boolean+ - type: 'null'+ title: Has Clip+ - name: has_snapshot+ in: query+ required: false+ schema:+ anyOf:+ - type: boolean+ - type: 'null'+ title: Has Snapshot- name: timezonein: queryrequired: false@@ -2356,14 +2380,14 @@ paths:required: falseschema:type: number- default: 1729274204.653048+ default: 1731275308.238304title: After- name: beforein: queryrequired: falseschema:type: number- default: 1729277804.653095+ default: 1731278908.238313title: Beforeresponses:'200':@@ -3262,6 +3286,27 @@ components:required:- subLabeltitle: EventsSubLabelBody+ ExportRecordingsBody:+ properties:+ playback:+ allOf:+ - $ref: '#/components/schemas/PlaybackFactorEnum'+ title: Playback factor+ default: realtime+ source:+ allOf:+ - $ref: '#/components/schemas/PlaybackSourceEnum'+ title: Playback source+ default: recordings+ name:+ type: string+ maxLength: 256+ title: Friendly name+ image_path:+ type: string+ title: Image Path+ type: object+ title: ExportRecordingsBodyExtension:type: stringenum:@@ -3313,6 +3358,18 @@ components:- total_alert- total_detectiontitle: Last24HoursReview+ PlaybackFactorEnum:+ type: string+ enum:+ - realtime+ - timelapse_25x+ title: PlaybackFactorEnum+ PlaybackSourceEnum:+ type: string+ enum:+ - recordings+ - preview+ title: PlaybackSourceEnumRegenerateDescriptionEnum:type: stringenum:@@ -3336,7 +3393,7 @@ components:- motion- cameratitle: ReviewActivityMotionResponse- ReviewDeleteMultipleReviewsBody:+ ReviewModifyMultipleBody:properties:ids:items:@@ -3348,7 +3405,7 @@ components:type: objectrequired:- ids- title: ReviewDeleteMultipleReviewsBody+ title: ReviewModifyMultipleBodyReviewSegmentResponse:properties:id:@@ -3386,19 +3443,6 @@ components:- thumb_path- datatitle: ReviewSegmentResponse- ReviewSetMultipleReviewedBody:- properties:- ids:- items:- type: string- minLength: 1- type: array- minItems: 1- title: Ids- type: object- required:- - ids- title: ReviewSetMultipleReviewedBodyReviewSummaryResponse:properties:last24Hours:diff --git a/frigate/api/defs/__init__.py b/frigate/api/defs/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/frigate/api/defs/request/__init__.py b/frigate/api/defs/request/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/frigate/api/defs/request/export_recordinds_body.py b/frigate/api/defs/request/export_recordinds_body.pynew file mode 100644index 0000000000..eb6c151555--- /dev/null+++ b/frigate/api/defs/request/export_recordinds_body.py@@ -0,0 +1,20 @@+from typing import Union++from pydantic import BaseModel, Field+from pydantic.json_schema import SkipJsonSchema++from frigate.record.export import (+ PlaybackFactorEnum,+ PlaybackSourceEnum,+)+++class ExportRecordingsBody(BaseModel):+ playback: PlaybackFactorEnum = Field(+ default=PlaybackFactorEnum.realtime, title="Playback factor"+ )+ source: PlaybackSourceEnum = Field(+ default=PlaybackSourceEnum.recordings, title="Playback source"+ )+ name: str = Field(title="Friendly name", default=None, max_length=256)+ image_path: Union[str, SkipJsonSchema[None]] = Nonediff --git a/frigate/api/export.py b/frigate/api/export.pyindex c3299a4b04..1a360bb324 100644--- a/frigate/api/export.py+++ b/frigate/api/export.py@@ -4,13 +4,13 @@ import loggingimport randomimport stringfrom pathlib import Path-from typing import Optionalimport psutilfrom fastapi import APIRouter, Requestfrom fastapi.responses import JSONResponsefrom peewee import DoesNotExist+from frigate.api.defs.request.export_recordinds_body import ExportRecordingsBodyfrom frigate.api.defs.tags import Tagsfrom frigate.const import EXPORT_DIRfrom frigate.models import Export, Previews, Recordings@@ -37,7 +37,7 @@ def export_recording(camera_name: str,start_time: float,end_time: float,- body: dict = None,+ body: ExportRecordingsBody,):if not camera_name or not request.app.frigate_config.cameras.get(camera_name):return JSONResponse(@@ -47,18 +47,10 @@ def export_recording(status_code=404,)- json: dict[str, any] = body or {}- playback_factor = json.get("playback", "realtime")- playback_source = json.get("source", "recordings")- friendly_name: Optional[str] = json.get("name")-- if len(friendly_name or "") > 256:- return JSONResponse(- content=({"success": False, "message": "File name is too long."}),- status_code=401,- )-- existing_image = json.get("image_path")+ playback_factor = body.playback+ playback_source = body.source+ friendly_name = body.name+ existing_image = body.image_pathif playback_source == "recordings":recordings_count = (