Compare commits

..

92 Commits

Author SHA1 Message Date
Blake Blackshear
ad4929c621 increment motionless_count 2022-02-06 14:50:15 -06:00
Blake Blackshear
9a0d276761 allow motion based retention when detect is disabled 2022-02-06 14:49:54 -06:00
Blake Blackshear
24f9937009 fix resolution on reolink example 2022-02-06 14:15:19 -06:00
Blake Blackshear
4e23967442 clarify addon versions 2022-02-06 14:15:06 -06:00
Blake Blackshear
acc1022998 remove outdated output args tip 2022-02-06 14:02:18 -06:00
Blake Blackshear
02c91d4c51 clarify that zones are based on the bottom center 2022-02-06 14:00:27 -06:00
Blake Blackshear
5e156f8151 update addon urls 2022-02-06 13:56:09 -06:00
Blake Blackshear
47e0e1d221 add example for ios camera live feed notification 2022-02-06 13:46:57 -06:00
Blake Blackshear
f57501d033 avoid rare divide by zero 2022-02-06 13:28:53 -06:00
Blake Blackshear
1a3f21e5c1 note for future 2022-02-06 13:28:45 -06:00
Blake Blackshear
5a2076fcab improve warning for retain modes 2022-02-06 10:12:49 -06:00
Blake Blackshear
2d5ec25dca invert active_count logic 2022-02-06 09:56:06 -06:00
Blake Blackshear
499f75e165 set has_clip to false when recordings fail 2022-02-06 09:49:01 -06:00
Blake Blackshear
3600ebca39 adjust error messages on ffmpeg crash 2022-02-06 08:46:41 -06:00
Blake Blackshear
50b5d40c10 add stacktrace to config validation errors 2022-02-06 08:40:24 -06:00
Blake Blackshear
21f1a98da4 add new properties to the docs 2022-02-06 08:17:46 -06:00
Blake Blackshear
21cc29be6f add additional info for non-H264 cameras 2022-02-06 07:57:36 -06:00
Blake Blackshear
794a9ff162 upgrade npm in dev container 2022-02-06 07:57:17 -06:00
Blake Blackshear
7b4cb95825 package updates for docs 2022-02-06 07:57:07 -06:00
Blake Blackshear
b1e84ca7fe allow dash in camera name 2022-02-05 14:31:06 -06:00
Blake Blackshear
e6ec5cb097 make motion the default retain mode 2022-02-05 09:38:22 -06:00
Blake Blackshear
23c70acd51 update stationary interval docs 2022-02-05 09:38:22 -06:00
Blake Blackshear
091648187f make expire interval configurable for users wanting to minimize i/o 2022-02-05 09:38:22 -06:00
Blake Blackshear
2b7d38f947 avoid extra tracking work on stationary frames 2022-02-05 09:38:22 -06:00
Blake Blackshear
f801930588 use iou instead of centroid 2022-02-05 09:38:22 -06:00
Blake Blackshear
955c2779d9 dont stop scanning when there are other regions 2022-02-05 09:38:22 -06:00
Blake Blackshear
037f8667a6 default periodic checks to never 2022-02-05 09:38:22 -06:00
Blake Blackshear
307068a61f scan the frame on startup 2022-02-05 09:38:22 -06:00
Blake Blackshear
077d900b44 require a position change to be an active object 2022-02-05 09:38:22 -06:00
Blake Blackshear
92f9195075 randomize the region multiplier for variation 2022-02-05 09:38:22 -06:00
Blake Blackshear
82c60093d1 improve method for determining position
compares the centroid to a history of bounding boxes
2022-02-05 09:38:22 -06:00
Blake Blackshear
944b9181e0 if recording not on disk, delete from db and return 2022-02-05 09:38:22 -06:00
Blake Blackshear
326b368e82 cleanup clean snapshots on event deletion too 2022-02-05 09:38:22 -06:00
Blake Blackshear
040d8c9778 require url safe camera names 2022-02-05 09:38:22 -06:00
Bernt Christian Egeland
273f803c7c Event Datepicker (#2428)
* new datepicker

* dev

* dev

* dev

* fix for version 0.10

* added rounded corners for date range

* lint

* Commented out some Select.test.

* improved date range selection

* improved functions with useCallback

* improved Select.test.jsx

* keyboard navigation

* keyboard navigation

* added dropdown menu icon

* Hide filters on xs, Button to show

* check if to far left before right

* Filter button text

* improved local timezone
2022-02-02 07:26:45 -06:00
Yuriy Sannikov
bd8e23833c Run python unit tests in a github actions (#2589)
* tox tests initial commit

* run tests in the Dockerfile during the build phase

* remove local tests

Co-authored-by: YS <ys@gm.com>
2022-01-14 07:31:25 -06:00
Yuriy Sannikov
9edf38347c safe refactoring (#2552)
Co-authored-by: YS <ys@gm.com>
2021-12-31 11:59:43 -06:00
TJ Horner
1569ce7cf6 Change JPEG mime type (#2543) 2021-12-30 17:03:29 -06:00
Blake Blackshear
db1255aa7f disable disk sync on startup 2021-12-13 06:51:03 -06:00
Blake Blackshear
609b436ed8 fix migrations 2021-12-13 06:50:06 -06:00
Blake Blackshear
95bdf9fe34 check for apex dir 2021-12-12 10:27:01 -06:00
Ryan McLean
251d29aa38 #2117 change entered_zones from set to list so that they are not automatically alphabetically ordered (#2212) 2021-12-12 09:29:57 -06:00
Justin Goette
156e1a4dc2 Allow for ".yaml" (#2244)
* allow for ".yaml"

* remove unused import
2021-12-12 09:27:05 -06:00
Matt Clayton
a5c13e7455 Add temperature of coral tpu to telemetry mqtt message 2021-12-12 09:22:32 -06:00
Blake Blackshear
fcb4aaef0d limit vod response cache 2021-12-12 09:21:45 -06:00
Blake Blackshear
589432bc89 update docs 2021-12-12 09:21:45 -06:00
Blake Blackshear
b19a02888a expire overlapping segments based on mode 2021-12-12 09:21:45 -06:00
Blake Blackshear
18fd50dfce store objects and motion counts in the db 2021-12-12 09:21:45 -06:00
Blake Blackshear
df0246aed8 warn when retention mismatch 2021-12-12 09:21:45 -06:00
Blake Blackshear
cbb2882123 refactor segment stats logic 2021-12-12 09:21:45 -06:00
Blake Blackshear
9f18629df3 switch to retain config instead of retain_days 2021-12-12 09:21:45 -06:00
Blake Blackshear
63f8034e46 pass processed tracked objects 2021-12-12 09:21:45 -06:00
Blake Blackshear
f3efc0667f retain frame data for recording maintenance 2021-12-12 09:21:45 -06:00
Blake Blackshear
af001321a8 fix process_clip 2021-12-12 09:21:45 -06:00
Blake Blackshear
92e08b92f5 sync recordings with disk once on startup 2021-12-12 09:21:45 -06:00
Blake Blackshear
26241b0877 no need to expire recordings every minute 2021-12-12 09:21:45 -06:00
Blake Blackshear
c1155af169 ensure cache copies when events have ended 2021-11-21 09:43:37 -06:00
Blake Blackshear
77c1f1bb1b cleanup missing files from database once per hour 2021-11-21 07:55:35 -06:00
Blake Blackshear
ae3c01fe2d handle missing file edge case 2021-11-21 07:26:31 -06:00
Blake Blackshear
7a2a85d253 log error messages on vod endpoints 2021-11-21 07:25:36 -06:00
Blake Blackshear
77c66d4e49 ensure duration > 0 for segments 2021-11-21 07:25:01 -06:00
Blake Blackshear
494e5ac4ec use snapshot url to support in progress events 2021-11-20 09:52:02 -06:00
Blake Blackshear
63b7465452 ensure stationary interval is greater than 0 2021-11-20 09:15:03 -06:00
Blake Blackshear
e6d2df5661 add duration to cache 2021-11-19 16:56:00 -06:00
Blake Blackshear
a3301e0347 avoid running ffprobe for each segment multiple times 2021-11-19 07:28:51 -06:00
Blake Blackshear
3d556cc2cb warn if no wait time 2021-11-19 07:19:14 -06:00
Blake Blackshear
585efe1a0f keep 5 segments in cache 2021-11-19 07:16:29 -06:00
Blake Blackshear
c7d47439dd better cache handling 2021-11-17 08:57:57 -06:00
Blake Blackshear
19a6978228 avoid proactive messages with retain_days 0 and handle first pass 2021-11-17 07:44:58 -06:00
Blake Blackshear
1ebb8a54bf avoid divide by zero 2021-11-17 07:29:23 -06:00
Blake Blackshear
ae968044d6 revert switch to b/w frame prep 2021-11-17 07:28:53 -06:00
Blake Blackshear
b912851e49 fix default motion comment 2021-11-15 06:54:03 -06:00
Blake Blackshear
14c74e4361 more robust cache management 2021-11-10 21:12:41 -06:00
Blake Blackshear
51fb532e1a set retain when setting switches from frontend 2021-11-09 07:40:23 -06:00
Blake Blackshear
3541f966e3 error handling for the recording maintainer 2021-11-09 07:05:21 -06:00
Blake Blackshear
c7faef8faa don't modify ffmpeg_cmd object 2021-11-08 19:05:39 -06:00
Blake Blackshear
cdd3000315 fix ffmpeg config for env vars 2021-11-08 18:20:47 -06:00
Blake Blackshear
1c1c28d0e5 create ffmpeg commands on startup 2021-11-08 07:36:21 -06:00
Blake Blackshear
4422e86907 clarify shm in docs 2021-11-08 07:36:21 -06:00
Blake Blackshear
8f43a2d109 use resolution of clip 2021-11-08 07:36:21 -06:00
Blake Blackshear
bd7755fdd3 revamp process clip 2021-11-08 07:36:21 -06:00
Blake Blackshear
d554175631 no longer make motion settings dynamic 2021-11-08 07:36:21 -06:00
Blake Blackshear
ff667b019a remove min frame height of 180 and increase contour area 2021-11-08 07:36:21 -06:00
Blake Blackshear
57dcb29f8b consolidate regions 2021-11-08 07:36:21 -06:00
Blake Blackshear
9dc6c423b7 improve contrast 2021-11-08 07:36:21 -06:00
Blake Blackshear
58117e2a3e check for overlapping motion boxes 2021-11-08 07:36:21 -06:00
Blake Blackshear
5bec438f9c config option for stationary detection interval 2021-11-01 07:58:30 -05:00
Blake Blackshear
24cc63d6d3 drop high overlap detections 2021-11-01 07:58:30 -05:00
Blake Blackshear
d17bd74c9a reduce detection rate for stationary objects 2021-11-01 07:58:30 -05:00
Blake Blackshear
8f101ccca8 improve box merging and keep tracking 2021-11-01 07:58:30 -05:00
Blake Blackshear
b63c56d810 only save recordings when an event is in progress 2021-10-25 06:40:36 -05:00
Blake Blackshear
61c62d4685 version tick 2021-10-25 06:40:02 -05:00
22 changed files with 95 additions and 15058 deletions

View File

@@ -43,11 +43,6 @@ If you are storing your database on a network share (SMB, NFS, etc), you may get
This may need to be in a custom location if network storage is used for the media folder. This may need to be in a custom location if network storage is used for the media folder.
```yaml
database:
path: /path/to/frigate.db
```
### `model` ### `model`
If using a custom model, the width and height will need to be specified. If using a custom model, the width and height will need to be specified.

View File

@@ -19,34 +19,6 @@ output_args:
rtmp: -c:v libx264 -an -f flv rtmp: -c:v libx264 -an -f flv
``` ```
### JPEG Stream Cameras
Cameras using a live changing jpeg image will need input parameters as below
```yaml
input_args:
- -r
- 5 # << enter FPS here
- -stream_loop
- -1
- -f
- image2
- -avoid_negative_ts
- make_zero
- -fflags
- nobuffer
- -flags
- low_delay
- -strict
- experimental
- -fflags
- +genpts+discardcorrupt
- -use_wallclock_as_timestamps
- 1
```
Outputting the stream will have the same args and caveats as per [MJPEG Cameras](#mjpeg-cameras)
### RTMP Cameras ### RTMP Cameras
The input parameters need to be adjusted for RTMP cameras The input parameters need to be adjusted for RTMP cameras

View File

@@ -159,23 +159,9 @@ detect:
enabled: True enabled: True
# Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate) # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate)
max_disappeared: 25 max_disappeared: 25
# Optional: Configuration for stationary object tracking # Optional: Frequency for running detection on stationary objects (default: 0)
stationary:
# Optional: Frequency for running detection on stationary objects (default: shown below)
# When set to 0, object detection will never be run on stationary objects. If set to 10, it will be run on every 10th frame. # When set to 0, object detection will never be run on stationary objects. If set to 10, it will be run on every 10th frame.
interval: 0 stationary_interval: 0
# Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s)
threshold: 50
# Optional: Define a maximum number of frames for tracking a stationary object (default: not set, track forever)
# This can help with false positives for objects that should only be stationary for a limited amount of time.
# It can also be used to disable stationary object tracking. For example, you may want to set a value for person, but leave
# car at the default.
max_frames:
# Optional: Default for all object types (default: not set, track forever)
default: 3000
# Optional: Object specific values
objects:
person: 1000
# Optional: Object configuration # Optional: Object configuration
# NOTE: Can be overridden at the camera level # NOTE: Can be overridden at the camera level
@@ -238,11 +224,6 @@ motion:
# NOTE: Can be overridden at the camera level # NOTE: Can be overridden at the camera level
record: record:
# Optional: Enable recording (default: shown below) # Optional: Enable recording (default: shown below)
# WARNING: Frigate does not currently support limiting recordings based
# on available disk space automatically. If using recordings,
# you must specify retention settings for a number of days that
# will fit within the available disk space of your drive or Frigate
# will crash.
enabled: False enabled: False
# Optional: Number of minutes to wait between cleanup runs (default: shown below) # Optional: Number of minutes to wait between cleanup runs (default: shown below)
# This can be used to reduce the frequency of deleting recording segments from disk if you want to minimize i/o # This can be used to reduce the frequency of deleting recording segments from disk if you want to minimize i/o

View File

@@ -5,11 +5,7 @@ title: Objects
import labels from "../../../labelmap.txt"; import labels from "../../../labelmap.txt";
Frigate includes the object models listed below from the Google Coral test data. By default, Frigate includes the following object models from the Google Coral test data. Note that `car` is listed twice because `truck` has been renamed to `car` by default. These object types are frequently confused.
Please note:
- `car` is listed twice because `truck` has been renamed to `car` by default. These object types are frequently confused.
- `person` is the only tracked object by default. See the [full configuration reference](https://docs.frigate.video/configuration/index#full-configuration-reference) for an example of expanding the list of tracked objects.
<ul> <ul>
{labels.split("\n").map((label) => ( {labels.split("\n").map((label) => (

View File

@@ -5,4 +5,4 @@ title: RTMP
Frigate can re-stream your video feed as a RTMP feed for other applications such as Home Assistant to utilize it at `rtmp://<frigate_host>/live/<camera_name>`. Port 1935 must be open. This allows you to use a video feed for detection in frigate and Home Assistant live view at the same time without having to make two separate connections to the camera. The video feed is copied from the original video feed directly to avoid re-encoding. This feed does not include any annotation by Frigate. Frigate can re-stream your video feed as a RTMP feed for other applications such as Home Assistant to utilize it at `rtmp://<frigate_host>/live/<camera_name>`. Port 1935 must be open. This allows you to use a video feed for detection in frigate and Home Assistant live view at the same time without having to make two separate connections to the camera. The video feed is copied from the original video feed directly to avoid re-encoding. This feed does not include any annotation by Frigate.
Some video feeds are not compatible with RTMP. If you are experiencing issues, check to make sure your camera feed is h264 with AAC audio. If your camera doesn't support a compatible format for RTMP, you can use the ffmpeg args to re-encode it on the fly at the expense of increased CPU utilization. Some more information about it can be found [here](../faqs#audio-in-recordings). Some video feeds are not compatible with RTMP. If you are experiencing issues, check to make sure your camera feed is h264 with AAC audio. If your camera doesn't support a compatible format for RTMP, you can use the ffmpeg args to re-encode it on the fly at the expense of increased CPU utilization.

View File

@@ -11,24 +11,9 @@ This error message is due to a shm-size that is too small. Try updating your shm
A solid green image means that frigate has not received any frames from ffmpeg. Check the logs to see why ffmpeg is exiting and adjust your ffmpeg args accordingly. A solid green image means that frigate has not received any frames from ffmpeg. Check the logs to see why ffmpeg is exiting and adjust your ffmpeg args accordingly.
### How can I get sound or audio in my recordings? {#audio-in-recordings} ### How can I get sound or audio in my recordings?
By default, Frigate removes audio from recordings to reduce the likelihood of failing for invalid data. If you would like to include audio, you need to override the output args to remove `-an` for where you want to include audio. The recommended audio codec is `aac`. Not all audio codecs are supported by RTMP, so you may need to re-encode your audio with `-c:a aac`. The default ffmpeg args are shown [here](/configuration/index/#full-configuration-reference). By default, Frigate removes audio from recordings to reduce the likelihood of failing for invalid data. If you would like to include audio, you need to override the output args to remove `-an` for where you want to include audio. The recommended audio codec is `aac`. Not all audio codecs are supported by RTMP, so you may need to re-encode your audio with `-c:a aac`. The default ffmpeg args are shown [here](configuration/index#full-configuration-reference).
:::tip
When using `-c:a aac`, do not forget to replace `-c copy` with `-c:v copy`. Example:
```diff title="frigate.yml"
ffmpeg:
output_args:
- record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an
+ record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac
```
This is needed because the `-c` flag (without `:a` or `:v`) applies for both audio and video, thus making it conflicting with `-c:a aac`.
:::
### My mjpeg stream or snapshots look green and crazy ### My mjpeg stream or snapshots look green and crazy

View File

@@ -167,17 +167,13 @@ cameras:
roles: roles:
- detect - detect
- rtmp - rtmp
- path: rtsp://10.0.10.10:554/high_res_stream # <----- Add high res stream - record # <----- Add role
roles:
- record
detect: ... detect: ...
record: # <----- Enable recording record: # <----- Enable recording
enabled: True enabled: True
motion: ... motion: ...
``` ```
If you don't have separate streams for detect and record, you would just add the record role to the list on the first input.
By default, Frigate will retain video of all events for 10 days. The full set of options for recording can be found [here](/configuration/index#full-configuration-reference). By default, Frigate will retain video of all events for 10 days. The full set of options for recording can be found [here](/configuration/index#full-configuration-reference).
### Step 8: Enable snapshots (optional) ### Step 8: Enable snapshots (optional)

View File

@@ -21,12 +21,6 @@ Windows is not officially supported, but some users have had success getting it
Frigate uses the following locations for read/write operations in the container. Docker volume mappings can be used to map these to any location on your host machine. Frigate uses the following locations for read/write operations in the container. Docker volume mappings can be used to map these to any location on your host machine.
:::caution
Note that Frigate does not currently support limiting recordings based on available disk space automatically. If using recordings, you must specify retention settings for a number of days that will fit within the available disk space of your drive or Frigate will crash.
:::
- `/media/frigate/clips`: Used for snapshot storage. In the future, it will likely be renamed from `clips` to `snapshots`. The file structure here cannot be modified and isn't intended to be browsed or managed manually. - `/media/frigate/clips`: Used for snapshot storage. In the future, it will likely be renamed from `clips` to `snapshots`. The file structure here cannot be modified and isn't intended to be browsed or managed manually.
- `/media/frigate/recordings`: Internal system storage for recording segments. The file structure here cannot be modified and isn't intended to be browsed or managed manually. - `/media/frigate/recordings`: Internal system storage for recording segments. The file structure here cannot be modified and isn't intended to be browsed or managed manually.
- `/media/frigate/frigate.db`: Default location for the sqlite database. You will also see several files alongside this file while frigate is running. If moving the database location (often needed when using a network drive at `/media/frigate`), it is recommended to mount a volume with docker at `/db` and change the storage location of the database to `/db/frigate.db` in the config file. - `/media/frigate/frigate.db`: Default location for the sqlite database. You will also see several files alongside this file while frigate is running. If moving the database location (often needed when using a network drive at `/media/frigate`), it is recommended to mount a volume with docker at `/db` and change the storage location of the database to `/db/frigate.db` in the config file.
@@ -124,7 +118,6 @@ services:
shm_size: "64mb" # update for your cameras based on calculation above shm_size: "64mb" # update for your cameras based on calculation above
devices: devices:
- /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
- /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
- /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
volumes: volumes:
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro

View File

@@ -56,9 +56,8 @@ Message published for each changed event. The first message is published when th
"thumbnail": null, "thumbnail": null,
"has_snapshot": false, "has_snapshot": false,
"has_clip": false, "has_clip": false,
"stationary": false, // whether or not the object is considered stationary
"motionless_count": 0, // number of frames the object has been motionless "motionless_count": 0, // number of frames the object has been motionless
"position_changes": 2 // number of times the object has moved from a stationary position "position_changes": 2 // number of times the object has changed position
}, },
"after": { "after": {
"id": "1607123955.475377-mxklsc", "id": "1607123955.475377-mxklsc",
@@ -79,7 +78,6 @@ Message published for each changed event. The first message is published when th
"thumbnail": null, "thumbnail": null,
"has_snapshot": false, "has_snapshot": false,
"has_clip": false, "has_clip": false,
"stationary": false, // whether or not the object is considered stationary
"motionless_count": 0, // number of frames the object has been motionless "motionless_count": 0, // number of frames the object has been motionless
"position_changes": 2 // number of times the object has changed position "position_changes": 2 // number of times the object has changed position
} }

View File

@@ -162,29 +162,6 @@ class RuntimeMotionConfig(MotionConfig):
extra = Extra.ignore extra = Extra.ignore
class StationaryMaxFramesConfig(FrigateBaseModel):
default: Optional[int] = Field(title="Default max frames.", ge=1)
objects: Dict[str, int] = Field(
default_factory=dict, title="Object specific max frames."
)
class StationaryConfig(FrigateBaseModel):
interval: Optional[int] = Field(
default=0,
title="Frame interval for checking stationary objects.",
ge=0,
)
threshold: Optional[int] = Field(
title="Number of frames without a position change for an object to be considered stationary",
ge=1,
)
max_frames: StationaryMaxFramesConfig = Field(
default_factory=StationaryMaxFramesConfig,
title="Max frames for stationary objects.",
)
class DetectConfig(FrigateBaseModel): class DetectConfig(FrigateBaseModel):
height: int = Field(default=720, title="Height of the stream for the detect role.") height: int = Field(default=720, title="Height of the stream for the detect role.")
width: int = Field(default=1280, title="Width of the stream for the detect role.") width: int = Field(default=1280, title="Width of the stream for the detect role.")
@@ -195,9 +172,10 @@ class DetectConfig(FrigateBaseModel):
max_disappeared: Optional[int] = Field( max_disappeared: Optional[int] = Field(
title="Maximum number of frames the object can dissapear before detection ends." title="Maximum number of frames the object can dissapear before detection ends."
) )
stationary: StationaryConfig = Field( stationary_interval: Optional[int] = Field(
default_factory=StationaryConfig, default=0,
title="Stationary objects config.", title="Frame interval for checking stationary objects.",
ge=0,
) )
@@ -788,11 +766,6 @@ class FrigateConfig(FrigateBaseModel):
if camera_config.detect.max_disappeared is None: if camera_config.detect.max_disappeared is None:
camera_config.detect.max_disappeared = max_disappeared camera_config.detect.max_disappeared = max_disappeared
# Default stationary_threshold configuration
stationary_threshold = camera_config.detect.fps * 10
if camera_config.detect.stationary.threshold is None:
camera_config.detect.stationary.threshold = stationary_threshold
# FFMPEG input substitution # FFMPEG input substitution
for input in camera_config.ffmpeg.inputs: for input in camera_config.ffmpeg.inputs:
input.path = input.path.format(**FRIGATE_ENV_VARS) input.path = input.path.format(**FRIGATE_ENV_VARS)

View File

@@ -15,16 +15,6 @@ from frigate.models import Event
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def should_update_db(prev_event, current_event):
return (
prev_event["top_score"] != current_event["top_score"]
or prev_event["entered_zones"] != current_event["entered_zones"]
or prev_event["thumbnail"] != current_event["thumbnail"]
or prev_event["has_clip"] != current_event["has_clip"]
or prev_event["has_snapshot"] != current_event["has_snapshot"]
)
class EventProcessor(threading.Thread): class EventProcessor(threading.Thread):
def __init__( def __init__(
self, config, camera_processes, event_queue, event_processed_queue, stop_event self, config, camera_processes, event_queue, event_processed_queue, stop_event
@@ -58,9 +48,7 @@ class EventProcessor(threading.Thread):
if event_type == "start": if event_type == "start":
self.events_in_process[event_data["id"]] = event_data self.events_in_process[event_data["id"]] = event_data
elif event_type == "update" and should_update_db( elif event_type == "update":
self.events_in_process[event_data["id"]], event_data
):
self.events_in_process[event_data["id"]] = event_data self.events_in_process[event_data["id"]] = event_data
# TODO: this will generate a lot of db activity possibly # TODO: this will generate a lot of db activity possibly
if event_data["has_clip"] or event_data["has_snapshot"]: if event_data["has_clip"] or event_data["has_snapshot"]:

View File

@@ -249,10 +249,7 @@ def event_clip(id):
clip_path = os.path.join(CLIPS_DIR, file_name) clip_path = os.path.join(CLIPS_DIR, file_name)
if not os.path.isfile(clip_path): if not os.path.isfile(clip_path):
end_ts = ( return recording_clip(event.camera, event.start_time, event.end_time)
datetime.now().timestamp() if event.end_time is None else event.end_time
)
return recording_clip(event.camera, event.start_time, end_ts)
response = make_response() response = make_response()
response.headers["Content-Description"] = "File Transfer" response.headers["Content-Description"] = "File Transfer"
@@ -527,17 +524,12 @@ def recordings(camera_name):
FROM C2 FROM C2
WHERE cnt = 0 WHERE cnt = 0
) )
SELECT id, label, camera, top_score, start_time, end_time
FROM event
WHERE camera = ? AND end_time IS NULL
UNION ALL
SELECT MIN(id) as id, label, camera, MAX(top_score) as top_score, MIN(ts) AS start_time, max(ts) AS end_time SELECT MIN(id) as id, label, camera, MAX(top_score) as top_score, MIN(ts) AS start_time, max(ts) AS end_time
FROM C3 FROM C3
GROUP BY label, grpnum GROUP BY label, grpnum
ORDER BY start_time;""", ORDER BY start_time;""",
camera_name, camera_name,
camera_name, camera_name,
camera_name,
) )
event: Event event: Event

View File

@@ -101,13 +101,14 @@ class TrackedObject:
return median(scores) return median(scores)
def update(self, current_frame_time, obj_data): def update(self, current_frame_time, obj_data):
thumb_update = False significant_update = False
significant_change = False zone_change = False
self.obj_data.update(obj_data)
# if the object is not in the current frame, add a 0.0 to the score history # if the object is not in the current frame, add a 0.0 to the score history
if obj_data["frame_time"] != current_frame_time: if self.obj_data["frame_time"] != current_frame_time:
self.score_history.append(0.0) self.score_history.append(0.0)
else: else:
self.score_history.append(obj_data["score"]) self.score_history.append(self.obj_data["score"])
# only keep the last 10 scores # only keep the last 10 scores
if len(self.score_history) > 10: if len(self.score_history) > 10:
self.score_history = self.score_history[-10:] self.score_history = self.score_history[-10:]
@@ -121,24 +122,24 @@ class TrackedObject:
if not self.false_positive: if not self.false_positive:
# determine if this frame is a better thumbnail # determine if this frame is a better thumbnail
if self.thumbnail_data is None or is_better_thumbnail( if self.thumbnail_data is None or is_better_thumbnail(
self.thumbnail_data, obj_data, self.camera_config.frame_shape self.thumbnail_data, self.obj_data, self.camera_config.frame_shape
): ):
self.thumbnail_data = { self.thumbnail_data = {
"frame_time": obj_data["frame_time"], "frame_time": self.obj_data["frame_time"],
"box": obj_data["box"], "box": self.obj_data["box"],
"area": obj_data["area"], "area": self.obj_data["area"],
"region": obj_data["region"], "region": self.obj_data["region"],
"score": obj_data["score"], "score": self.obj_data["score"],
} }
thumb_update = True significant_update = True
# check zones # check zones
current_zones = [] current_zones = []
bottom_center = (obj_data["centroid"][0], obj_data["box"][3]) bottom_center = (self.obj_data["centroid"][0], self.obj_data["box"][3])
# check each zone # check each zone
for name, zone in self.camera_config.zones.items(): for name, zone in self.camera_config.zones.items():
# if the zone is not for this object type, skip # if the zone is not for this object type, skip
if len(zone.objects) > 0 and not obj_data["label"] in zone.objects: if len(zone.objects) > 0 and not self.obj_data["label"] in zone.objects:
continue continue
contour = zone.contour contour = zone.contour
# check if the object is in the zone # check if the object is in the zone
@@ -149,29 +150,12 @@ class TrackedObject:
if name not in self.entered_zones: if name not in self.entered_zones:
self.entered_zones.append(name) self.entered_zones.append(name)
if not self.false_positive:
# if the zones changed, signal an update # if the zones changed, signal an update
if set(self.current_zones) != set(current_zones): if not self.false_positive and set(self.current_zones) != set(current_zones):
significant_change = True zone_change = True
# if the position changed, signal an update
if self.obj_data["position_changes"] != obj_data["position_changes"]:
significant_change = True
# if the motionless_count reaches the stationary threshold
if (
self.obj_data["motionless_count"]
== self.camera_config.detect.stationary.threshold
):
significant_change = True
# update at least once per minute
if self.obj_data["frame_time"] - self.previous["frame_time"] > 60:
significant_change = True
self.obj_data.update(obj_data)
self.current_zones = current_zones self.current_zones = current_zones
return (thumb_update, significant_change) return (significant_update, zone_change)
def to_dict(self, include_thumbnail: bool = False): def to_dict(self, include_thumbnail: bool = False):
snapshot_time = ( snapshot_time = (
@@ -193,8 +177,6 @@ class TrackedObject:
"box": self.obj_data["box"], "box": self.obj_data["box"],
"area": self.obj_data["area"], "area": self.obj_data["area"],
"region": self.obj_data["region"], "region": self.obj_data["region"],
"stationary": self.obj_data["motionless_count"]
> self.camera_config.detect.stationary.threshold,
"motionless_count": self.obj_data["motionless_count"], "motionless_count": self.obj_data["motionless_count"],
"position_changes": self.obj_data["position_changes"], "position_changes": self.obj_data["position_changes"],
"current_zones": self.current_zones.copy(), "current_zones": self.current_zones.copy(),
@@ -484,11 +466,11 @@ class CameraState:
for id in updated_ids: for id in updated_ids:
updated_obj = tracked_objects[id] updated_obj = tracked_objects[id]
thumb_update, significant_update = updated_obj.update( significant_update, zone_change = updated_obj.update(
frame_time, current_detections[id] frame_time, current_detections[id]
) )
if thumb_update: if significant_update:
# ensure this frame is stored in the cache # ensure this frame is stored in the cache
if ( if (
updated_obj.thumbnail_data["frame_time"] == frame_time updated_obj.thumbnail_data["frame_time"] == frame_time
@@ -498,13 +480,13 @@ class CameraState:
updated_obj.last_updated = frame_time updated_obj.last_updated = frame_time
# if it has been more than 5 seconds since the last thumb update # if it has been more than 5 seconds since the last publish
# and the last update is greater than the last publish or # and the last update is greater than the last publish or
# the object has changed significantly # the object has changed zones
if ( if (
frame_time - updated_obj.last_published > 5 frame_time - updated_obj.last_published > 5
and updated_obj.last_updated > updated_obj.last_published and updated_obj.last_updated > updated_obj.last_published
) or significant_update: ) or zone_change:
# call event handlers # call event handlers
for c in self.callbacks["update"]: for c in self.callbacks["update"]:
c(self.name, updated_obj, frame_time) c(self.name, updated_obj, frame_time)

View File

@@ -48,7 +48,7 @@ class ObjectTracker:
del self.tracked_objects[id] del self.tracked_objects[id]
del self.disappeared[id] del self.disappeared[id]
# tracks the current position of the object based on the last N bounding boxes # tracks the current position of the object based on the last 10 bounding boxes
# returns False if the object has moved outside its previous position # returns False if the object has moved outside its previous position
def update_position(self, id, box): def update_position(self, id, box):
position = self.positions[id] position = self.positions[id]
@@ -93,52 +93,20 @@ class ObjectTracker:
return True return True
def is_expired(self, id):
obj = self.tracked_objects[id]
# get the max frames for this label type or the default
max_frames = self.detect_config.stationary.max_frames.objects.get(
obj["label"], self.detect_config.stationary.max_frames.default
)
# if there is no max_frames for this label type, continue
if max_frames is None:
return False
# if the object has exceeded the max_frames setting, deregister
if (
obj["motionless_count"] - self.detect_config.stationary.threshold
> max_frames
):
print(f"expired: {obj['motionless_count']}")
return True
def update(self, id, new_obj): def update(self, id, new_obj):
self.disappeared[id] = 0 self.disappeared[id] = 0
# update the motionless count if the object has not moved to a new position # update the motionless count if the object has not moved to a new position
if self.update_position(id, new_obj["box"]): if self.update_position(id, new_obj["box"]):
self.tracked_objects[id]["motionless_count"] += 1 self.tracked_objects[id]["motionless_count"] += 1
if self.is_expired(id):
self.deregister(id)
return
else: else:
# register the first position change and then only increment if
# the object was previously stationary
if (
self.tracked_objects[id]["position_changes"] == 0
or self.tracked_objects[id]["motionless_count"]
>= self.detect_config.stationary.threshold
):
self.tracked_objects[id]["position_changes"] += 1
self.tracked_objects[id]["motionless_count"] = 0 self.tracked_objects[id]["motionless_count"] = 0
self.tracked_objects[id]["position_changes"] += 1
self.tracked_objects[id].update(new_obj) self.tracked_objects[id].update(new_obj)
def update_frame_times(self, frame_time): def update_frame_times(self, frame_time):
for id in list(self.tracked_objects.keys()): for id in self.tracked_objects.keys():
self.tracked_objects[id]["frame_time"] = frame_time self.tracked_objects[id]["frame_time"] = frame_time
self.tracked_objects[id]["motionless_count"] += 1 self.tracked_objects[id]["motionless_count"] += 1
if self.is_expired(id):
self.deregister(id)
def match_and_update(self, frame_time, new_objects): def match_and_update(self, frame_time, new_objects):
# group by name # group by name

View File

@@ -184,7 +184,10 @@ class BirdsEyeFrameManager:
if self.mode == BirdseyeModeEnum.continuous: if self.mode == BirdseyeModeEnum.continuous:
return True return True
if self.mode == BirdseyeModeEnum.motion and motion_box_count > 0: if (
self.mode == BirdseyeModeEnum.motion
and object_box_count + motion_box_count > 0
):
return True return True
if self.mode == BirdseyeModeEnum.objects and object_box_count > 0: if self.mode == BirdseyeModeEnum.objects and object_box_count > 0:
@@ -415,7 +418,7 @@ def output_frames(config: FrigateConfig, video_output_queue):
): ):
if birdseye_manager.update( if birdseye_manager.update(
camera, camera,
len([o for o in current_tracked_objects if not o["stationary"]]), len(current_tracked_objects),
len(motion_boxes), len(motion_boxes),
frame_time, frame_time,
frame, frame,

View File

@@ -51,6 +51,7 @@ class RecordingMaintainer(threading.Thread):
self.config = config self.config = config
self.recordings_info_queue = recordings_info_queue self.recordings_info_queue = recordings_info_queue
self.stop_event = stop_event self.stop_event = stop_event
self.first_pass = True
self.recordings_info = defaultdict(list) self.recordings_info = defaultdict(list)
self.end_time_cache = {} self.end_time_cache = {}
@@ -333,6 +334,12 @@ class RecordingMaintainer(threading.Thread):
logger.error(e) logger.error(e)
duration = datetime.datetime.now().timestamp() - run_start duration = datetime.datetime.now().timestamp() - run_start
wait_time = max(0, 5 - duration) wait_time = max(0, 5 - duration)
if wait_time == 0 and not self.first_pass:
logger.warning(
"Cache is taking longer than 5 seconds to clear. Your recordings disk may be too slow."
)
if self.first_pass:
self.first_pass = False
logger.info(f"Exiting recording maintenance...") logger.info(f"Exiting recording maintenance...")

View File

@@ -511,8 +511,8 @@ def process_frames(
if obj["motionless_count"] >= 10 if obj["motionless_count"] >= 10
# and it isn't due for a periodic check # and it isn't due for a periodic check
and ( and (
detect_config.stationary.interval == 0 detect_config.stationary_interval == 0
or obj["motionless_count"] % detect_config.stationary.interval != 0 or obj["motionless_count"] % detect_config.stationary_interval != 0
) )
# and it hasn't disappeared # and it hasn't disappeared
and object_tracker.disappeared[obj["id"]] == 0 and object_tracker.disappeared[obj["id"]] == 0

14794
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,6 @@
import { h } from 'preact'; import { h } from 'preact';
import { useState } from 'preact/hooks'; import { useState } from 'preact/hooks';
import { import { addSeconds, differenceInSeconds, fromUnixTime, format, parseISO, startOfHour } from 'date-fns';
differenceInSeconds,
fromUnixTime,
format,
parseISO,
startOfHour,
differenceInMinutes,
differenceInHours,
} from 'date-fns';
import ArrowDropdown from '../icons/ArrowDropdown'; import ArrowDropdown from '../icons/ArrowDropdown';
import ArrowDropup from '../icons/ArrowDropup'; import ArrowDropup from '../icons/ArrowDropup';
import Link from '../components/Link'; import Link from '../components/Link';
@@ -29,10 +21,7 @@ export default function RecordingPlaylist({ camera, recordings, selectedDate, se
events={recording.events} events={recording.events}
selected={recording.date === selectedDate} selected={recording.date === selectedDate}
> >
{recording.recordings {recording.recordings.slice().reverse().map((item, i) => (
.slice()
.reverse()
.map((item, i) => (
<div className="mb-2 w-full"> <div className="mb-2 w-full">
<div <div
className={`flex w-full text-md text-white px-8 py-2 mb-2 ${ className={`flex w-full text-md text-white px-8 py-2 mb-2 ${
@@ -46,10 +35,7 @@ export default function RecordingPlaylist({ camera, recordings, selectedDate, se
</div> </div>
<div className="flex-1 text-right">{item.events.length} Events</div> <div className="flex-1 text-right">{item.events.length} Events</div>
</div> </div>
{item.events {item.events.slice().reverse().map((event) => (
.slice()
.reverse()
.map((event) => (
<EventCard camera={camera} event={event} delay={item.delay} /> <EventCard camera={camera} event={event} delay={item.delay} />
))} ))}
</div> </div>
@@ -97,17 +83,8 @@ export function ExpandableList({ title, events = 0, children, selected = false }
export function EventCard({ camera, event, delay }) { export function EventCard({ camera, event, delay }) {
const apiHost = useApiHost(); const apiHost = useApiHost();
const start = fromUnixTime(event.start_time); const start = fromUnixTime(event.start_time);
let duration = 'In Progress';
if (event.end_time) {
const end = fromUnixTime(event.end_time); const end = fromUnixTime(event.end_time);
const hours = differenceInHours(end, start); const duration = addSeconds(new Date(0), differenceInSeconds(end, start));
const minutes = differenceInMinutes(end, start) - hours * 60;
const seconds = differenceInSeconds(end, start) - hours * 60 - minutes * 60;
duration = '';
if (hours) duration += `${hours}h `;
if (minutes) duration += `${minutes}m `;
duration += `${seconds}s`;
}
const position = differenceInSeconds(start, startOfHour(start)); const position = differenceInSeconds(start, startOfHour(start));
const offset = Object.entries(delay) const offset = Object.entries(delay)
.map(([p, d]) => (position > p ? d : 0)) .map(([p, d]) => (position > p ? d : 0))
@@ -125,7 +102,7 @@ export function EventCard({ camera, event, delay }) {
<div className="flex-1"> <div className="flex-1">
<div className="text-2xl text-white leading-tight capitalize">{event.label}</div> <div className="text-2xl text-white leading-tight capitalize">{event.label}</div>
<div className="text-xs md:text-normal text-gray-300">Start: {format(start, 'HH:mm:ss')}</div> <div className="text-xs md:text-normal text-gray-300">Start: {format(start, 'HH:mm:ss')}</div>
<div className="text-xs md:text-normal text-gray-300">Duration: {duration}</div> <div className="text-xs md:text-normal text-gray-300">Duration: {format(duration, 'mm:ss')}</div>
</div> </div>
<div className="text-lg text-white text-right leading-tight">{(event.top_score * 100).toFixed(1)}%</div> <div className="text-lg text-white text-right leading-tight">{(event.top_score * 100).toFixed(1)}%</div>
</div> </div>

View File

@@ -29,8 +29,12 @@ function Camera({ name, conf }) {
const { payload: snapshotValue, send: sendSnapshots } = useSnapshotsState(name); const { payload: snapshotValue, send: sendSnapshots } = useSnapshotsState(name);
const href = `/cameras/${name}`; const href = `/cameras/${name}`;
const buttons = useMemo(() => { const buttons = useMemo(() => {
return [{ name: 'Events', href: `/events?camera=${name}` }, { name: 'Recordings', href: `/recording/${name}` }]; const result = [{ name: 'Events', href: `/events?camera=${name}` }];
}, [name]); if (conf.record.enabled) {
result.push({ name: 'Recordings', href: `/recording/${name}` });
}
return result;
}, [name, conf.record.enabled]);
const icons = useMemo( const icons = useMemo(
() => [ () => [
{ {

View File

@@ -66,9 +66,6 @@ export default function Recording({ camera, date, hour, seconds }) {
this.player.currentTime(seconds); this.player.currentTime(seconds);
} }
} }
// Force playback rate to be correct
const playbackRate = this.player.playbackRate();
this.player.defaultPlaybackRate(playbackRate);
} }
return ( return (

View File

@@ -46,7 +46,7 @@ describe('Cameras Route', () => {
expect(screen.queryByLabelText('Loading…')).not.toBeInTheDocument(); expect(screen.queryByLabelText('Loading…')).not.toBeInTheDocument();
expect(screen.queryAllByText('Recordings')).toHaveLength(2); expect(screen.queryAllByText('Recordings')).toHaveLength(1);
}); });
test('buttons toggle detect, clips, and snapshots', async () => { test('buttons toggle detect, clips, and snapshots', async () => {