Compare commits

..

120 Commits

Author SHA1 Message Date
Josh Hawkins
4e5a6eb1c8 Consolidate onvif camera recommendations in docs (#11972) 2024-06-15 08:02:18 -05:00
Josh Hawkins
5617fbbcb1 Optional proxy in config (#11973) 2024-06-15 08:01:19 -05:00
Blake Blackshear
15e2df1e5c set shortest edge to preview height (#11971) 2024-06-15 06:42:23 -05:00
Alex Yao
0d862d6aa8 Show failure exception message (#11964) 2024-06-14 20:34:14 -05:00
Blake Blackshear
9ceffeb191 split out proxy from auth (#11963)
* split out proxy from auth

* update documentation

* fixup auth mode check
2024-06-14 18:02:13 -05:00
Nicolas Mowen
b49cda274d Fix calendar selection (#11959) 2024-06-14 12:14:32 -05:00
Marc Altmann
2934c7817d Update FFmpeg for Rockchip (#11952) 2024-06-14 07:25:33 -05:00
Blake Blackshear
4078a147ef Merge remote-tracking branch 'origin/master' into dev 2024-06-14 06:45:21 -05:00
Blake Blackshear
1cb5dcb7dc clarify vaapi vs qsv (#11954) 2024-06-14 06:44:22 -05:00
Blake Blackshear
7aec8222fc clarify model id (#11953) 2024-06-14 06:42:53 -05:00
Blake Blackshear
30e1969fad clarify plus models (#11951) 2024-06-14 05:15:19 -06:00
Nicolas Mowen
a7da468b97 Manually set current time when selecting event (#11948)
* Manually set current time when selecting event

* Make it clear which camera has no preview

* Make it clear which camera has no preview

* Format camera name
2024-06-13 19:00:41 -05:00
Blake Blackshear
1a0d9e10d7 clarifications for proxy auth mode (#11947) 2024-06-13 16:13:55 -06:00
Nicolas Mowen
9514a3d089 UI tweaks (#11940)
* Enforce events must have snapshots for frigate+

* Open docs links in separate tabs

* Reload after restart to the baseUrl
2024-06-13 16:11:25 -06:00
Josh Hawkins
349b27b764 Draggable grid fixes (#11944)
* Use globals on grid for resizing/dragging flags

* remove unneeded useeffect
2024-06-13 13:11:48 -06:00
Nicolas Mowen
e56ce993df UI Tweaks (#11931)
* Show number of items instead of dot

* Don't call error when connection has been closed on purpose

* Use motion icon for motion

* Show text on tablets as well
2024-06-13 09:45:07 -05:00
Nicolas Mowen
3e1861e2ce Correctly update segment data (#11922) 2024-06-12 15:48:54 -06:00
Josh Hawkins
187d98a153 Ensure uri components are decoded (#11920) 2024-06-12 16:03:00 -05:00
Josh Hawkins
2d4d1584fd Activity indicator for alerts/detections count when loading (#11914)
* Activity indicator for alerts/detections count when loading

* Return zeros if summary is unavailable
2024-06-12 12:30:22 -06:00
Josh Hawkins
c75fc40833 Activity indicator whenever preferred live mode changes (#11913) 2024-06-12 11:36:11 -06:00
Felipe Santos
e3c8901549 Fix cpu count when process name includes the word processor (#11911) 2024-06-12 08:03:27 -06:00
Nicolas Mowen
6978140492 Copy review data so there is a diff (#11896) 2024-06-11 18:05:20 -05:00
Josh Hawkins
272a21ffab Add scrollbar class to preview row/column (#11890) 2024-06-11 13:45:45 -05:00
Josh Hawkins
a8e901b63c UI fixes (#11883)
* Keep as optional prop

* put zones inside of scrollable container
2024-06-11 09:05:50 -06:00
Josh Hawkins
bb359f67a4 Review UI improvements (#11882) 2024-06-11 09:46:05 -05:00
Nicolas Mowen
c9d253a320 Review improvements (#11879)
* Update segment even when number of active objects is the same

* add score to frigate+ chip

* Add support for selecting zones

* Add api support for filtering on zones

* Adjust UI

* Update filtering logic

* Clean up
2024-06-11 08:19:17 -06:00
Blake Blackshear
b3eab17f2c just check for secret file specifically (#11877)
* just check for secret file specifically

* add josh to funding
2024-06-11 06:53:12 -06:00
Nicolas Mowen
962d213699 UI changes (#11863)
* Delay live ready being dropped

* Handle case of removed camera
2024-06-10 20:20:58 -05:00
Josh Hawkins
18d561da0e Live player fixes and improvements (#11855)
* Only set stalled error when player is visible

* Show activity indicator before live player starts playing

* remove comment

* keep gradients when still image is showing

* fix chips

* red dot and outline
2024-06-10 17:24:25 -06:00
Blake Blackshear
30b86271ea move clip.mp4 backend to clips folder (#11834)
* move clip.mp4 backend to clips folder

* improve caching

* fix check
2024-06-09 13:45:26 -05:00
Josh Hawkins
5f3c35209d Prevent editing of object mask type on existing mask (#11829) 2024-06-09 06:28:38 -06:00
Julien Ehrhart
2535519830 Update HA integration doc with image entities following #548 (#11261) 2024-06-09 06:44:27 -05:00
Blake Blackshear
f4dd3e44b6 update images in readme 2024-06-08 15:37:16 -05:00
Nicolas Mowen
11babb9509 Remove mention of recordings timeline object debugging (#11820) 2024-06-08 09:00:24 -06:00
Josh Hawkins
e1bedf30bf Make sure camera is always set in settings (#11812) 2024-06-07 13:34:29 -06:00
Josh Hawkins
859682c8d1 Change breakpoint for desktop motion review columns (#11808) 2024-06-07 09:40:32 -06:00
Josh Hawkins
804edceec2 Retain 3 columns on desktop motion review (#11805) 2024-06-07 06:51:09 -06:00
Josh Hawkins
9f181014a1 UI tweaks (#11795)
* Prevent "undefined" from being displayed in searchParams string

* Show message for no motion data

* Use theme colors for no preview found divs
2024-06-07 05:57:15 -06:00
Blake Blackshear
4313fd97aa Adds support for YOLO-NAS in OpenVino (#11645)
* update onnxruntime

* support for yolo-nas in openvino

* cleanup notebook

* update docs

* improve docs

* handle AUTO issue and update docs
2024-06-07 05:52:08 -06:00
Blake Blackshear
4e569ad644 Update deps (#11799)
* web deps

* python deps
2024-06-07 05:50:45 -06:00
Blake Blackshear
b4384a1be3 Shutdown hang (#11793)
* intentionally handle queues during shutdown and carefully manage shutdown order

* more carefully manage shutdown to avoid threadlocks

* use debug for signal logging

* ensure disabled cameras dont break shutdown

* typo
2024-06-06 18:54:38 -05:00
Josh Hawkins
5b42c91a91 Compare timestamps instead of datetimes when exporting (#11790) 2024-06-06 14:34:31 -06:00
Josh Hawkins
926d394b2f Ensure datetime comparison is the same (native vs aware) (#11789) 2024-06-06 14:10:46 -06:00
Josh Hawkins
fc5a926892 Ensure export thumbnail datetime is UTC (#11786) 2024-06-06 13:18:42 -06:00
Josh Hawkins
d2787d4308 Change debug message about deleting db entries to warning (#11780) 2024-06-06 09:16:28 -06:00
Josh Hawkins
8cc170f027 Draggable grid layout bugfixes (#11777)
* Maintain aspect ratio when overdragging

* add existing x value

* Better handle portrait and wide cam aspect ratios
2024-06-06 06:26:02 -06:00
Felipe Santos
53fa64fd14 Ensure nginx worker processes respects docker limits (#11769)
* Ensure nginx worker processes respects docker limits

* Update get_cpus.sh revision

* Add get_cpus.sh functionality inline to nginx/run
2024-06-05 13:43:22 -06:00
Josh Hawkins
8c96dfe1d1 Some small layout tweaks for portrait cams and motion review (#11766)
* Some small layout tweaks for portrait cams and motion review

* spans

* fix desktop
2024-06-05 09:53:17 -05:00
Ramūnas Dronga
36ae42a011 fix: remove contradictory ffmpeg param and missing param (#11752) 2024-06-04 14:19:37 -06:00
Nicolas Mowen
0181d1e377 Don't show preview for birdseye (#11749)
* Don't show preview for birdseye

* Retry ws connection on error

* Flex wrap cameras labels
2024-06-04 14:00:04 -06:00
Josh Hawkins
3f0a954856 Try webrtc when mse fails with decoding error (#11745)
* Try webrtc if enabled and mse fails with decoding error

* default to jsmpeg if webrtc times out

* check for mic first
2024-06-04 09:11:32 -06:00
Nicolas Mowen
2875e84cb5 UI Fixes (#11742)
* Allow deleting failed in progress exports

* Fix comparison and preview retrieval

* Fix stretching of event cards

* Reset edit state when group changes

* Allow specifying group
2024-06-04 09:10:19 -06:00
Jason Hunter
7917bf55ff Fix unclean shutdown of ZMQ (#11740) 2024-06-04 06:39:34 -06:00
Nicolas Mowen
ea0292b911 Ensure review padding is consistently applied (#11728) 2024-06-03 17:10:39 -06:00
Josh Hawkins
e6d1ad0ac5 Theme scrollbars with tailwind-scrollbar (#11723) 2024-06-03 12:43:30 -06:00
reidprichard
9808ff64e7 Update authentication.md to note port 8080 vs 5000 (#11722)
* Update authentication.md to note port 8080 vs 5000

* Update docs/docs/configuration/authentication.md

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2024-06-03 11:53:59 -06:00
Josh Hawkins
f65ddccd6e Ensure debug switches match loaded options (#11721) 2024-06-03 08:51:23 -06:00
Nicolas Mowen
b763754723 fix duplicate id in bug report (#11718) 2024-06-03 08:00:29 -06:00
Nicolas Mowen
d5dafffc39 Fix bug template (#11716)
* Update bug-link.yml

* Delete .github/ISSUE_TEMPLATE/bug-link.yml

* Use existing template
2024-06-03 08:19:16 -05:00
Nicolas Mowen
bd7c575f26 Add bug template to issues (#11712)
* Add bug template to issues

* Delete .github/ISSUE_TEMPLATE/bug_report.yml

* Create bug-report.yml

* Create bug-link.yml
2024-06-03 07:42:47 -05:00
Josh Hawkins
13f250f630 Use valid/unique css identifier for jsmpeg canvas elements (#11704) 2024-06-03 05:39:19 -06:00
Marc Altmann
7a4eb0b37c Add coco-80 labelmap and update FFmpeg for Rockchip (#11695)
* add coco-80 labelmap and update ffmpeg

* Update docs/docs/configuration/object_detectors.md

---------

Co-authored-by: Blake Blackshear <blake.blackshear@gmail.com>
2024-06-02 20:47:26 -05:00
Josh Hawkins
1e80342c41 UI tweaks and bugfixes (#11692)
* UI tweaks and bugfixes

* fix linter complaints in unmodified files
2024-06-02 12:00:59 -05:00
Blake Blackshear
7031c47fb2 fix tempio install for arm64 (#11691) 2024-06-02 08:47:11 -05:00
Blake Blackshear
e431031112 improve tls implementation (#11690)
* improve tls implementation

* update docs
2024-06-02 06:48:28 -06:00
Sergei
379061f847 Typo on edgetpu.md (#11686)
Added a missing bracket.
2024-06-02 05:22:55 -06:00
Josh Hawkins
beefc51361 container for birdseye aspect and auto width for mobile time pill (#11685) 2024-06-01 21:13:37 -06:00
Blake Blackshear
bccffe6670 TLS support (#11678)
* implement self signed cert and monitor/reload

* move go2rtc upstream to separate file

* add directory for ACME challenges

* make certsync more resilient

* add TLS docs

* add jwt secret info to docs
2024-06-01 10:29:46 -05:00
Nicolas Mowen
8418b65f34 Fix path containing too many / (#11680) 2024-06-01 08:24:20 -05:00
Soren L. Hansen
6e53c109b6 feat: apply ingress path to app paths (#11677)
When serving Frigate at a subpath, the paths that show in the URL bar
and that wind up in your browser history are anchored at the web root.
I.e. you go to `https://example.com/frigate/`, it changes to
`https://example.com/`, and clicking around works as expected, but the
`frigate/` prefix is gone.

It's confusing if you don't know that the URL's are entirely virtual.
Also, your browser history is useless, since the URL's point to e.g.
`https://example.com/#kitchen`, but visiting that URL will not hit
`/frigate/` at all.

Most of the work is already done. Nginx injects javascript to set
`window.baseURL` based on the X-Ingress-Path header. This change passes
that to BrowserRouter, so that it'll be part of the URL's it shows.

Fixes #4526
2024-06-01 07:08:01 -06:00
Blake Blackshear
7b99bbfd28 Update deps (#11679)
* update web deps

* update actions

* automatic stable tag publishing

* python deps

* typo
2024-06-01 06:39:05 -06:00
Nicolas Mowen
8179278bfa Don't fail if user has bind mounted nginx config (#11671) 2024-06-01 06:19:54 -05:00
Nicolas Mowen
758df09da3 Handle error when live view stalls (#11665)
* Handle error when live view stalls

* Manually calculate buffer timeout

* Formatting
2024-05-31 08:52:42 -05:00
Josh Hawkins
a3d116e70e stay in fullscreen when navigating to a camera (#11666) 2024-05-31 07:58:33 -05:00
Josh Hawkins
8c325801ef fix race where camera change effect sometimes was called after layout building (#11656) 2024-05-30 14:17:00 -06:00
Tom B
35946d332d Fix Statusbar rendering NaN% for unsupported GPUs (#11655) 2024-05-30 13:10:24 -06:00
Nicolas Mowen
142641b387 Adjust nginx proc count based on available CPUs (#11653)
* Restrict nginx to 4 processes if more are available

* Fix bash

* Different sed structure

* Limit ffmpeg thread counts for secondary ffmpeg processes

* Add up / down keyboard shortcut
2024-05-30 12:34:01 -05:00
Josh Hawkins
402c16e7df don't sleep mobile devices when fullscreen (#11652) 2024-05-30 09:37:08 -06:00
Nicolas Mowen
3e6b8c23bc Update dialog sizing for plus dialog (#11650) 2024-05-30 09:26:15 -05:00
Nicolas Mowen
1c5e7ebb48 UI Fixes (#11648)
* Add cursor pointer to preset dropdown

* Catch key index

* Fix iOS mime type
2024-05-30 07:41:37 -06:00
Josh Hawkins
9cb3e11df6 non-modal dropdown menus (#11649) 2024-05-30 07:39:14 -06:00
Nicolas Mowen
1c2e2a7b38 Handle case where user sets detections as empty list (#11646) 2024-05-30 07:45:34 -05:00
Josh Hawkins
a763ae303d static handlebar size to better match figma (#11638) 2024-05-29 21:34:19 -05:00
Nicolas Mowen
ec88752666 Don't show mark reviewed button when all items are in progress (#11636)
* Don't show mark reviewed button when all items are in progress

* Fix unknown preview file
2024-05-29 19:54:56 -05:00
Josh Hawkins
4135cabf58 assume 1 grid column by default on live dashboard (#11630) 2024-05-29 16:03:59 -06:00
Nicolas Mowen
9fc22efa2d Always save previews in UTC offset (#11629) 2024-05-29 14:55:56 -06:00
Josh Hawkins
37dd3fc25b fix birdseye fullscreen (#11625) 2024-05-29 14:18:51 -05:00
Nicolas Mowen
9e8202874e Remove live mode from config (#11618)
* Use preferred mode as default

* Remove live mode from config

* Add deer icon

* remove from config schema
2024-05-29 13:06:48 -05:00
Nicolas Mowen
9245c5cb56 Improve efficiency of log and metrics pages (#11622)
* Rework stats pages

* Handle limited data case

* Handle page and arrow keys

* Adjust sizing
2024-05-29 12:05:39 -06:00
Josh Hawkins
f1c0422d5e Various bugfixes and improvements (#11624)
* various bugfixes and improvements

* add separator

* no separator
2024-05-29 12:05:28 -06:00
Josh Hawkins
3dd401f57a string or list for camera groups (#11616) 2024-05-29 09:19:05 -05:00
Nicolas Mowen
6dd9660ecd Settings rework (#11613)
* refactor settings to be consistent with other page structure

* Implement non auto live

* Adjust missing view

* Quick fix

* Clarify settings options

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>

* Update naming and config restarts

* Rename

---------

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
2024-05-29 08:01:39 -06:00
Nicolas Mowen
d5f6decd30 Cache camera stream info to speed up future config generations (#11614)
* Cache camera stream info to speed up future config generations

* Formatting

* fix
2024-05-29 07:41:41 -06:00
Nicolas Mowen
cf4517cbdb cache current hour previews (#11606) 2024-05-28 17:35:55 -05:00
Nicolas Mowen
61f79afae9 Always use mse unless webrtc is requrested (#11605) 2024-05-28 17:35:36 -05:00
Nicolas Mowen
5513addab8 UI Fixes (#11602)
* Fix playback rate not showing

* Fix export image

* Formatting

* Formatting
2024-05-28 13:45:08 -06:00
Nicolas Mowen
d064e44571 Fix iOS fullscreen (#11600) 2024-05-28 13:10:42 -06:00
James Tanner-McLeod
c95758580f Draw motion mask first (#11598)
This draws the motion mask before the other overlay elements (such as bounding boxes), so that they are still visible. Fixes #11592
2024-05-28 12:44:20 -06:00
Josh Hawkins
ced5ab203f ensure the correct container is used for canvas calcs (#11599) 2024-05-28 12:41:51 -06:00
Nicolas Mowen
4236580672 UI fixes (#11596)
* Fix using undefined search params

* Fix calendar selection

* Simplify
2024-05-28 13:15:31 -05:00
Josh Hawkins
f7c3ddd380 check if motion dataframe is empty (#11593) 2024-05-28 11:33:28 -06:00
Nicolas Mowen
8546d3d315 Simplify timezone math (#11586)
* Use utc minutes

* Cleanup
2024-05-28 09:09:17 -05:00
Josh Hawkins
2fda383782 clean up unneeded code (#11587) 2024-05-28 08:05:04 -06:00
Josh Hawkins
4165639308 Live view tweaks and jsmpeg bugfix (#11584)
* live view tweaks and jsmpeg bugfix

* use container aspect in check
2024-05-28 08:11:35 -05:00
Nicolas Mowen
6913cc6abc Handle case where preview doesn't automatically changeover (#11583) 2024-05-28 08:11:23 -05:00
Nicolas Mowen
d64633889b Fixes (#11575)
* Fix settings icon

* Handle out of resources
2024-05-27 21:27:01 -05:00
Nicolas Mowen
7bed854ff7 remove libusb build (#11571) 2024-05-27 16:52:19 -06:00
Josh Hawkins
c1330704cf Make jsmpeg players fully responsive (#11567)
* make jsmpeg canvas responsive

* make birdseye responsive too
2024-05-27 16:18:04 -06:00
Nicolas Mowen
5900a2a4ba Add ability to interact with review items in events list (#11562)
* Add ability to interact with review items

* Ignore on iOS

* Don't load metadata

* Bug fixes
2024-05-27 17:12:57 -05:00
Blake Blackshear
bfeb7b8a96 upgrade to latest openvino version (#11563) 2024-05-27 14:49:35 -06:00
Nicolas Mowen
a86e22e0fc Fix live view updating when it shouldn't be (#11561)
* Simplify live image update logic

* Fix case where go2rtc is not setup
2024-05-27 09:50:02 -06:00
Josh Hawkins
c07f6999ca refresh editor value when config is updated (#11559) 2024-05-27 09:31:58 -06:00
Josh Hawkins
eca8c52f15 docs update: how to exclude camera from alerts/detections (#11560) 2024-05-27 09:31:49 -06:00
Nicolas Mowen
be147d218b Fix optimistic state (#11556) 2024-05-27 07:59:26 -05:00
Josh Hawkins
7a9ee63bd3 save video dimensions in onLoadedData instead of onLoadedMetadata (#11545) 2024-05-26 17:48:33 -06:00
Nicolas Mowen
c2eac10925 Tweaks and fixes (#11541)
* Update config version to be stored inside of the config

* Don't remove items from list when navigating back

* Use video api instead of webps for live current hour filmstrip

* Check that the config file is writable

* Show camera name when camera is offline

* Show camera name when offline

* Cleanup
2024-05-26 16:49:12 -05:00
Josh Hawkins
63d81bef45 redirect non existent paths to live view (#11536) 2024-05-26 10:17:52 -06:00
Josh Hawkins
3f171e7670 bugfixes (#11526) 2024-05-25 20:37:53 -06:00
Josh Hawkins
681c7367d7 ensure resizable handles are above jsmpeg canvas elements (#11519) 2024-05-25 15:15:30 -05:00
Marc Altmann
adb043e7ae Update docs for rockchip platform (#11503)
* improve docs for rockchip

* update version info

* fix typo

* fix typo

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* fix typo

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2024-05-25 11:27:44 -06:00
169 changed files with 4762 additions and 2553 deletions

View File

@@ -0,0 +1,83 @@
title: "[Bug]: "
labels: ["bug", "triage"]
body:
- type: textarea
id: description
attributes:
label: Describe the problem you are having
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: Visible on the System page in the Web UI
validations:
required: true
- type: textarea
id: config
attributes:
label: Frigate config file
description: This will be automatically formatted into code, so no need for backticks.
render: yaml
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
validations:
required: true
- type: dropdown
id: os
attributes:
label: Operating system
options:
- HassOS
- Debian
- Other Linux
- Proxmox
- UNRAID
- Windows
- Other
validations:
required: true
- type: dropdown
id: install-method
attributes:
label: Install method
options:
- HassOS Addon
- Docker Compose
- Docker CLI
validations:
required: true
- type: dropdown
id: network
attributes:
label: Network connection
options:
- Wired
- Wireless
- Mixed
validations:
required: true
- type: input
id: camera
attributes:
label: Camera make and model
description: Dahua, hikvision, amcrest, reolink, etc and model number
validations:
required: true
- type: textarea
id: other
attributes:
label: Any other information that may be helpful

1
.github/FUNDING.yml vendored
View File

@@ -1,3 +1,4 @@
github:
- blakeblackshear
- NickM-27
- hawkeye217

View File

@@ -2,4 +2,7 @@ blank_issues_enabled: false
contact_links:
- name: Frigate Support
url: https://github.com/blakeblackshear/frigate/discussions/new/choose
about: Get support for setting up or troubelshooting Frigate.
about: Get support for setting up or troubleshooting Frigate.
- name: Frigate Bug Report
url: https://github.com/blakeblackshear/frigate/discussions/new/choose
about: Report a specific UI or backend bug.

View File

@@ -220,7 +220,7 @@ jobs:
with:
string: ${{ github.repository }}
- name: Log in to the Container registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ghcr.io
username: ${{ github.actor }}

View File

@@ -16,7 +16,7 @@ jobs:
with:
string: ${{ github.repository }}
- name: Log in to the Container registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -24,14 +24,24 @@ jobs:
- name: Create tag variables
run: |
BRANCH=$([[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "master" || echo "dev")
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
echo "BASE=ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}" >> $GITHUB_ENV
echo "BUILD_TAG=${BRANCH}-${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "CLEAN_VERSION=$(echo ${GITHUB_REF##*/} | tr '[:upper:]' '[:lower:]' | sed 's/^[v]//')" >> $GITHUB_ENV
- name: Tag and push the main image
run: |
VERSION_TAG=${BASE}:${CLEAN_VERSION}
STABLE_TAG=${BASE}:stable
PULL_TAG=${BASE}:${BUILD_TAG}
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${VERSION_TAG}
for variant in standard-arm64 tensorrt tensorrt-jp4 tensorrt-jp5 rk; do
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${VERSION_TAG}-${variant}
done
# stable tag
if [[ "${BRANCH}" == "master" ]]; then
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${STABLE_TAG}
for variant in standard-arm64 tensorrt tensorrt-jp4 tensorrt-jp5 rk; do
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${STABLE_TAG}-${variant}
done
fi

3
.gitignore vendored
View File

@@ -16,4 +16,5 @@ web/node_modules
web/coverage
core
!/web/**/*.ts
.idea/*
.idea/*
.ipynb_checkpoints

View File

@@ -29,18 +29,22 @@ If you would like to make a donation to support development, please use [Github
## Screenshots
Integration into Home Assistant
### Live dashboard
<div>
<a href="docs/static/img/media_browser.png"><img src="docs/static/img/media_browser.png" height=400></a>
<a href="docs/static/img/notification.png"><img src="docs/static/img/notification.png" height=400></a>
<img width="800" alt="Live dashboard" src="https://github.com/blakeblackshear/frigate/assets/569905/5e713cb9-9db5-41dc-947a-6937c3bc376e">
</div>
Also comes with a builtin UI:
### Streamlined review workflow
<div>
<a href="docs/static/img/home-ui.png"><img src="docs/static/img/home-ui.png" height=400></a>
<a href="docs/static/img/camera-ui.png"><img src="docs/static/img/camera-ui.png" height=400></a>
<img width="800" alt="Streamlined review workflow" src="https://github.com/blakeblackshear/frigate/assets/569905/6fed96e8-3b18-40e5-9ddc-31e6f3c9f2ff">
</div>
![Events](docs/static/img/events-ui.png)
### Multi-camera scrubbing
<div>
<img width="800" alt="Multi-camera scrubbing" src="https://github.com/blakeblackshear/frigate/assets/569905/d6788a15-0eeb-4427-a8d4-80b93cae3d74">
</div>
### Built-in mask and zone editor
<div>
<img width="800" alt="Multi-camera scrubbing" src="https://github.com/blakeblackshear/frigate/assets/569905/d7885fc3-bfe6-452f-b7d0-d957cb3e31f5">
</div>

View File

@@ -35,13 +35,16 @@ ARG TARGETARCH
WORKDIR /rootfs/usr/local/go2rtc/bin
ADD --link --chmod=755 "https://github.com/AlexxIT/go2rtc/releases/download/v1.9.2/go2rtc_linux_${TARGETARCH}" go2rtc
FROM wget AS tempio
ARG TARGETARCH
RUN --mount=type=bind,source=docker/main/install_tempio.sh,target=/deps/install_tempio.sh \
/deps/install_tempio.sh
####
#
# OpenVino Support
#
# 1. Download and convert a model from Intel's Public Open Model Zoo
# 2. Build libUSB without udev to handle NCS2 enumeration
#
####
# Download and Convert OpenVino model
@@ -57,38 +60,11 @@ RUN apt-get -qq update \
&& pip install -r /requirements-ov.txt
# Get OpenVino Model
RUN mkdir /models \
&& cd /models && omz_downloader --name ssdlite_mobilenet_v2 \
&& cd /models && omz_converter --name ssdlite_mobilenet_v2 --precision FP16
# libUSB - No Udev
FROM wget as libusb-build
ARG TARGETARCH
ARG DEBIAN_FRONTEND
ENV CCACHE_DIR /root/.ccache
ENV CCACHE_MAXSIZE 2G
# Build libUSB without udev. Needed for Openvino NCS2 support
WORKDIR /opt
RUN apt-get update && apt-get install -y unzip build-essential automake libtool ccache pkg-config
RUN --mount=type=cache,target=/root/.ccache wget -q https://github.com/libusb/libusb/archive/v1.0.26.zip -O v1.0.26.zip && \
unzip v1.0.26.zip && cd libusb-1.0.26 && \
./bootstrap.sh && \
./configure CC='ccache gcc' CCX='ccache g++' --disable-udev --enable-shared && \
make -j $(nproc --all)
RUN apt-get update && \
apt-get install -y --no-install-recommends libusb-1.0-0-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /opt/libusb-1.0.26/libusb
RUN /bin/mkdir -p '/usr/local/lib' && \
/bin/bash ../libtool --mode=install /usr/bin/install -c libusb-1.0.la '/usr/local/lib' && \
/bin/mkdir -p '/usr/local/include/libusb-1.0' && \
/usr/bin/install -c -m 644 libusb.h '/usr/local/include/libusb-1.0' && \
/bin/mkdir -p '/usr/local/lib/pkgconfig' && \
cd /opt/libusb-1.0.26/ && \
/usr/bin/install -c -m 644 libusb-1.0.pc '/usr/local/lib/pkgconfig' && \
ldconfig
RUN --mount=type=bind,source=docker/main/build_ov_model.py,target=/build_ov_model.py \
mkdir /models && cd /models \
&& wget http://download.tensorflow.org/models/object_detection/ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz \
&& tar -xvf ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz \
&& python3 /build_ov_model.py
FROM wget AS models
@@ -97,7 +73,8 @@ RUN wget -qO edgetpu_model.tflite https://github.com/google-coral/test_data/raw/
RUN wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite
COPY labelmap.txt .
# Copy OpenVino model
COPY --from=ov-converter /models/public/ssdlite_mobilenet_v2/FP16 openvino-model
COPY --from=ov-converter /models/ssdlite_mobilenet_v2.xml openvino-model/
COPY --from=ov-converter /models/ssdlite_mobilenet_v2.bin openvino-model/
RUN wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt && \
sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt
# Get Audio Model and labels
@@ -158,7 +135,7 @@ RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt
FROM scratch AS deps-rootfs
COPY --from=nginx /usr/local/nginx/ /usr/local/nginx/
COPY --from=go2rtc /rootfs/ /
COPY --from=libusb-build /usr/local/lib /usr/local/lib
COPY --from=tempio /rootfs/ /
COPY --from=s6-overlay /rootfs/ /
COPY --from=models /rootfs/ /
COPY docker/main/rootfs/ /
@@ -176,7 +153,7 @@ ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}"
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/tempio/bin:/usr/local/nginx/sbin:${PATH}"
# Install dependencies
RUN --mount=type=bind,source=docker/main/install_deps.sh,target=/deps/install_deps.sh \
@@ -188,8 +165,6 @@ RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
COPY --from=deps-rootfs / /
RUN ldconfig
EXPOSE 5000
EXPOSE 8554
EXPOSE 8555/tcp 8555/udp

View File

@@ -0,0 +1,11 @@
import openvino as ov
from openvino.tools import mo
ov_model = mo.convert_model(
"/models/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb",
compress_to_fp16=True,
transformations_config="/usr/local/lib/python3.9/dist-packages/openvino/tools/mo/front/tf/ssd_v2_support.json",
tensorflow_object_detection_api_pipeline_config="/models/ssdlite_mobilenet_v2_coco_2018_05_09/pipeline.config",
reverse_input_channels=True,
)
ov.save_model(ov_model, "/models/ssdlite_mobilenet_v2.xml")

16
docker/main/install_tempio.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -euxo pipefail
tempio_version="2021.09.0"
if [[ "${TARGETARCH}" == "amd64" ]]; then
arch="amd64"
elif [[ "${TARGETARCH}" == "arm64" ]]; then
arch="aarch64"
fi
mkdir -p /rootfs/usr/local/tempio/bin
wget -q -O /rootfs/usr/local/tempio/bin/tempio "https://github.com/home-assistant/tempio/releases/download/${tempio_version}/tempio_${arch}"
chmod 755 /rootfs/usr/local/tempio/bin/tempio

View File

@@ -1,5 +1,3 @@
numpy
# Openvino Library - Custom built with MYRIAD support
openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.3.1/openvino-2022.3.1-1-cp39-cp39-manylinux_2_31_x86_64.whl; platform_machine == 'x86_64'
openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.3.1/openvino-2022.3.1-1-cp39-cp39-linux_aarch64.whl; platform_machine == 'aarch64'
openvino-dev[tensorflow2] @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.3.1/openvino_dev-2022.3.1-1-py3-none-any.whl
tensorflow
openvino-dev>=2024.0.0

View File

@@ -2,7 +2,7 @@ click == 8.1.*
Flask == 3.0.*
Flask_Limiter == 3.7.*
imutils == 0.5.*
joserfc == 0.10.*
joserfc == 0.11.*
markupsafe == 2.1.*
matplotlib == 3.8.*
mypy == 1.6.1
@@ -29,7 +29,5 @@ norfair == 2.2.*
setproctitle == 1.3.*
ws4py == 0.5.*
unidecode == 1.3.*
onnxruntime == 1.16.*
# Openvino Library - Custom built with MYRIAD support
openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.3.1/openvino-2022.3.1-1-cp39-cp39-manylinux_2_31_x86_64.whl; platform_machine == 'x86_64'
openvino @ https://github.com/NateMeyer/openvino-wheels/releases/download/multi-arch_2022.3.1/openvino-2022.3.1-1-cp39-cp39-linux_aarch64.whl; platform_machine == 'aarch64'
onnxruntime == 1.18.*
openvino == 2024.1.*

View File

@@ -0,0 +1 @@
certsync

View File

@@ -0,0 +1 @@
certsync-pipeline

View File

@@ -0,0 +1,4 @@
#!/command/with-contenv bash
# shellcheck shell=bash
exec logutil-service /dev/shm/logs/certsync

View File

@@ -0,0 +1 @@
longrun

View File

@@ -0,0 +1,30 @@
#!/command/with-contenv bash
# shellcheck shell=bash
# Take down the S6 supervision tree when the service fails
set -o errexit -o nounset -o pipefail
# Logs should be sent to stdout so that s6 can collect them
declare exit_code_container
exit_code_container=$(cat /run/s6-linux-init-container-results/exitcode)
readonly exit_code_container
readonly exit_code_service="${1}"
readonly exit_code_signal="${2}"
readonly service="CERTSYNC"
echo "[INFO] Service ${service} exited with code ${exit_code_service} (by signal ${exit_code_signal})"
if [[ "${exit_code_service}" -eq 256 ]]; then
if [[ "${exit_code_container}" -eq 0 ]]; then
echo $((128 + exit_code_signal)) >/run/s6-linux-init-container-results/exitcode
fi
if [[ "${exit_code_signal}" -eq 15 ]]; then
exec /run/s6/basedir/bin/halt
fi
elif [[ "${exit_code_service}" -ne 0 ]]; then
if [[ "${exit_code_container}" -eq 0 ]]; then
echo "${exit_code_service}" >/run/s6-linux-init-container-results/exitcode
fi
exec /run/s6/basedir/bin/halt
fi

View File

@@ -0,0 +1 @@
certsync-log

View File

@@ -0,0 +1,58 @@
#!/command/with-contenv bash
# shellcheck shell=bash
# Start the CERTSYNC service
set -o errexit -o nounset -o pipefail
# Logs should be sent to stdout so that s6 can collect them
echo "[INFO] Starting certsync..."
lefile="/etc/letsencrypt/live/frigate/fullchain.pem"
tls_enabled=`python3 /usr/local/nginx/get_tls_settings.py | jq -r .enabled`
while true
do
if [[ "$tls_enabled" == 'false' ]]; then
sleep 9999
continue
fi
if [ ! -e $lefile ]
then
echo "[ERROR] TLS certificate does not exist: $lefile"
fi
leprint=`openssl x509 -in $lefile -fingerprint -noout 2>&1 || echo 'failed'`
case "$leprint" in
*Fingerprint*)
;;
*)
echo "[ERROR] Missing fingerprint from $lefile"
;;
esac
liveprint=`echo | openssl s_client -showcerts -connect 127.0.0.1:8080 2>&1 | openssl x509 -fingerprint 2>&1 | grep -i fingerprint || echo 'failed'`
case "$liveprint" in
*Fingerprint*)
;;
*)
echo "[ERROR] Missing fingerprint from current nginx TLS cert"
;;
esac
if [[ "$leprint" != "failed" && "$liveprint" != "failed" && "$leprint" != "$liveprint" ]]
then
echo "[INFO] Reloading nginx to refresh TLS certificate"
echo "$lefile: $leprint"
/usr/local/nginx/sbin/nginx -s reload
fi
sleep 60
done
exit 0

View File

@@ -0,0 +1 @@
30000

View File

@@ -0,0 +1 @@
longrun

View File

@@ -4,7 +4,7 @@
set -o errexit -o nounset -o pipefail
dirs=(/dev/shm/logs/frigate /dev/shm/logs/go2rtc /dev/shm/logs/nginx)
dirs=(/dev/shm/logs/frigate /dev/shm/logs/go2rtc /dev/shm/logs/nginx /dev/shm/logs/certsync)
mkdir -p "${dirs[@]}"
chown nobody:nogroup "${dirs[@]}"

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
# Wait for PID file to exist.
while ! test -f /run/nginx.pid; do sleep 1; done

View File

@@ -0,0 +1 @@
3

View File

@@ -8,6 +8,84 @@ set -o errexit -o nounset -o pipefail
echo "[INFO] Starting NGINX..."
# Taken from https://github.com/felipecrs/cgroup-scripts/commits/master/get_cpus.sh
function get_cpus() {
local quota=""
local period=""
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
if [ -f /sys/fs/cgroup/cpu.max ]; then
read -r quota period </sys/fs/cgroup/cpu.max
if [ "$quota" = "max" ]; then
quota=""
period=""
fi
else
echo "[WARN] /sys/fs/cgroup/cpu.max not found. Falling back to /proc/cpuinfo." >&2
fi
else
if [ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ] && [ -f /sys/fs/cgroup/cpu/cpu.cfs_period_us ]; then
quota=$(cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
period=$(cat /sys/fs/cgroup/cpu/cpu.cfs_period_us)
if [ "$quota" = "-1" ]; then
quota=""
period=""
fi
else
echo "[WARN] /sys/fs/cgroup/cpu/cpu.cfs_quota_us or /sys/fs/cgroup/cpu/cpu.cfs_period_us not found. Falling back to /proc/cpuinfo." >&2
fi
fi
local cpus
if [ -n "${quota}" ] && [ -n "${period}" ]; then
cpus=$((quota / period))
if [ "$cpus" -eq 0 ]; then
cpus=1
fi
else
cpus=$(grep -c ^processor /proc/cpuinfo)
fi
printf '%s' "$cpus"
}
function set_worker_processes() {
# Capture number of assigned CPUs to calculate worker processes
local cpus
cpus=$(get_cpus)
if [[ "${cpus}" -gt 4 ]]; then
cpus=4
fi
# we need to catch any errors because sed will fail if user has bind mounted a custom nginx file
sed -i "s/worker_processes auto;/worker_processes ${cpus};/" /usr/local/nginx/conf/nginx.conf || true
}
set_worker_processes
# ensure the directory for ACME challenges exists
mkdir -p /etc/letsencrypt/www
# Create self signed certs if needed
letsencrypt_path=/etc/letsencrypt/live/frigate
mkdir -p $letsencrypt_path
if [ ! \( -f "$letsencrypt_path/privkey.pem" -a -f "$letsencrypt_path/fullchain.pem" \) ]; then
echo "[INFO] No TLS certificate found. Generating a self signed certificate..."
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
-subj "/O=FRIGATE DEFAULT CERT/CN=*" \
-keyout "$letsencrypt_path/privkey.pem" -out "$letsencrypt_path/fullchain.pem" 2>/dev/null
fi
# build templates for optional TLS support
python3 /usr/local/nginx/get_tls_settings.py | \
tempio -template /usr/local/nginx/templates/listen.gotmpl \
-out /usr/local/nginx/conf/listen.conf
# Replace the bash process with the NGINX process, redirecting stderr to stdout
exec 2>&1
exec nginx
exec \
s6-notifyoncheck -t 30000 -n 1 \
nginx

View File

@@ -0,0 +1,80 @@
0 person
1 bicycle
2 car
3 motorcycle
4 airplane
5 car
6 train
7 car
8 boat
9 traffic light
10 fire hydrant
11 stop sign
12 parking meter
13 bench
14 bird
15 cat
16 dog
17 horse
18 sheep
19 cow
20 elephant
21 bear
22 zebra
23 giraffe
24 backpack
25 umbrella
26 handbag
27 tie
28 suitcase
29 frisbee
30 skis
31 snowboard
32 sports ball
33 kite
34 baseball bat
35 baseball glove
36 skateboard
37 surfboard
38 tennis racket
39 bottle
40 wine glass
41 cup
42 fork
43 knife
44 spoon
45 bowl
46 banana
47 apple
48 sandwich
49 orange
50 broccoli
51 carrot
52 hot dog
53 pizza
54 donut
55 cake
56 chair
57 couch
58 potted plant
59 bed
60 dining table
61 toilet
62 tv
63 laptop
64 mouse
65 remote
66 keyboard
67 cell phone
68 microwave
69 oven
70 toaster
71 sink
72 refrigerator
73 book
74 clock
75 vase
76 scissors
77 teddy bear
78 hair drier
79 toothbrush

View File

@@ -0,0 +1,91 @@
0 person
1 bicycle
2 car
3 motorcycle
4 airplane
5 bus
6 train
7 car
8 boat
9 traffic light
10 fire hydrant
11 street sign
12 stop sign
13 parking meter
14 bench
15 bird
16 cat
17 dog
18 horse
19 sheep
20 cow
21 elephant
22 bear
23 zebra
24 giraffe
25 hat
26 backpack
27 umbrella
28 shoe
29 eye glasses
30 handbag
31 tie
32 suitcase
33 frisbee
34 skis
35 snowboard
36 sports ball
37 kite
38 baseball bat
39 baseball glove
40 skateboard
41 surfboard
42 tennis racket
43 bottle
44 plate
45 wine glass
46 cup
47 fork
48 knife
49 spoon
50 bowl
51 banana
52 apple
53 sandwich
54 orange
55 broccoli
56 carrot
57 hot dog
58 pizza
59 donut
60 cake
61 chair
62 couch
63 potted plant
64 bed
65 mirror
66 dining table
67 window
68 desk
69 toilet
70 door
71 tv
72 laptop
73 mouse
74 remote
75 keyboard
76 cell phone
77 microwave
78 oven
79 toaster
80 sink
81 refrigerator
82 blender
83 book
84 clock
85 vase
86 scissors
87 teddy bear
88 hair drier
89 toothbrush
90 hair brush

View File

@@ -0,0 +1,4 @@
upstream go2rtc {
server 127.0.0.1:1984;
keepalive 1024;
}

View File

@@ -56,17 +56,14 @@ http {
keepalive 1024;
}
upstream go2rtc {
server 127.0.0.1:1984;
keepalive 1024;
}
include go2rtc_upstream.conf;
server {
# intended for external traffic, protected by auth
listen [::]:8080 ipv6only=off;
# intended for internal traffic, not protected by auth
listen [::]:5000 ipv6only=off;
include listen.conf;
# vod settings
vod_base_url '';
vod_segments_base_url '';
@@ -134,6 +131,8 @@ http {
image/jpeg jpg;
}
expires 7d;
add_header Cache-Control "public";
autoindex on;
root /media/frigate;
}

View File

@@ -0,0 +1,28 @@
"""Prints the tls config as json to stdout."""
import json
import os
import yaml
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
# Check if we can use .yaml instead of .yml
config_file_yaml = config_file.replace(".yml", ".yaml")
if os.path.isfile(config_file_yaml):
config_file = config_file_yaml
try:
with open(config_file) as f:
raw_config = f.read()
if config_file.endswith((".yaml", ".yml")):
config: dict[str, any] = yaml.safe_load(raw_config)
elif config_file.endswith(".json"):
config: dict[str, any] = json.loads(raw_config)
except FileNotFoundError:
config: dict[str, any] = {}
tls_config: dict[str, any] = config.get("tls", {})
print(json.dumps(tls_config))

View File

@@ -0,0 +1,30 @@
{{ if not .enabled }}
# intended for external traffic, protected by auth
listen [::]:8080 ipv6only=off;
{{ else }}
# intended for external traffic, protected by auth
listen [::]:8080 ipv6only=off ssl;
ssl_certificate /etc/letsencrypt/live/frigate/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/frigate/privkey.pem;
# generated 2024-06-01, Mozilla Guideline v5.7, nginx 1.25.3, OpenSSL 1.1.1w, modern configuration, no OCSP
# https://ssl-config.mozilla.org/#server=nginx&version=1.25.3&config=modern&openssl=1.1.1w&ocsp=false&guideline=5.7
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
# modern configuration
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
add_header Strict-Transport-Security "max-age=63072000" always;
# ACME challenge location
location /.well-known/acme-challenge/ {
default_type "text/plain";
root /etc/letsencrypt/www;
}
{{ end }}

View File

@@ -22,5 +22,5 @@ ADD https://github.com/MarcA711/rknn-toolkit2/releases/download/v2.0.0/librknnrt
RUN rm -rf /usr/lib/btbn-ffmpeg/bin/ffmpeg
RUN rm -rf /usr/lib/btbn-ffmpeg/bin/ffprobe
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-3/ffmpeg /usr/lib/btbn-ffmpeg/bin/
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-3/ffprobe /usr/lib/btbn-ffmpeg/bin/
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffmpeg /usr/lib/btbn-ffmpeg/bin/
ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffprobe /usr/lib/btbn-ffmpeg/bin/

View File

@@ -5,30 +5,26 @@ title: Authentication
# Authentication
## Modes
Frigate supports two modes for authentication
| Mode | Description |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `native` | (default) Use this mode if you don't implement authentication with a proxy in front of Frigate. |
| `proxy` | Use this mode if you have an existing proxy for authentication. Supports passing authenticated user downstream to Frigate for role-based authorization (future implementation). |
### Native mode
Frigate stores user information in its database. Password hashes are generated using industry standard PBKDF2-SHA256 with 600,000 iterations. Upon successful login, a JWT token is issued with an expiration date and set as a cookie. The cookie is refreshed as needed automatically. This JWT token can also be passed in the Authorization header as a bearer token.
Users are managed in the UI under Settings > Users.
#### Onboarding
The following ports are available to access the Frigate web UI.
| Port | Description |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `8080` | Authenticated UI and API. Reverse proxies should use this port. |
| `5000` | Internal unauthenticated UI and API access. Access to this port should be limited. Intended to be used within the docker network for services that integrate with Frigate and do not support authentication. |
## Onboarding
On startup, an admin user and password are generated and printed in the logs. It is recommended to set a new password for the admin account after logging in for the first time under Settings > Users.
#### Resetting admin password
## Resetting admin password
In the event that you are locked out of your instance, you can tell Frigate to reset the admin password and print it in the logs on next startup using the `reset_admin_password` setting in your config file.
#### Login failure rate limiting
## Login failure rate limiting
In order to limit the risk of brute force attacks, rate limiting is available for login failures. This is implemented with Flask-Limiter, and the string notation for valid values is available in [the documentation](https://flask-limiter.readthedocs.io/en/stable/configuration.html#rate-limit-string-notation).
@@ -46,22 +42,60 @@ If you are running a reverse proxy in the same docker compose file as Frigate, h
```yaml
auth:
mode: native
failed_login_rate_limit: "1/second;5/minute;20/hour"
trusted_proxies:
- 172.18.0.0/16 # <---- this is the subnet for the internal docker compose network
```
### Proxy mode
## JWT Token Secret
Proxy mode is designed to complement common upstream authentication proxies such as Authelia, Authentik, oauth2_proxy, or traefik-forward-auth.
The JWT token secret needs to be kept secure. Anyone with this secret can generate valid JWT tokens to authenticate with Frigate. This should be a cryptographically random string of at least 64 characters.
#### Header mapping
You can generate a token using the Python secret library with the following command:
If your proxy supports passing a header with the authenticated username, you can use the `header_map` config to specify the header name so it is passed to Frigate. For example, the following will map the `X-Forwarded-User` value. Header names are not case sensitive.
```shell
python3 -c 'import secrets; print(secrets.token_hex(64))'
```
Frigate looks for a JWT token secret in the following order:
1. An environment variable named `FRIGATE_JWT_SECRET`
2. A docker secret named `FRIGATE_JWT_SECRET` in `/run/secrets/`
3. A `jwt_secret` option from the Home Assistant Addon options
4. A `.jwt_secret` file in the config directory
If no secret is found on startup, Frigate generates one and stores it in a `.jwt_secret` file in the config directory.
Changing the secret will invalidate current tokens.
## Proxy configuration
Frigate can be configured to leverage features of common upstream authentication proxies such as Authelia, Authentik, oauth2_proxy, or traefik-forward-auth.
If you are leveraging the authentication of an upstream proxy, you likely want to disable Frigate's authentication. Optionally, if communication between the reverse proxy and Frigate is over an untrusted network, you should set an `auth_secret` in the `proxy` config and configure the proxy to send the secret value as a header named `X-Proxy-Secret`. Assuming this is an untrusted network, you will also want to [configure a real TLS certificate](tls.md) to ensure the traffic can't simply be sniffed to steal the secret.
Here is an example of how to disable Frigate's authentication and also ensure the requests come only from your known proxy.
```yaml
auth:
enabled: False
proxy:
auth_secret: <some random long string>
```
You can use the following code to generate a random secret.
```shell
python3 -c 'import secrets; print(secrets.token_hex(64))'
```
### Header mapping
If you have disabled Frigate's authentication and your proxy supports passing a header with the authenticated username, you can use the `header_map` config to specify the header name so it is passed to Frigate. For example, the following will map the `X-Forwarded-User` value. Header names are not case sensitive.
```yaml
proxy:
...
header_map:
user: x-forwarded-user
@@ -89,10 +123,10 @@ If you would like to add more options, you can overwrite the default file with a
Future versions of Frigate may leverage group and role headers for authorization in Frigate as well.
#### Login page redirection
### Login page redirection
Frigate gracefully performs login page redirection that should work with most authentication proxies. If your reverse proxy returns a `Location` header on `401`, `302`, or `307` unauthorized responses, Frigate's frontend will automatically detect it and redirect to that URL.
#### Custom logout url
### Custom logout url
If your reverse proxy has a dedicated logout url, you can specify using the `logout_url` config option. This will update the link for the `Logout` link in the UI.

View File

@@ -79,7 +79,7 @@ This list of working and non-working PTZ cameras is based on user feedback.
| Brand or specific camera | PTZ Controls | Autotracking | Notes |
| ------------------------ | :----------: | :----------: | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| Amcrest | ✅ | ✅ | ⛔️ Generally, Amcrest should work, but some older models (like the common IP2M-841) don't support auto tracking |
| Amcrest | ✅ | ✅ | ⛔️ Generally, Amcrest should work, but some older models (like the common IP2M-841) don't support autotracking |
| Amcrest ASH21 | ❌ | ❌ | No ONVIF support |
| Ctronics PTZ | ✅ | ❌ | |
| Dahua | ✅ | ✅ | |
@@ -91,11 +91,7 @@ This list of working and non-working PTZ cameras is based on user feedback.
| Reolink E1 Zoom | ✅ | ❌ | |
| Reolink RLC-823A 16x | ✅ | ❌ | |
| Sunba 405-D20X | ✅ | ❌ | |
| Tapo C200 | ✅ | ❌ | Incomplete ONVIF support |
| Tapo C210 | ✅ | ❌ | Incomplete ONVIF support, ONVIF Service Port: 2020 |
| Tapo C220 | ✅ | ❌ | Incomplete ONVIF support, ONVIF Service Port: 2020 |
| Tapo C225 | ✅ | ❌ | Incomplete ONVIF support, ONVIF Service Port: 2020 |
| Tapo C520WS | ✅ | ❌ | Incomplete ONVIF support, ONVIF Service Port: 2020 |
| Tapo | ✅ | ❌ | Many models supported, ONVIF Service Port: 2020 |
| Uniview IPC672LR-AX4DUPK | ✅ | ❌ | Firmware says FOV relative movement is supported, but camera doesn't actually move when sending ONVIF commands |
| Vikylin PTZ-2804X-I2 | ❌ | ❌ | Incomplete ONVIF support |

View File

@@ -13,7 +13,7 @@ Depending on your system, these parameters may not be compatible. More informati
## Raspberry Pi 3/4
Ensure you increase the allocated RAM for your GPU to at least 128 (`raspi-config` > Performance Options > GPU Memory).
Ensure you increase the allocated RAM for your GPU to at least 128 (`raspi-config` > Performance Options > GPU Memory).
If you are using the HA addon, you may need to use the full access variant and turn off `Protection mode` for hardware acceleration.
```yaml
@@ -67,7 +67,7 @@ Or map in all the `/dev/video*` devices.
### Via VAAPI
VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams. VAAPI is recommended for all generations of Intel-based CPUs if QSV does not work.
VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams. VAAPI is recommended for all generations of Intel-based CPUs.
```yaml
ffmpeg:
@@ -82,7 +82,7 @@ With some of the processors, like the J4125, the default driver `iHD` doesn't se
### Via Quicksync (>=10th Generation only)
QSV must be set specifically based on the video encoding of the stream.
If VAAPI does not work for you, you can try QSV if your processor supports it. QSV must be set specifically based on the video encoding of the stream.
#### H.264 streams
@@ -362,39 +362,11 @@ that NVDEC/NVDEC1 are in use.
## Rockchip platform
Hardware accelerated video de-/encoding is supported on all Rockchip SoCs using [Nyanmisaka's FFmpeg Fork](https://github.com/nyanmisaka/ffmpeg-rockchip) based on [Rockchip's mpp library](https://github.com/rockchip-linux/mpp).
Hardware accelerated video de-/encoding is supported on all Rockchip SoCs using [Nyanmisaka's FFmpeg 6.1 Fork](https://github.com/nyanmisaka/ffmpeg-rockchip) based on [Rockchip's mpp library](https://github.com/rockchip-linux/mpp).
### Prerequisites
Make sure that you use a linux distribution that comes with the rockchip BSP kernel 5.10 or 6.1 and rkvdec2 driver. To check, enter the following commands:
```
$ uname -r
5.10.xxx-rockchip # or 6.1.xxx; the -rockchip suffix is important
$ ls /dev/dri
by-path card0 card1 renderD128 renderD129 # should list renderD128
```
I recommend [Joshua Riek's Ubuntu for Rockchip](https://github.com/Joshua-Riek/ubuntu-rockchip), if your board is supported.
### Setup
Follow Frigate's default installation instructions, but use a docker image with `-rk` suffix for example `ghcr.io/blakeblackshear/frigate:stable-rk`.
Next, you need to grant docker permissions to access your hardware:
- During the configuration process, you should run docker in privileged mode to avoid any errors due to insufficient permissions. To do so, add `privileged: true` to your `docker-compose.yml` file or the `--privileged` flag to your docker run command.
- After everything works, you should only grant necessary permissions to increase security. Add the lines below to your `docker-compose.yml` file or the following options to your docker run command: `--security-opt systempaths=unconfined --security-opt apparmor=unconfined --device /dev/dri:/dev/dri --device /dev/dma_heap:/dev/dma_heap --device /dev/rga:/dev/rga --device /dev/mpp_service:/dev/mpp_service`:
```yaml
security_opt:
- apparmor=unconfined
- systempaths=unconfined
devices:
- /dev/dri:/dev/dri
- /dev/dma_heap:/dev/dma_heap
- /dev/rga:/dev/rga
- /dev/mpp_service:/dev/mpp_service
```
Make sure to follow the [Rockchip specific installation instructions](/frigate/installation#rockchip-platform).
### Configuration

View File

@@ -109,9 +109,13 @@ detectors:
The OpenVINO detector type runs an OpenVINO IR model on AMD and Intel CPUs, Intel GPUs and Intel VPU hardware. To configure an OpenVINO detector, set the `"type"` attribute to `"openvino"`.
The OpenVINO device to be used is specified using the `"device"` attribute according to the naming conventions in the [Device Documentation](https://docs.openvino.ai/latest/openvino_docs_OV_UG_Working_with_devices.html). Other supported devices could be `AUTO`, `CPU`, `GPU`, `MYRIAD`, etc. If not specified, the default OpenVINO device will be selected by the `AUTO` plugin.
The OpenVINO device to be used is specified using the `"device"` attribute according to the naming conventions in the [Device Documentation](https://docs.openvino.ai/2024/openvino-workflow/running-inference/inference-devices-and-modes.html). The most common devices are `CPU` and `GPU`. Currently, there is a known issue with using `AUTO`. For backwards compatibility, Frigate will attempt to use `GPU` if `AUTO` is set in your configuration.
OpenVINO is supported on 6th Gen Intel platforms (Skylake) and newer. It will also run on AMD CPUs despite having no official support for it. A supported Intel platform is required to use the `GPU` device with OpenVINO. The `MYRIAD` device may be run on any platform, including Arm devices. For detailed system requirements, see [OpenVINO System Requirements](https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/system-requirements.html)
OpenVINO is supported on 6th Gen Intel platforms (Skylake) and newer. It will also run on AMD CPUs despite having no official support for it. A supported Intel platform is required to use the `GPU` device with OpenVINO. For detailed system requirements, see [OpenVINO System Requirements](https://docs.openvino.ai/2024/about-openvino/release-notes-openvino/system-requirements.html)
### Supported Models
#### SSDLite MobileNet v2
An OpenVINO model is provided in the container at `/openvino-model/ssdlite_mobilenet_v2.xml` and is used by this detector type by default. The model comes from Intel's Open Model Zoo [SSDLite MobileNet V2](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/ssdlite_mobilenet_v2) and is converted to an FP16 precision IR model. Use the model configuration shown below when using the OpenVINO detector with the default model.
@@ -119,27 +123,26 @@ An OpenVINO model is provided in the container at `/openvino-model/ssdlite_mobil
detectors:
ov:
type: openvino
device: AUTO
model:
path: /openvino-model/ssdlite_mobilenet_v2.xml
device: GPU
model:
width: 300
height: 300
input_tensor: nhwc
input_pixel_format: bgr
path: /openvino-model/ssdlite_mobilenet_v2.xml
labelmap_path: /openvino-model/coco_91cl_bkgr.txt
```
This detector also supports YOLOX. Other YOLO variants are not officially supported/tested. Frigate does not come with any yolo models preloaded, so you will need to supply your own models. This detector has been verified to work with the [yolox_tiny](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/yolox-tiny) model from Intel's Open Model Zoo. You can follow [these instructions](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/yolox-tiny#download-a-model-and-convert-it-into-openvino-ir-format) to retrieve the OpenVINO-compatible `yolox_tiny` model. Make sure that the model input dimensions match the `width` and `height` parameters, and `model_type` is set accordingly. See [Full Configuration Reference](/configuration/reference.md) for a list of possible `model_type` options. Below is an example of how `yolox_tiny` can be used in Frigate:
#### YOLOX
This detector also supports YOLOX. Frigate does not come with any YOLOX models preloaded, so you will need to supply your own models. This detector has been verified to work with the [yolox_tiny](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/yolox-tiny) model from Intel's Open Model Zoo. You can follow [these instructions](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/yolox-tiny#download-a-model-and-convert-it-into-openvino-ir-format) to retrieve the OpenVINO-compatible `yolox_tiny` model. Make sure that the model input dimensions match the `width` and `height` parameters, and `model_type` is set accordingly. See [Full Configuration Reference](/configuration/reference.md) for a list of possible `model_type` options. Below is an example of how `yolox_tiny` can be used in Frigate:
```yaml
detectors:
ov:
type: openvino
device: AUTO
model:
path: /path/to/yolox_tiny.xml
device: GPU
model:
width: 416
@@ -147,38 +150,41 @@ model:
input_tensor: nchw
input_pixel_format: bgr
model_type: yolox
path: /path/to/yolox_tiny.xml
labelmap_path: /path/to/coco_80cl.txt
```
### Intel NCS2 VPU and Myriad X Setup
#### YOLO-NAS
Intel produces a neural net inference acceleration chip called Myriad X. This chip was sold in their Neural Compute Stick 2 (NCS2) which has been discontinued. If intending to use the MYRIAD device for acceleration, additional setup is required to pass through the USB device. The host needs a udev rule installed to handle the NCS2 device.
[YOLO-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md) models are supported, but not included by default. You can build and download a compatible model with pre-trained weights using [this notebook](https://github.com/frigate/blob/dev/notebooks/YOLO_NAS_Pretrained_Export.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/blakeblackshear/frigate/blob/dev/notebooks/YOLO_NAS_Pretrained_Export.ipynb).
```bash
sudo usermod -a -G users "$(whoami)"
cat <<EOF > 97-myriad-usbboot.rules
SUBSYSTEM=="usb", ATTRS{idProduct}=="2485", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="usb", ATTRS{idProduct}=="f63b", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
EOF
sudo cp 97-myriad-usbboot.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
:::warning
The pre-trained YOLO-NAS weights from DeciAI are subject to their license and can't be used commercially. For more information, see: https://docs.deci.ai/super-gradients/latest/LICENSE.YOLONAS.html
:::
The input image size in this notebook is set to 320x320. This results in lower CPU usage and faster inference times without impacting performance in most cases due to the way Frigate crops video frames to areas of interest before running detection. The notebook and config can be updated to 640x640 if desired.
After placing the downloaded onnx model in your config folder, you can use the following configuration:
```yaml
detectors:
ov:
type: openvino
device: GPU
model:
model_type: yolonas
width: 320 # <--- should match whatever was set in notebook
height: 320 # <--- should match whatever was set in notebook
input_tensor: nchw
input_pixel_format: bgr
path: /config/yolo_nas_s.onnx
labelmap_path: /labelmap/coco-80.txt
```
Additionally, the Frigate docker container needs to run with the following configuration:
```bash
--device-cgroup-rule='c 189:\* rmw' -v /dev/bus/usb:/dev/bus/usb
```
or in your compose file:
```yml
device_cgroup_rules:
- "c 189:* rmw"
volumes:
- /dev/bus/usb:/dev/bus/usb
```
Note that the labelmap uses a subset of the complete COCO label set that has only 80 objects.
## NVidia TensorRT Detector
@@ -313,39 +319,11 @@ Hardware accelerated object detection is supported on the following SoCs:
- RK3576
- RK3588
This implementation uses the [Rockchip's RKNN-Toolkit2](https://github.com/airockchip/rknn-toolkit2/) Currently, only [Yolo-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md) is supported as object detection model.
This implementation uses the [Rockchip's RKNN-Toolkit2](https://github.com/airockchip/rknn-toolkit2/), version v2.0.0.beta0. Currently, only [Yolo-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md) is supported as object detection model.
### Prerequisites
Make sure that you use a linux distribution that comes with the rockchip BSP kernel 5.10 or 6.1 and rknpu driver. To check, enter the following commands:
```
$ uname -r
5.10.xxx-rockchip # or 6.1.xxx; the -rockchip suffix is important
$ ls /dev/dri
by-path card0 card1 renderD128 renderD129 # should list renderD129
$ sudo cat /sys/kernel/debug/rknpu/version
RKNPU driver: v0.9.2 # or later version
```
I recommend [Joshua Riek's Ubuntu for Rockchip](https://github.com/Joshua-Riek/ubuntu-rockchip), if your board is supported.
### Setup
Follow Frigate's default installation instructions, but use a docker image with `-rk` suffix for example `ghcr.io/blakeblackshear/frigate:stable-rk`.
Next, you need to grant docker permissions to access your hardware:
- During the configuration process, you should run docker in privileged mode to avoid any errors due to insufficient permissions. To do so, add `privileged: true` to your `docker-compose.yml` file or the `--privileged` flag to your docker run command.
- After everything works, you should only grant necessary permissions to increase security. Add the lines below to your `docker-compose.yml` file or the following options to your docker run command: `--security-opt systempaths=unconfined --security-opt apparmor=unconfined --device /dev/dri:/dev/dri`:
```yaml
security_opt:
- apparmor=unconfined
- systempaths=unconfined
devices:
- /dev/dri:/dev/dri
```
Make sure to follow the [Rockchip specific installation instrucitions](/frigate/installation#rockchip-platform).
### Configuration
@@ -376,13 +354,21 @@ model: # required
input_pixel_format: bgr # required
# shape of detection frame
input_tensor: nhwc
# needs to be adjusted to model, see below
labelmap_path: /labelmap.txt # required
```
The correct labelmap must be loaded for each model. If you use a custom model (see notes below), you must make sure to provide the correct labelmap. The table below lists the correct paths for the bundled models:
| `path` | `labelmap_path` |
| --------------------- | --------------------- |
| deci-fp16-yolonas\_\* | /labelmap/coco-80.txt |
### Choosing a model
:::warning
yolo-nas models use weights from DeciAI. These weights are subject to their license and can't be used commercially. For more information, see: https://docs.deci.ai/super-gradients/latest/LICENSE.YOLONAS.html
The pre-trained YOLO-NAS weights from DeciAI are subject to their license and can't be used commercially. For more information, see: https://docs.deci.ai/super-gradients/latest/LICENSE.YOLONAS.html
:::
@@ -405,6 +391,5 @@ $ cat /sys/kernel/debug/rknpu/load
:::
- By default the rknn detector uses the yolonas_s model (`model: path: default-fp16-yolonas_s`). This model comes with the image, so no further steps than those mentioned above are necessary and no download happens.
- The other choices are automatically downloaded and stored in the folder `config/model_cache/rknn_cache`. After upgrading Frigate, you should remove older models to free up space.
- Finally, you can also provide your own `.rknn` model. You should not save your own models in the `rknn_cache` folder, store them directly in the `model_cache` folder or another subfolder. To convert a model to `.rknn` format see the `rknn-toolkit2` (requires a x86 machine). Note, that there is only post-processing for the supported models.
- All models are automatically downloaded and stored in the folder `config/model_cache/rknn_cache`. After upgrading Frigate, you should remove older models to free up space.
- You can also provide your own `.rknn` model. You should not save your own models in the `rknn_cache` folder, store them directly in the `model_cache` folder or another subfolder. To convert a model to `.rknn` format see the `rknn-toolkit2` (requires a x86 machine). Note, that there is only post-processing for the supported models.

View File

@@ -36,7 +36,7 @@ False positives can also be reduced by filtering a detection based on its shape.
### Object Area
`min_area` and `max_area` filter on the area of an objects bounding box in pixels and can be used to reduce false positives that are outside the range of expected sizes. For example when a leaf is detected as a dog or when a large tree is detected as a person, these can be reduced by adding a `min_area` / `max_area` filter. The recordings timeline can be used to determine the area of the bounding box in that frame by selecting a timeline item then mousing over or tapping the red box.
`min_area` and `max_area` filter on the area of an objects bounding box in pixels and can be used to reduce false positives that are outside the range of expected sizes. For example when a leaf is detected as a dog or when a large tree is detected as a person, these can be reduced by adding a `min_area` / `max_area` filter.
### Object Proportions

View File

@@ -63,11 +63,31 @@ database:
# The path to store the SQLite DB (default: shown below)
path: /config/frigate.db
# Optional: TLS configuration
tls:
# Optional: Enable TLS for port 8080 (default: shown below)
enabled: True
# Optional: Proxy configuration
proxy:
# Optional: Mapping for headers from upstream proxies. Only used if Frigate's auth
# is disabled.
# NOTE: Many authentication proxies pass a header downstream with the authenticated
# user name. Not all values are supported. It must be a whitelisted header.
# See the docs for more info.
header_map:
user: x-forwarded-user
# Optional: Url for logging out a user. This sets the location of the logout url in
# the UI.
logout_url: /api/logout
# Optional: Auth secret that is checked against the X-Proxy-Secret header sent from
# the proxy. If not set, all requests are trusted regardless of origin.
auth_secret: None
# Optional: Authentication configuration
auth:
# Optional: Authentication mode (default: shown below)
# Valid values are: native, proxy
mode: native
# Optional: Enable authentication
enabled: True
# Optional: Reset the admin user password on startup (default: shown below)
# New password is printed in the logs
reset_admin_password: False
@@ -82,23 +102,14 @@ auth:
# When the session is going to expire in less time than this setting,
# it will be refreshed back to the session_length.
refresh_time: 43200 # 12 hours
# Optional: Mapping for headers from upstream proxies. Only used in proxy auth mode.
# NOTE: Many authentication proxies pass a header downstream with the authenticated
# user name. Not all values are supported. It must be a whitelisted header.
# See the docs for more info.
header_map:
user: x-forwarded-user
# Optional: Rate limiting for login failures to help prevent brute force
# login attacks (default: shown below)
# See the docs for more information on valid values
failed_login_rate_limit: None
# Optional: Trusted proxies for determining IP address to rate limit
# NOTE: This is only used for rate limiting login attempts and does not bypass
# authentication in any way
# authentication. See the authentication docs for more details.
trusted_proxies: []
# Optional: Url for logging out a user. This only needs to be set if you are using
# proxy mode.
logout_url: /api/logout
# Optional: Number of hashing iterations for user passwords
# As of Feb 2023, OWASP recommends 600000 iterations for PBKDF2-SHA256
# NOTE: changing this value will not automatically update password hashes, you
@@ -645,8 +656,6 @@ cameras:
# Optional
ui:
# Optional: Set the default live mode for cameras in the UI (default: shown below)
live_mode: mse
# Optional: Set a timezone to use in the UI (default: use browser local time)
# timezone: America/Denver
# Optional: Set the time format used.

View File

@@ -11,7 +11,7 @@ Frigate uses [go2rtc](https://github.com/AlexxIT/go2rtc/tree/v1.9.2) to provide
:::note
You can access the go2rtc stream info at `http://frigate_ip:8080/api/go2rtc/streams` which can be helpful to debug as well as provide useful information about your camera streams.
You can access the go2rtc stream info at `/api/go2rtc/streams` which can be helpful to debug as well as provide useful information about your camera streams.
:::

View File

@@ -42,6 +42,20 @@ review:
- dog
```
## Excluding a camera from alerts or detections
To exclude a specific camera from alerts or detections, simply provide an empty list to the alerts or detections field _at the camera level_.
For example, to exclude objects on the camera _gatecamera_ from any detections, include this in your config:
```yaml
cameras:
gatecamera:
review:
detections:
labels: []
```
## Restricting review items to specific zones
By default a review item will be created if any `review -> alerts -> labels` and `review -> detections -> labels` are detected anywhere in the camera frame. You will likely want to configure review items to only be created when the object enters an area of interest, [see the zone docs for more information](./zones.md#restricting-alerts-and-detections-to-specific-zones)

View File

@@ -0,0 +1,47 @@
---
id: tls
title: TLS
---
# TLS
Frigate's integrated NGINX server supports TLS certificates. By default Frigate will generate a self signed certificate that will be used for port 8080. Frigate is designed to make it easy to use whatever tool you prefer to manage certificates.
Frigate is often running behind a reverse proxy that manages TLS certificates for multiple services. You will likely need to set your reverse proxy to allow self signed certificates or you can disable TLS in Frigate's config. However, if you are running on a dedicated device that's separate from your proxy or if you expose Frigate directly to the internet, you may want to configure TLS with valid certificates.
In many deployments, TLS will be unnecessary. It can be disabled in the config with the following yaml:
```yaml
tls:
enabled: False
```
## Certificates
TLS certificates can be mounted at `/etc/letsencrypt/live/frigate` using a bind mount or docker volume.
```yaml
frigate:
...
volumes:
- /path/to/your/certificate_folder:/etc/letsencrypt/live/frigate
...
```
Within the folder, the private key is expected to be named `privkey.pem` and the certificate is expected to be named `fullchain.pem`.
Frigate automatically compares the fingerprint of the certificate at `/etc/letsencrypt/live/frigate/fullchain.pem` against the fingerprint of the TLS cert in NGINX every minute. If these differ, the NGINX config is reloaded to pick up the updated certificate.
If you issue Frigate valid certificates you will likely want to configure it to run on port 443 so you can access it without a port number like `https://your-frigate-domain.com` by mapping 8080 to 443.
```yaml
frigate:
...
ports:
- "443:8080"
...
```
## ACME Challenge
Frigate also supports hosting the acme challenge files for the HTTP challenge method if needed. The challenge files should be mounted at `/etc/letsencrypt/www`.

View File

@@ -95,6 +95,18 @@ Frigate supports all Jetson boards, from the inexpensive Jetson Nano to the powe
Inference speed will vary depending on the YOLO model, jetson platform and jetson nvpmodel (GPU/DLA/EMC clock speed). It is typically 20-40 ms for most models. The DLA is more efficient than the GPU, but not faster, so using the DLA will reduce power consumption but will slightly increase inference time.
#### Rockchip platform
Frigate supports hardware video processing on all Rockchip boards. However, hardware object detection is only supported on these boards:
- RK3562
- RK3566
- RK3568
- RK3576
- RK3588
The inference time of a rk3588 with all 3 cores enabled is typically 25-30 ms for yolo-nas s.
## What does Frigate use the CPU for and what does it use a detector for? (ELI5 Version)
This is taken from a [user question on reddit](https://www.reddit.com/r/homeassistant/comments/q8mgau/comment/hgqbxh5/?utm_source=share&utm_medium=web2x&context=3). Modified slightly for clarity.

View File

@@ -34,7 +34,7 @@ The following ports are used by Frigate and can be mapped via docker as required
| Port | Description |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `8080` | Authenticated UI and API access. Reverse proxies should use this port. |
| `8080` | Authenticated UI and API access without TLS. Reverse proxies should use this port. |
| `5000` | Internal unauthenticated UI and API access. Access to this port should be limited. Intended to be used within the docker network for services that integrate with Frigate. |
| `8554` | RTSP restreaming. By default, these streams are unauthenticated. Authentication can be configured in go2rtc section of config. |
| `8555` | WebRTC connections for low latency live views. |
@@ -44,7 +44,6 @@ The following ports are used by Frigate and can be mapped via docker as required
Writing to a local disk or external USB drive:
```yaml
version: "3.9"
services:
frigate:
...
@@ -95,6 +94,56 @@ By default, the Raspberry Pi limits the amount of memory available to the GPU. I
Additionally, the USB Coral draws a considerable amount of power. If using any other USB devices such as an SSD, you will experience instability due to the Pi not providing enough power to USB devices. You will need to purchase an external USB hub with it's own power supply. Some have reported success with <a href="https://amzn.to/3a2mH0P" target="_blank" rel="nofollow noopener sponsored">this</a> (affiliate link).
### Rockchip platform
Make sure that you use a linux distribution that comes with the rockchip BSP kernel 5.10 or 6.1 and necessary drivers (especially rkvdec2 and rknpu). To check, enter the following commands:
```
$ uname -r
5.10.xxx-rockchip # or 6.1.xxx; the -rockchip suffix is important
$ ls /dev/dri
by-path card0 card1 renderD128 renderD129 # should list renderD128 (VPU) and renderD129 (NPU)
$ sudo cat /sys/kernel/debug/rknpu/version
RKNPU driver: v0.9.2 # or later version
```
I recommend [Joshua Riek's Ubuntu for Rockchip](https://github.com/Joshua-Riek/ubuntu-rockchip), if your board is supported.
#### Setup
Follow Frigate's default installation instructions, but use a docker image with `-rk` suffix for example `ghcr.io/blakeblackshear/frigate:stable-rk`.
Next, you need to grant docker permissions to access your hardware:
- During the configuration process, you should run docker in privileged mode to avoid any errors due to insufficient permissions. To do so, add `privileged: true` to your `docker-compose.yml` file or the `--privileged` flag to your docker run command.
- After everything works, you should only grant necessary permissions to increase security. Disable the privileged mode and add the lines below to your `docker-compose.yml` file:
```yaml
security_opt:
- apparmor=unconfined
- systempaths=unconfined
devices:
- /dev/dri
- /dev/dma_heap
- /dev/rga
- /dev/mpp_service
```
or add these options to your `docker run` command:
```
--security-opt systempaths=unconfined \
--security-opt apparmor=unconfined \
--device /dev/dri \
--device /dev/dma_heap \
--device /dev/rga \
--device /dev/mpp_service
```
#### Configuration
Next, you should configure [hardware object detection](/configuration/object_detectors#rockchip-platform) and [hardware video processing](/configuration/hardware_acceleration#rockchip-platform).
## Docker
Running in Docker with compose is the recommended install method.

View File

@@ -137,7 +137,7 @@ cameras:
- detect
```
Now you should be able to start Frigate by running `docker compose up -d` from within the folder containing `docker-compose.yml`. On startup, an admin user and password will be created and outputted in the logs. You can see this by running `docker logs frigate`. Frigate should now be accessible at `server_ip:8080` where you can login with the `admin` user and finish the configuration using the built-in configuration editor.
Now you should be able to start Frigate by running `docker compose up -d` from within the folder containing `docker-compose.yml`. On startup, an admin user and password will be created and outputted in the logs. You can see this by running `docker logs frigate`. Frigate should now be accessible at `https://server_ip:8080` where you can login with the `admin` user and finish the configuration using the built-in configuration editor.
## Configuring Frigate

View File

@@ -164,7 +164,7 @@ Accepts the following query string parameters:
| `motion` | int | Draw blue boxes for areas with detected motion (0 or 1) |
| `regions` | int | Draw green boxes for areas where object detection was run (0 or 1) |
You can access a higher resolution mjpeg stream by appending `h=height-in-pixels` to the endpoint. For example `http://localhost:8080/api/back?h=1080`. You can also increase the FPS by appending `fps=frame-rate` to the URL such as `http://localhost:8080/api/back?fps=10` or both with `?fps=10&h=1000`.
You can access a higher resolution mjpeg stream by appending `h=height-in-pixels` to the endpoint. For example `/api/back?h=1080`. You can also increase the FPS by appending `fps=frame-rate` to the URL such as `/api/back?fps=10` or both with `?fps=10&h=1000`.
### `GET /api/<camera_name>/latest.jpg[?h=300]`
@@ -450,6 +450,7 @@ Reviews from the database. Accepts the following query string parameters:
| `after` | int | Epoch time |
| `cameras` | str | , separated list of cameras |
| `labels` | str | , separated list of labels |
| `zones` | str | , separated list of zones |
| `reviewed` | int | Include items that have been reviewed (0 or 1) |
| `limit` | int | Limit the number of events returned |
| `severity` | str | Limit items to severity (alert, detection, significant_motion) |
@@ -496,21 +497,21 @@ Delete review items.
Get the motion activity for camera(s) during a specified time period.
| param | Type | Description |
| ---------- | ---- | -------------------------------------------------------------- |
| `before` | int | Epoch time |
| `after` | int | Epoch time |
| `cameras` | str | , separated list of cameras |
| param | Type | Description |
| --------- | ---- | --------------------------- |
| `before` | int | Epoch time |
| `after` | int | Epoch time |
| `cameras` | str | , separated list of cameras |
### `GET /review/activity/audio`
Get the audio activity for camera(s) during a specified time period.
| param | Type | Description |
| ---------- | ---- | -------------------------------------------------------------- |
| `before` | int | Epoch time |
| `after` | int | Epoch time |
| `cameras` | str | , separated list of cameras |
| param | Type | Description |
| --------- | ---- | --------------------------- |
| `before` | int | Epoch time |
| `after` | int | Epoch time |
| `cameras` | str | , separated list of cameras |
## Timeline

View File

@@ -150,7 +150,8 @@ Home Assistant > Configuration > Integrations > Frigate > Options
| Platform | Description |
| --------------- | --------------------------------------------------------------------------------- |
| `camera` | Live camera stream (requires RTSP), camera for image of the last detected object. |
| `camera` | Live camera stream (requires RTSP). |
| `image` | Image of the latest detected object for each camera. |
| `sensor` | States to monitor Frigate performance, object counts for all zones and cameras. |
| `switch` | Switch entities to toggle detection, recordings and snapshots. |
| `binary_sensor` | A "motion" binary sensor entity per camera/zone/object. |

View File

@@ -49,20 +49,26 @@ You can view all of your submitted images at [https://plus.frigate.video](https:
## Use Models
Models available in Frigate+ can be used with a special model path. No other information needs to be configured for Frigate+ models because it fetches the remaining config from Frigate+ automatically.
Once you have [requested your first model](../plus/first_model.md) and gotten your own model ID, it can be used with a special model path. No other information needs to be configured for Frigate+ models because it fetches the remaining config from Frigate+ automatically.
```yaml
model:
path: plus://e63b7345cc83a84ed79dedfc99c16616
path: plus://<your_model_id>
```
:::note
Model IDs are not secret values and can be shared freely. Access to your model is protected by your API key.
:::
Models are downloaded into the `/config/model_cache` folder and only downloaded if needed.
If needed, you can override the labelmap for Frigate+ models. This is not recommended as renaming labels will break the Submit to Frigate+ feature if the labels are not available in Frigate+.
```yaml
model:
path: plus://e63b7345cc83a84ed79dedfc99c16616
path: plus://<your_model_id>
labelmap:
3: animal
4: animal

View File

@@ -28,6 +28,12 @@ model:
path: plus://<your_model_id>
```
:::note
Model IDs are not secret values and can be shared freely. Access to your model is protected by your API key.
:::
## Step 4: Adjust your object filters for higher scores
Frigate+ models generally have much higher scores than the default model provided in Frigate. You will likely need to increase your `threshold` and `min_score` values. Here is an example of how these values can be refined, but you should expect these to evolve as your model improves. For more information about how `threshold` and `min_score` are related, see the docs on [object filters](../configuration/object_filters.md#object-scores).

View File

@@ -37,7 +37,7 @@ The USB Coral can become stuck and need to be restarted, this can happen for a n
## PCIe Coral Not Detected
The most common reason for the PCIe coral not being detected is that the driver has not been installed. See [the coral docs(https://coral.ai/docs/m2/get-started/#2-install-the-pcie-driver-and-edge-tpu-runtime) for how to install the driver for the PCIe based coral.
The most common reason for the PCIe coral not being detected is that the driver has not been installed. See [the coral docs](https://coral.ai/docs/m2/get-started/#2-install-the-pcie-driver-and-edge-tpu-runtime) for how to install the driver for the PCIe based coral.
## Only One PCIe Coral Is Detected With Coral Dual EdgeTPU

665
docs/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,9 +14,9 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "^3.3.2",
"@docusaurus/preset-classic": "^3.3.2",
"@docusaurus/theme-mermaid": "^3.3.2",
"@docusaurus/core": "^3.4.0",
"@docusaurus/preset-classic": "^3.4.0",
"@docusaurus/theme-mermaid": "^3.4.0",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.1.0",
@@ -37,8 +37,8 @@
]
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.3.2",
"@docusaurus/types": "^3.3.2",
"@docusaurus/module-type-aliases": "^3.4.0",
"@docusaurus/types": "^3.4.0",
"@types/react": "^18.2.79"
},
"engines": {

View File

@@ -52,6 +52,7 @@ module.exports = {
"configuration/authentication",
"configuration/hardware_acceleration",
"configuration/ffmpeg_presets",
"configuration/tls",
"configuration/advanced",
],
},

View File

@@ -21,7 +21,7 @@ from frigate.api.export import ExportBp
from frigate.api.media import MediaBp
from frigate.api.preview import PreviewBp
from frigate.api.review import ReviewBp
from frigate.config import AuthModeEnum, FrigateConfig
from frigate.config import FrigateConfig
from frigate.const import CONFIG_DIR
from frigate.events.external import ExternalEventProcessor
from frigate.models import Event, Timeline
@@ -86,9 +86,7 @@ def create_app(
app.plus_api = plus_api
app.camera_error_image = None
app.stats_emitter = stats_emitter
app.jwt_token = (
get_jwt_secret() if frigate_config.auth.mode == AuthModeEnum.native else None
)
app.jwt_token = get_jwt_secret() if frigate_config.auth.enabled else None
# update the request_address with the x-forwarded-for header from nginx
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1)
# initialize the rate limiter for the login endpoint
@@ -176,6 +174,9 @@ def config():
# remove the mqtt password
config["mqtt"].pop("password", None)
# remove the proxy secret
config["proxy"].pop("auth_secret", None)
for camera_name, camera in current_app.frigate_config.cameras.items():
camera_dict = config["cameras"][camera_name]

View File

@@ -17,7 +17,7 @@ from flask_limiter import Limiter
from joserfc import jwt
from peewee import DoesNotExist
from frigate.config import AuthConfig, AuthModeEnum
from frigate.config import AuthConfig, ProxyConfig
from frigate.const import CONFIG_DIR, JWT_SECRET_ENV_VAR, PASSWORD_HASH_ALGORITHM
from frigate.models import User
@@ -87,11 +87,7 @@ def get_jwt_secret() -> str:
)
jwt_secret = os.environ.get(JWT_SECRET_ENV_VAR)
# check docker secrets
elif (
os.path.isdir("/run/secrets")
and os.access("/run/secrets", os.R_OK)
and JWT_SECRET_ENV_VAR in os.listdir("/run/secrets")
):
elif os.path.isfile(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)):
logger.debug(f"Using jwt secret from {JWT_SECRET_ENV_VAR} docker secret file.")
jwt_secret = Path(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)).read_text()
# check for the addon options file
@@ -170,6 +166,9 @@ def set_jwt_cookie(response, cookie_name, encoded_jwt, expiration, secure):
# Endpoint for use with nginx auth_request
@AuthBp.route("/auth")
def auth():
auth_config: AuthConfig = current_app.frigate_config.auth
proxy_config: ProxyConfig = current_app.frigate_config.proxy
success_response = make_response({}, 202)
# dont require auth if the request is on the internal port
@@ -177,11 +176,22 @@ def auth():
if request.headers.get("x-server-port", 0, type=int) == 5000:
return success_response
# if proxy auth mode
if current_app.frigate_config.auth.mode == AuthModeEnum.proxy:
fail_response = make_response({}, 401)
# ensure the proxy secret matches if configured
if (
proxy_config.auth_secret is not None
and request.headers.get("x-proxy-secret", "", type=str)
!= proxy_config.auth_secret
):
logger.debug("X-Proxy-Secret header does not match configured secret value")
return fail_response
# if auth is disabled, just apply the proxy header map and return success
if not auth_config.enabled:
# pass the user header value from the upstream proxy if a mapping is specified
# or use anonymous if none are specified
if current_app.frigate_config.auth.header_map.user is not None:
if proxy_config.header_map.user is not None:
upstream_user_header_value = request.headers.get(
current_app.frigate_config.auth.header_map.user,
type=str,
@@ -192,7 +202,7 @@ def auth():
success_response.headers["remote-user"] = "anonymous"
return success_response
fail_response = make_response({}, 401)
# now apply authentication
fail_response.headers["location"] = "/login"
JWT_COOKIE_NAME = current_app.frigate_config.auth.cookie_name

View File

@@ -4,6 +4,7 @@ import logging
from pathlib import Path
from typing import Optional
import psutil
from flask import (
Blueprint,
current_app,
@@ -14,6 +15,7 @@ from flask import (
from peewee import DoesNotExist
from werkzeug.utils import secure_filename
from frigate.const import EXPORT_DIR
from frigate.models import Export, Recordings
from frigate.record.export import PlaybackFactorEnum, RecordingExporter
@@ -140,6 +142,27 @@ def export_delete(id: str):
404,
)
files_in_use = []
for process in psutil.process_iter():
try:
if process.name() != "ffmpeg":
continue
flist = process.open_files()
if flist:
for nt in flist:
if nt.path.startswith(EXPORT_DIR):
files_in_use.append(nt.path.split("/")[-1])
except psutil.Error:
continue
if export.video_path.split("/")[-1] in files_in_use:
return make_response(
jsonify(
{"success": False, "message": "Can not delete in progress export."}
),
400,
)
Path(export.video_path).unlink(missing_ok=True)
if export.thumb_path:

View File

@@ -459,7 +459,7 @@ def recording_clip(camera_name, start_ts, end_ts):
)
file_name = secure_filename(file_name)
path = os.path.join(CACHE_DIR, file_name)
path = os.path.join(CLIPS_DIR, f"cache/{file_name}")
if not os.path.exists(path):
ffmpeg_cmd = [
@@ -511,7 +511,7 @@ def recording_clip(camera_name, start_ts, end_ts):
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
response.headers["Content-Length"] = os.path.getsize(path)
response.headers["X-Accel-Redirect"] = (
f"/cache/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
f"/clips/cache/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
)
return response
@@ -1232,8 +1232,8 @@ def preview_gif(camera_name: str, start_ts, end_ts, max_cache_age=2592000):
@MediaBp.route("/<camera_name>/start/<int:start_ts>/end/<int:end_ts>/preview.mp4")
@MediaBp.route("/<camera_name>/start/<float:start_ts>/end/<float:end_ts>/preview.mp4")
def preview_mp4(camera_name: str, start_ts, end_ts):
file_name = f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"
def preview_mp4(camera_name: str, start_ts, end_ts, max_cache_age=604800):
file_name = f"preview_{camera_name}_{start_ts}-{end_ts}.mp4"
if len(file_name) > 1000:
return make_response(
@@ -1380,7 +1380,7 @@ def preview_mp4(camera_name: str, start_ts, end_ts):
response = make_response()
response.headers["Content-Description"] = "File Transfer"
response.headers["Cache-Control"] = "no-cache"
response.headers["Cache-Control"] = f"private, max-age={max_cache_age}"
response.headers["Content-Type"] = "video/mp4"
response.headers["Content-Length"] = os.path.getsize(path)
response.headers["X-Accel-Redirect"] = (

View File

@@ -22,6 +22,7 @@ ReviewBp = Blueprint("reviews", __name__)
def review():
cameras = request.args.get("cameras", "all")
labels = request.args.get("labels", "all")
zones = request.args.get("zones", "all")
reviewed = request.args.get("reviewed", type=int, default=0)
limit = request.args.get("limit", type=int, default=None)
severity = request.args.get("severity", None)
@@ -60,6 +61,20 @@ def review():
label_clause = reduce(operator.or_, label_clauses)
clauses.append((label_clause))
if zones != "all":
# use matching so segments with multiple zones
# still match on a search where any zone matches
zone_clauses = []
filtered_zones = zones.split(",")
for zone in filtered_zones:
zone_clauses.append(
(ReviewSegment.data["zones"].cast("text") % f'*"{zone}"*')
)
zone_clause = reduce(operator.or_, zone_clauses)
clauses.append((zone_clause))
if reviewed == 0:
clauses.append((ReviewSegment.has_been_reviewed == False))
@@ -96,6 +111,7 @@ def review_summary():
cameras = request.args.get("cameras", "all")
labels = request.args.get("labels", "all")
zones = request.args.get("zones", "all")
clauses = [(ReviewSegment.start_time > day_ago)]
@@ -118,6 +134,20 @@ def review_summary():
label_clause = reduce(operator.or_, label_clauses)
clauses.append((label_clause))
if zones != "all":
# use matching so segments with multiple zones
# still match on a search where any zone matches
zone_clauses = []
filtered_zones = zones.split(",")
for zone in filtered_zones:
zone_clauses.append(
(ReviewSegment.data["zones"].cast("text") % f'*"{zone}"*')
)
zone_clause = reduce(operator.or_, zone_clauses)
clauses.append((zone_clause))
last_24 = (
ReviewSegment.select(
fn.SUM(
@@ -440,6 +470,11 @@ def motion_activity():
# resample data using pandas to get activity on scaled basis
df = pd.DataFrame(data, columns=["start_time", "motion", "camera"])
if df.empty:
logger.warning("No motion data found for the requested time range")
return jsonify([])
df = df.astype(dtype={"motion": "float16"})
# set date as datetime index

View File

@@ -27,7 +27,7 @@ from frigate.comms.dispatcher import Communicator, Dispatcher
from frigate.comms.inter_process import InterProcessCommunicator
from frigate.comms.mqtt import MqttClient
from frigate.comms.ws import WebSocketClient
from frigate.config import AuthModeEnum, FrigateConfig
from frigate.config import FrigateConfig
from frigate.const import (
CACHE_DIR,
CLIPS_DIR,
@@ -68,7 +68,7 @@ from frigate.stats.util import stats_init
from frigate.storage import StorageMaintainer
from frigate.timeline import TimelineProcessor
from frigate.types import CameraMetricsTypes, PTZMetricsTypes
from frigate.util.builtin import save_default_config
from frigate.util.builtin import empty_and_close_queue, save_default_config
from frigate.util.config import migrate_frigate_config
from frigate.util.object import get_camera_regions_grid
from frigate.version import VERSION
@@ -100,7 +100,7 @@ class FrigateApp:
for d in [
CONFIG_DIR,
RECORD_DIR,
CLIPS_DIR,
f"{CLIPS_DIR}/cache",
CACHE_DIR,
MODEL_CACHE_DIR,
EXPORT_DIR,
@@ -521,8 +521,9 @@ class FrigateApp:
logger.info(f"Capture process started for {name}: {capture_process.pid}")
def start_audio_processors(self) -> None:
self.audio_process = None
if len([c for c in self.config.cameras.values() if c.audio.enabled]) > 0:
audio_process = mp.Process(
self.audio_process = mp.Process(
target=listen_to_audio,
name="audio_capture",
args=(
@@ -530,10 +531,10 @@ class FrigateApp:
self.camera_metrics,
),
)
audio_process.daemon = True
audio_process.start()
self.processes["audio_detector"] = audio_process.pid or 0
logger.info(f"Audio process started: {audio_process.pid}")
self.audio_process.daemon = True
self.audio_process.start()
self.processes["audio_detector"] = self.audio_process.pid or 0
logger.info(f"Audio process started: {self.audio_process.pid}")
def start_timeline_processor(self) -> None:
self.timeline_processor = TimelineProcessor(
@@ -592,7 +593,7 @@ class FrigateApp:
)
def init_auth(self) -> None:
if self.config.auth.mode == AuthModeEnum.native:
if self.config.auth.enabled:
if User.select().count() == 0:
password = secrets.token_hex(16)
password_hash = hash_password(
@@ -706,9 +707,9 @@ class FrigateApp:
self.check_shm()
self.init_auth()
# Flask only listens for SIGINT, so we need to catch SIGTERM and send SIGINT
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
self.stop()
sys.exit()
os.kill(os.getpid(), signal.SIGINT)
signal.signal(signal.SIGTERM, receiveSignal)
@@ -717,10 +718,13 @@ class FrigateApp:
except KeyboardInterrupt:
pass
logger.info("Flask has exited...")
self.stop()
def stop(self) -> None:
logger.info("Stopping...")
self.stop_event.set()
# set an end_time on entries without an end_time before exiting
@@ -731,43 +735,76 @@ class FrigateApp:
ReviewSegment.end_time == None
).execute()
# Stop Communicators
self.inter_process_communicator.stop()
self.inter_config_updater.stop()
self.inter_detection_proxy.stop()
# stop the audio process
if self.audio_process is not None:
self.audio_process.terminate()
self.audio_process.join()
# ensure the capture processes are done
for camera in self.camera_metrics.keys():
capture_process = self.camera_metrics[camera]["capture_process"]
if capture_process is not None:
logger.info(f"Waiting for capture process for {camera} to stop")
capture_process.terminate()
capture_process.join()
# ensure the camera processors are done
for camera in self.camera_metrics.keys():
camera_process = self.camera_metrics[camera]["process"]
if camera_process is not None:
logger.info(f"Waiting for process for {camera} to stop")
camera_process.terminate()
camera_process.join()
logger.info(f"Closing frame queue for {camera}")
frame_queue = self.camera_metrics[camera]["frame_queue"]
empty_and_close_queue(frame_queue)
# ensure the detectors are done
for detector in self.detectors.values():
detector.stop()
# Empty the detection queue and set the events for all requests
while not self.detection_queue.empty():
connection_id = self.detection_queue.get(timeout=1)
self.detection_out_events[connection_id].set()
self.detection_queue.close()
self.detection_queue.join_thread()
empty_and_close_queue(self.detection_queue)
logger.info("Detection queue closed")
self.detected_frames_processor.join()
empty_and_close_queue(self.detected_frames_queue)
logger.info("Detected frames queue closed")
self.timeline_processor.join()
self.event_processor.join()
empty_and_close_queue(self.timeline_queue)
logger.info("Timeline queue closed")
self.output_processor.terminate()
self.output_processor.join()
self.recording_process.terminate()
self.recording_process.join()
self.review_segment_process.terminate()
self.review_segment_process.join()
self.external_event_processor.stop()
self.dispatcher.stop()
self.detected_frames_processor.join()
self.ptz_autotracker_thread.join()
self.event_processor.join()
self.event_cleanup.join()
self.record_cleanup.join()
self.stats_emitter.join()
self.frigate_watchdog.join()
self.db.stop()
# Stop Communicators
self.inter_process_communicator.stop()
self.inter_config_updater.stop()
self.inter_detection_proxy.stop()
while len(self.detection_shms) > 0:
shm = self.detection_shms.pop()
shm.close()
shm.unlink()
for queue in [
self.detected_frames_queue,
self.log_queue,
]:
if queue is not None:
while not queue.empty():
queue.get_nowait()
queue.close()
queue.join_thread()
self.log_process.terminate()
self.log_process.join()
os._exit(os.EX_OK)

View File

@@ -26,9 +26,8 @@ class DetectionProxyRunner(threading.Thread):
def run(self) -> None:
"""Run the proxy."""
control = self.context.socket(zmq.SUB)
control = self.context.socket(zmq.REP)
control.connect(SOCKET_CONTROL)
control.setsockopt_string(zmq.SUBSCRIBE, "")
incoming = self.context.socket(zmq.XSUB)
incoming.bind(SOCKET_PUB)
outgoing = self.context.socket(zmq.XPUB)
@@ -46,13 +45,13 @@ class DetectionProxy:
def __init__(self) -> None:
self.context = zmq.Context()
self.control = self.context.socket(zmq.PUB)
self.control = self.context.socket(zmq.REQ)
self.control.bind(SOCKET_CONTROL)
self.runner = DetectionProxyRunner(self.context)
self.runner.start()
def stop(self) -> None:
self.control.send_string("TERMINATE") # tell the proxy to stop
self.control.send("TERMINATE".encode()) # tell the proxy to stop
self.runner.join()
self.context.destroy()

View File

@@ -1,6 +1,5 @@
from __future__ import annotations
import asyncio
import json
import logging
import os
@@ -46,9 +45,9 @@ from frigate.util.builtin import (
get_ffmpeg_arg_list,
load_config_with_no_duplicates,
)
from frigate.util.config import get_relative_coordinates
from frigate.util.config import StreamInfoRetriever, get_relative_coordinates
from frigate.util.image import create_mask
from frigate.util.services import auto_detect_hwaccel, get_video_properties
from frigate.util.services import auto_detect_hwaccel
logger = logging.getLogger(__name__)
@@ -73,6 +72,9 @@ DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
DEFAULT_TIME_LAPSE_FFMPEG_ARGS = "-vf setpts=0.04*PTS -r 30"
# stream info handler
stream_info_retriever = StreamInfoRetriever()
class FrigateBaseModel(BaseModel):
model_config = ConfigDict(extra="forbid", protected_namespaces=())
@@ -98,9 +100,6 @@ class DateTimeStyleEnum(str, Enum):
class UIConfig(FrigateBaseModel):
live_mode: LiveModeEnum = Field(
default=LiveModeEnum.mse, title="Default Live Mode."
)
timezone: Optional[str] = Field(default=None, title="Override UI timezone.")
time_format: TimeFormatEnum = Field(
default=TimeFormatEnum.browser, title="Override UI time format."
@@ -116,9 +115,8 @@ class UIConfig(FrigateBaseModel):
)
class AuthModeEnum(str, Enum):
native = "native"
proxy = "proxy"
class TlsConfig(FrigateBaseModel):
enabled: bool = Field(default=True, title="Enable TLS for port 8080")
class HeaderMappingConfig(FrigateBaseModel):
@@ -127,8 +125,22 @@ class HeaderMappingConfig(FrigateBaseModel):
)
class ProxyConfig(FrigateBaseModel):
header_map: HeaderMappingConfig = Field(
default_factory=HeaderMappingConfig,
title="Header mapping definitions for proxy user passing.",
)
logout_url: Optional[str] = Field(
default=None, title="Redirect url for logging out with proxy."
)
auth_secret: Optional[str] = Field(
default=None,
title="Secret value for proxy authentication.",
)
class AuthConfig(FrigateBaseModel):
mode: AuthModeEnum = Field(default=AuthModeEnum.native, title="Authentication mode")
enabled: bool = Field(default=True, title="Enable authentication")
reset_admin_password: bool = Field(
default=False, title="Reset the admin password on startup"
)
@@ -144,10 +156,6 @@ class AuthConfig(FrigateBaseModel):
title="Refresh the session if it is going to expire in this many seconds",
ge=30,
)
header_map: HeaderMappingConfig = Field(
default_factory=HeaderMappingConfig,
title="Header mapping definitions for proxy auth mode.",
)
failed_login_rate_limit: Optional[str] = Field(
default=None,
title="Rate limits for failed login attempts.",
@@ -156,9 +164,6 @@ class AuthConfig(FrigateBaseModel):
default=[],
title="Trusted proxies for determining IP address to rate limit",
)
logout_url: Optional[str] = Field(
default=None, title="Redirect url for logging out in proxy mode."
)
# As of Feb 2023, OWASP recommends 600000 iterations for PBKDF2-SHA256
hash_iterations: int = Field(default=600000, title="Password hash iterations")
@@ -1169,12 +1174,20 @@ class LoggerConfig(FrigateBaseModel):
class CameraGroupConfig(FrigateBaseModel):
"""Represents a group of cameras."""
cameras: list[str] = Field(
cameras: Union[str, List[str]] = Field(
default_factory=list, title="List of cameras in this group."
)
icon: str = Field(default="generic", title="Icon that represents camera group.")
order: int = Field(default=0, title="Sort order for group.")
@field_validator("cameras", mode="before")
@classmethod
def validate_cameras(cls, v):
if isinstance(v, str) and "," not in v:
return [v]
return v
def verify_config_roles(camera_config: CameraConfig) -> None:
"""Verify that roles are setup in the config correctly."""
@@ -1296,6 +1309,10 @@ class FrigateConfig(FrigateBaseModel):
database: DatabaseConfig = Field(
default_factory=DatabaseConfig, title="Database configuration."
)
tls: TlsConfig = Field(default_factory=TlsConfig, title="TLS configuration.")
proxy: ProxyConfig = Field(
default_factory=ProxyConfig, title="Proxy configuration."
)
auth: AuthConfig = Field(default_factory=AuthConfig, title="Auth configuration.")
environment_vars: Dict[str, str] = Field(
default_factory=dict, title="Frigate environment variables."
@@ -1355,11 +1372,18 @@ class FrigateConfig(FrigateBaseModel):
default_factory=TimestampStyleConfig,
title="Global timestamp style configuration.",
)
version: Optional[float] = Field(default=None, title="Current config version.")
def runtime_config(self, plus_api: PlusApi = None) -> FrigateConfig:
"""Merge camera config with globals."""
config = self.model_copy(deep=True)
# Proxy secret substitution
if config.proxy.auth_secret:
config.proxy.auth_secret = config.proxy.auth_secret.format(
**FRIGATE_ENV_VARS
)
# MQTT user/password substitutions
if config.mqtt.user or config.mqtt.password:
config.mqtt.user = config.mqtt.user.format(**FRIGATE_ENV_VARS)
@@ -1415,7 +1439,7 @@ class FrigateConfig(FrigateBaseModel):
if need_detect_dimensions or need_record_fourcc:
stream_info = {"width": 0, "height": 0, "fourcc": None}
try:
stream_info = asyncio.run(get_video_properties(input.path))
stream_info = stream_info_retriever.get_stream_info(input.path)
except Exception:
logger.warn(
f"Error detecting stream parameters automatically for {input.path} Applying default values."

View File

@@ -1,5 +1,6 @@
import logging
from abc import ABC, abstractmethod
from typing import List
import numpy as np
@@ -10,6 +11,7 @@ logger = logging.getLogger(__name__)
class DetectionApi(ABC):
type_key: str
supported_models: List[ModelTypeEnum]
@abstractmethod
def __init__(self, detector_config):

View File

@@ -57,8 +57,8 @@ class DeepStack(DetectionApi):
files={"image": image_bytes},
timeout=self.api_timeout,
)
except requests.exceptions.RequestException:
logger.error("Error calling deepstack API")
except requests.exceptions.RequestException as ex:
logger.error("Error calling deepstack API: %s", ex)
return np.zeros((20, 6), np.float32)
response_json = response.json()

View File

@@ -1,7 +1,7 @@
import logging
import numpy as np
import openvino.runtime as ov
import openvino as ov
from pydantic import Field
from typing_extensions import Literal
@@ -20,31 +20,100 @@ class OvDetectorConfig(BaseDetectorConfig):
class OvDetector(DetectionApi):
type_key = DETECTOR_KEY
supported_models = [ModelTypeEnum.ssd, ModelTypeEnum.yolonas, ModelTypeEnum.yolox]
def __init__(self, detector_config: OvDetectorConfig):
self.ov_core = ov.Core()
self.ov_model = self.ov_core.read_model(detector_config.model.path)
self.ov_model_type = detector_config.model.model_type
self.h = detector_config.model.height
self.w = detector_config.model.width
if detector_config.device == "AUTO":
logger.warning(
"OpenVINO AUTO device type is not currently supported. Attempting to use GPU instead."
)
detector_config.device = "GPU"
self.interpreter = self.ov_core.compile_model(
model=self.ov_model, device_name=detector_config.device
model=detector_config.model.path, device_name=detector_config.device
)
logger.info(f"Model Input Shape: {self.interpreter.input(0).shape}")
self.output_indexes = 0
self.model_invalid = False
if self.ov_model_type not in self.supported_models:
logger.error(
f"OpenVino detector does not support {self.ov_model_type} models."
)
self.model_invalid = True
# Ensure the SSD model has the right input and output shapes
if self.ov_model_type == ModelTypeEnum.ssd:
model_inputs = self.interpreter.inputs
model_outputs = self.interpreter.outputs
if len(model_inputs) != 1:
logger.error(
f"SSD models must only have 1 input. Found {len(model_inputs)}."
)
self.model_invalid = True
if len(model_outputs) != 1:
logger.error(
f"SSD models must only have 1 output. Found {len(model_outputs)}."
)
self.model_invalid = True
if model_inputs[0].get_shape() != ov.Shape([1, self.w, self.h, 3]):
logger.error(
f"SSD model input doesn't match. Found {model_inputs[0].get_shape()}."
)
self.model_invalid = True
output_shape = model_outputs[0].get_shape()
if output_shape[0] != 1 or output_shape[1] != 1 or output_shape[3] != 7:
logger.error(f"SSD model output doesn't match. Found {output_shape}.")
self.model_invalid = True
if self.ov_model_type == ModelTypeEnum.yolonas:
model_inputs = self.interpreter.inputs
model_outputs = self.interpreter.outputs
if len(model_inputs) != 1:
logger.error(
f"YoloNAS models must only have 1 input. Found {len(model_inputs)}."
)
self.model_invalid = True
if len(model_outputs) != 1:
logger.error(
f"YoloNAS models must be exported in flat format and only have 1 output. Found {len(model_outputs)}."
)
self.model_invalid = True
if model_inputs[0].get_shape() != ov.Shape([1, 3, self.w, self.h]):
logger.error(
f"YoloNAS model input doesn't match. Found {model_inputs[0].get_shape()}, but expected {[1, 3, self.w, self.h]}."
)
self.model_invalid = True
output_shape = model_outputs[0].partial_shape
if output_shape[-1] != 7:
logger.error(
f"YoloNAS models must be exported in flat format. Model output doesn't match. Found {output_shape}."
)
self.model_invalid = True
while True:
try:
tensor_shape = self.interpreter.output(self.output_indexes).shape
logger.info(f"Model Output-{self.output_indexes} Shape: {tensor_shape}")
self.output_indexes += 1
except Exception:
logger.info(f"Model has {self.output_indexes} Output Tensors")
break
if self.ov_model_type == ModelTypeEnum.yolox:
self.output_indexes = 0
while True:
try:
tensor_shape = self.interpreter.output(self.output_indexes).shape
logger.info(
f"Model Output-{self.output_indexes} Shape: {tensor_shape}"
)
self.output_indexes += 1
except Exception:
logger.info(f"Model has {self.output_indexes} Output Tensors")
break
self.num_classes = tensor_shape[2] - 5
logger.info(f"YOLOX model has {self.num_classes} classes")
self.set_strides_grids()
@@ -81,29 +150,52 @@ class OvDetector(DetectionApi):
def detect_raw(self, tensor_input):
infer_request = self.interpreter.create_infer_request()
infer_request.infer([tensor_input])
# TODO: see if we can use shared_memory=True
input_tensor = ov.Tensor(array=tensor_input)
infer_request.infer(input_tensor)
detections = np.zeros((20, 6), np.float32)
if self.model_invalid:
return detections
if self.ov_model_type == ModelTypeEnum.ssd:
results = infer_request.get_output_tensor()
results = infer_request.get_output_tensor(0).data[0][0]
detections = np.zeros((20, 6), np.float32)
i = 0
for object_detected in results.data[0, 0, :]:
if object_detected[0] != -1:
logger.debug(object_detected)
if object_detected[2] < 0.1 or i == 20:
for i, (_, class_id, score, xmin, ymin, xmax, ymax) in enumerate(results):
if i == 20:
break
detections[i] = [
object_detected[1], # Label ID
float(object_detected[2]), # Confidence
object_detected[4], # y_min
object_detected[3], # x_min
object_detected[6], # y_max
object_detected[5], # x_max
class_id,
float(score),
ymin,
xmin,
ymax,
xmax,
]
i += 1
return detections
elif self.ov_model_type == ModelTypeEnum.yolox:
if self.ov_model_type == ModelTypeEnum.yolonas:
predictions = infer_request.get_output_tensor(0).data
for i, prediction in enumerate(predictions):
if i == 20:
break
(_, x_min, y_min, x_max, y_max, confidence, class_id) = prediction
# when running in GPU mode, empty predictions in the output have class_id of -1
if class_id < 0:
break
detections[i] = [
class_id,
confidence,
y_min / self.h,
x_min / self.w,
y_max / self.h,
x_max / self.w,
]
return detections
if self.ov_model_type == ModelTypeEnum.yolox:
out_tensor = infer_request.get_output_tensor()
# [x, y, h, w, box_score, class_no_1, ..., class_no_80],
results = out_tensor.data
@@ -124,8 +216,6 @@ class OvDetector(DetectionApi):
ordered = dets[dets[:, 5].argsort()[::-1]][:20]
detections = np.zeros((20, 6), np.float32)
for i, object_detected in enumerate(ordered):
detections[i] = self.process_yolo(
object_detected[6], object_detected[5], object_detected[:4]

View File

@@ -42,11 +42,11 @@ class Rknn(DetectionApi):
config.model.model_type = model_props["model_type"]
if model_props["model_type"] == ModelTypeEnum.yolonas:
logger.info("""
You are using yolo-nas with weights from DeciAI.
These weights are subject to their license and can't be used commercially.
For more information, see: https://docs.deci.ai/super-gradients/latest/LICENSE.YOLONAS.html
""")
logger.info(
"You are using yolo-nas with weights from DeciAI. "
"These weights are subject to their license and can't be used commercially. "
"For more information, see: https://docs.deci.ai/super-gradients/latest/LICENSE.YOLONAS.html"
)
from rknnlite.api import RKNNLite

View File

@@ -50,11 +50,13 @@ def get_ffmpeg_command(ffmpeg: FfmpegConfig) -> list[str]:
or get_ffmpeg_arg_list(ffmpeg.input_args)
)
return (
["ffmpeg", "-vn"]
["ffmpeg", "-vn", "-threads", "1"]
+ input_args
+ ["-i"]
+ [ffmpeg_input.path]
+ [
"-threads",
"1",
"-f",
f"{AUDIO_FORMAT}",
"-ar",
@@ -81,6 +83,7 @@ def listen_to_audio(
logger.info("Exiting audio detector...")
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
logger.debug(f"Audio process received signal {signalNumber}")
stop_event.set()
exit_process()

View File

@@ -57,8 +57,8 @@ def log_process(log_queue: Queue) -> None:
while True:
try:
record = log_queue.get(timeout=1)
except (queue.Empty, KeyboardInterrupt):
record = log_queue.get(block=True, timeout=1.0)
except queue.Empty:
if stop_event.is_set():
break
continue

View File

@@ -498,6 +498,10 @@ class CameraState:
frame_copy = cv2.cvtColor(frame_copy, cv2.COLOR_YUV2BGR_I420)
# draw on the frame
if draw_options.get("mask"):
mask_overlay = np.where(self.camera_config.motion.mask == [0])
frame_copy[mask_overlay] = [0, 0, 0]
if draw_options.get("bounding_boxes"):
# draw the bounding boxes on the frame
for obj in tracked_objects.values():
@@ -622,10 +626,6 @@ class CameraState:
)
cv2.drawContours(frame_copy, [zone.contour], -1, zone.color, thickness)
if draw_options.get("mask"):
mask_overlay = np.where(self.camera_config.motion.mask == [0])
frame_copy[mask_overlay] = [0, 0, 0]
if draw_options.get("motion_boxes"):
for m_box in motion_boxes:
cv2.rectangle(

View File

@@ -134,6 +134,8 @@ class FFMpegConverter(threading.Thread):
ffmpeg_cmd = [
"ffmpeg",
"-threads",
"1",
"-f",
"rawvideo",
"-pix_fmt",
@@ -142,6 +144,8 @@ class FFMpegConverter(threading.Thread):
f"{in_width}x{in_height}",
"-i",
"pipe:",
"-threads",
"1",
"-f",
"mpegts",
"-s",

View File

@@ -31,6 +31,8 @@ class FFMpegConverter(threading.Thread):
ffmpeg_cmd = [
"ffmpeg",
"-threads",
"1",
"-f",
"rawvideo",
"-pix_fmt",
@@ -39,6 +41,8 @@ class FFMpegConverter(threading.Thread):
f"{in_width}x{in_height}",
"-i",
"pipe:",
"-threads",
"1",
"-f",
"mpegts",
"-s",

View File

@@ -38,6 +38,7 @@ def output_frames(
stop_event = mp.Event()
def receiveSignal(signalNumber, frame):
logger.debug(f"Output frames process received signal {signalNumber}")
stop_event.set()
signal.signal(signal.SIGTERM, receiveSignal)

View File

@@ -5,6 +5,7 @@ import logging
import os
import subprocess as sp
import threading
import time
from pathlib import Path
import cv2
@@ -77,7 +78,7 @@ class FFMpegConverter(threading.Thread):
self.ffmpeg_cmd = parse_preset_hardware_acceleration_encode(
config.ffmpeg.hwaccel_args,
input="-f concat -y -protocol_whitelist pipe,file -safe 0 -i /dev/stdin",
output=f"-g {PREVIEW_KEYFRAME_INTERVAL}{' -fpsmax 2' if int(os.getenv('LIBAVFORMAT_VERSION_MAJOR', '59')) >= 59 else ''} -bf 0 -b:v {PREVIEW_QUALITY_BIT_RATES[self.config.record.preview.quality]} {FPS_VFR_PARAM} -movflags +faststart -pix_fmt yuv420p {self.path}",
output=f"-g {PREVIEW_KEYFRAME_INTERVAL} -bf 0 -b:v {PREVIEW_QUALITY_BIT_RATES[self.config.record.preview.quality]} {FPS_VFR_PARAM} -movflags +faststart -pix_fmt yuv420p {self.path}",
type=EncodeTypeEnum.preview,
)
@@ -101,12 +102,24 @@ class FFMpegConverter(threading.Thread):
f"duration {self.frame_times[t_idx + 1] - self.frame_times[t_idx]}"
)
p = sp.run(
self.ffmpeg_cmd.split(" "),
input="\n".join(playlist),
encoding="ascii",
capture_output=True,
)
try:
p = sp.run(
self.ffmpeg_cmd.split(" "),
input="\n".join(playlist),
encoding="ascii",
capture_output=True,
)
except BlockingIOError:
logger.warning(
f"Failed to create preview for {self.config.name}, retrying..."
)
time.sleep(2)
p = sp.run(
self.ffmpeg_cmd.split(" "),
input="\n".join(playlist),
encoding="ascii",
capture_output=True,
)
start = self.frame_times[0]
end = self.frame_times[-1]
@@ -139,10 +152,20 @@ class PreviewRecorder:
self.start_time = 0
self.last_output_time = 0
self.output_frames = []
self.out_height = PREVIEW_HEIGHT
self.out_width = (
int((config.detect.width / config.detect.height) * self.out_height) // 4 * 4
)
if config.detect.width > config.detect.height:
self.out_height = PREVIEW_HEIGHT
self.out_width = (
int((config.detect.width / config.detect.height) * self.out_height)
// 4
* 4
)
else:
self.out_width = PREVIEW_HEIGHT
self.out_height = (
int((config.detect.height / config.detect.width) * self.out_width)
// 4
* 4
)
# create communication for finished previews
self.requestor = InterProcessRequestor()
@@ -167,6 +190,7 @@ class PreviewRecorder:
# end segment at end of hour
self.segment_end = (
(datetime.datetime.now() + datetime.timedelta(hours=1))
.astimezone(datetime.timezone.utc)
.replace(minute=0, second=0, microsecond=0)
.timestamp()
)
@@ -179,6 +203,7 @@ class PreviewRecorder:
# check for existing items in cache
start_ts = (
datetime.datetime.now()
.astimezone(datetime.timezone.utc)
.replace(minute=0, second=0, microsecond=0)
.timestamp()
)
@@ -194,7 +219,12 @@ class PreviewRecorder:
os.unlink(os.path.join(PREVIEW_CACHE_DIR, file))
continue
ts = float(file.split("-")[1][: -(len(PREVIEW_FRAME_TYPE) + 1)])
file_time = file.split("-")[1][: -(len(PREVIEW_FRAME_TYPE) + 1)]
if not file_time:
continue
ts = float(file_time)
if self.start_time == 0:
self.start_time = ts
@@ -287,6 +317,7 @@ class PreviewRecorder:
# reset frame cache
self.segment_end = (
(datetime.datetime.now() + datetime.timedelta(hours=1))
.astimezone(datetime.timezone.utc)
.replace(minute=0, second=0, microsecond=0)
.timestamp()
)

View File

@@ -11,7 +11,7 @@ from pathlib import Path
from playhouse.sqlite_ext import SqliteExtDatabase
from frigate.config import CameraConfig, FrigateConfig, RetainModeEnum
from frigate.const import CACHE_DIR, MAX_WAL_SIZE, RECORD_DIR
from frigate.const import CACHE_DIR, CLIPS_DIR, MAX_WAL_SIZE, RECORD_DIR
from frigate.models import Event, Previews, Recordings, ReviewSegment
from frigate.record.util import remove_empty_directories, sync_recordings
from frigate.util.builtin import clear_and_unlink, get_tomorrow_at_time
@@ -28,11 +28,19 @@ class RecordingCleanup(threading.Thread):
self.config = config
self.stop_event = stop_event
def clean_tmp_previews(self) -> None:
"""delete any previews in the cache that are more than 1 hour old."""
for p in Path(CACHE_DIR).rglob("preview_*.mp4"):
logger.debug(f"Checking preview {p}.")
if p.stat().st_mtime < (datetime.datetime.now().timestamp() - 60 * 60):
logger.debug("Deleting preview.")
clear_and_unlink(p)
def clean_tmp_clips(self) -> None:
"""delete any clips in the cache that are more than 5 minutes old."""
for p in Path(CACHE_DIR).rglob("clip_*.mp4"):
"""delete any clips in the cache that are more than 1 hour old."""
for p in Path(os.path.join(CLIPS_DIR, "cache")).rglob("clip_*.mp4"):
logger.debug(f"Checking tmp clip {p}.")
if p.stat().st_mtime < (datetime.datetime.now().timestamp() - 60 * 1):
if p.stat().st_mtime < (datetime.datetime.now().timestamp() - 60 * 60):
logger.debug("Deleting tmp clip.")
clear_and_unlink(p)
@@ -335,7 +343,7 @@ class RecordingCleanup(threading.Thread):
logger.info("Exiting recording cleanup...")
break
self.clean_tmp_clips()
self.clean_tmp_previews()
if (
self.config.record.sync_recordings
@@ -346,6 +354,7 @@ class RecordingCleanup(threading.Thread):
next_sync = get_tomorrow_at_time(3)
if counter == 0:
self.clean_tmp_clips()
self.expire_recordings()
remove_empty_directories(RECORD_DIR)
self.truncate_wal()

View File

@@ -11,6 +11,8 @@ import threading
from enum import Enum
from pathlib import Path
from peewee import DoesNotExist
from frigate.config import FrigateConfig
from frigate.const import (
CACHE_DIR,
@@ -70,32 +72,35 @@ class RecordingExporter(threading.Thread):
def save_thumbnail(self, id: str) -> str:
thumb_path = os.path.join(CLIPS_DIR, f"export/{id}.webp")
if datetime.datetime.fromtimestamp(
if (
self.start_time
) < datetime.datetime.now().replace(minute=0, second=0):
< datetime.datetime.now(datetime.timezone.utc)
.replace(minute=0, second=0, microsecond=0)
.timestamp()
):
# has preview mp4
preview: Previews = (
Previews.select(
Previews.camera,
Previews.path,
Previews.duration,
Previews.start_time,
Previews.end_time,
)
.where(
Previews.start_time.between(self.start_time, self.end_time)
| Previews.end_time.between(self.start_time, self.end_time)
| (
(self.start_time > Previews.start_time)
& (self.end_time < Previews.end_time)
try:
preview: Previews = (
Previews.select(
Previews.camera,
Previews.path,
Previews.duration,
Previews.start_time,
Previews.end_time,
)
.where(
Previews.start_time.between(self.start_time, self.end_time)
| Previews.end_time.between(self.start_time, self.end_time)
| (
(self.start_time > Previews.start_time)
& (self.end_time < Previews.end_time)
)
)
.where(Previews.camera == self.camera)
.limit(1)
.get()
)
.where(Previews.camera == self.camera)
.limit(1)
.get()
)
if not preview:
except DoesNotExist:
return ""
diff = self.start_time - preview.start_time

View File

@@ -82,7 +82,7 @@ class RecordingMaintainer(threading.Thread):
for d in os.listdir(CACHE_DIR)
if os.path.isfile(os.path.join(CACHE_DIR, d))
and d.endswith(".mp4")
and not d.startswith("clip_")
and not d.startswith("preview_")
]
files_in_use = []

View File

@@ -22,6 +22,7 @@ def manage_recordings(config: FrigateConfig) -> None:
stop_event = mp.Event()
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
logger.debug(f"Recording manager process received signal {signalNumber}")
stop_event.set()
signal.signal(signal.SIGTERM, receiveSignal)

View File

@@ -65,7 +65,7 @@ def sync_recordings(limited: bool) -> None:
]
if float(len(recordings_to_delete)) / max(1, recordings.count()) > 0.5:
logger.debug(
logger.warning(
f"Deleting {(float(len(recordings_to_delete)) / recordings.count()):2f}% of recordings DB entries, could be due to configuration error. Aborting..."
)
return False

View File

@@ -140,7 +140,7 @@ class PendingReviewSegment:
"zones": list(self.zones),
"audio": list(self.audio),
},
}
}.copy()
class ReviewSegmentMaintainer(threading.Thread):
@@ -194,10 +194,9 @@ class ReviewSegmentMaintainer(threading.Thread):
camera_config: CameraConfig,
frame,
objects: list[TrackedObject],
prev_data: dict[str, any],
) -> None:
"""Update segment."""
prev_data = segment.get_data(ended=False)
if frame is not None:
segment.update_frame(camera_config, frame, objects)
@@ -240,8 +239,11 @@ class ReviewSegmentMaintainer(threading.Thread):
"""Validate if existing review segment should continue."""
camera_config = self.config.cameras[segment.camera]
active_objects = get_active_objects(frame_time, camera_config, objects)
prev_data = segment.get_data(False)
if len(active_objects) > 0:
should_update = False
if frame_time > segment.last_update:
segment.last_update = frame_time
@@ -270,19 +272,23 @@ class ReviewSegmentMaintainer(threading.Thread):
)
):
segment.severity = SeverityEnum.alert
should_update = True
# keep zones up to date
if len(object["current_zones"]) > 0:
segment.zones.update(object["current_zones"])
if len(active_objects) > segment.frame_active_count:
should_update = True
if should_update:
try:
frame_id = f"{camera_config.name}{frame_time}"
yuv_frame = self.frame_manager.get(
frame_id, camera_config.frame_shape_yuv
)
self.update_segment(
segment, camera_config, yuv_frame, active_objects
segment, camera_config, yuv_frame, active_objects, prev_data
)
self.frame_manager.close(frame_id)
except FileNotFoundError:
@@ -296,7 +302,7 @@ class ReviewSegmentMaintainer(threading.Thread):
)
segment.save_full_frame(camera_config, yuv_frame)
self.frame_manager.close(frame_id)
self.update_segment(segment, camera_config, None, [])
self.update_segment(segment, camera_config, None, [], prev_data)
except FileNotFoundError:
return
@@ -356,7 +362,7 @@ class ReviewSegmentMaintainer(threading.Thread):
if (
not severity
and (
not camera_config.review.detections.labels
camera_config.review.detections.labels is None
or object["label"] in (camera_config.review.detections.labels)
)
and (
@@ -467,7 +473,7 @@ class ReviewSegmentMaintainer(threading.Thread):
current_segment.audio.add(audio)
current_segment.severity = SeverityEnum.alert
elif (
not camera_config.review.detections.labels
camera_config.review.detections.labels is None
or audio in camera_config.review.detections.labels
):
current_segment.audio.add(audio)
@@ -510,7 +516,7 @@ class ReviewSegmentMaintainer(threading.Thread):
detections.add(audio)
severity = SeverityEnum.alert
elif (
not camera_config.review.detections.labels
camera_config.review.detections.labels is None
or audio in camera_config.review.detections.labels
):
detections.add(audio)
@@ -571,7 +577,7 @@ def get_active_objects(
and (
o["label"] in camera_config.review.alerts.labels
or (
not camera_config.review.detections.labels
camera_config.review.detections.labels is None
or o["label"] in camera_config.review.detections.labels
)
) # object must be in the alerts or detections label list

View File

@@ -20,6 +20,7 @@ def manage_review_segments(config: FrigateConfig) -> None:
stop_event = mp.Event()
def receiveSignal(signalNumber: int, frame: Optional[FrameType]) -> None:
logger.debug(f"Manage review segments process received signal {signalNumber}")
stop_event.set()
signal.signal(signal.SIGTERM, receiveSignal)

View File

@@ -3,6 +3,8 @@
import copy
import datetime
import logging
import multiprocessing as mp
import queue
import re
import shlex
import urllib.parse
@@ -237,7 +239,7 @@ def update_yaml(data, key_path, new_value):
temp[key[0]] += [{}] * (key[1] - len(temp[key[0]]) + 1)
temp = temp[key[0]][key[1]]
else:
if key not in temp:
if key not in temp or temp[key] is None:
temp[key] = {}
temp = temp[key]
@@ -337,3 +339,13 @@ def clear_and_unlink(file: Path, missing_ok: bool = True) -> None:
pass
file.unlink(missing_ok=missing_ok)
def empty_and_close_queue(q: mp.Queue):
while True:
try:
q.get(block=True, timeout=0.5)
except queue.Empty:
q.close()
q.join_thread()
return

View File

@@ -1,5 +1,6 @@
"""configuration utils."""
import asyncio
import logging
import os
import shutil
@@ -8,6 +9,7 @@ from typing import Optional, Union
from ruamel.yaml import YAML
from frigate.const import CONFIG_DIR, EXPORT_DIR
from frigate.util.services import get_video_properties
logger = logging.getLogger(__name__)
@@ -17,16 +19,17 @@ CURRENT_CONFIG_VERSION = 0.14
def migrate_frigate_config(config_file: str):
"""handle migrating the frigate config."""
logger.info("Checking if frigate config needs migration...")
version_file = os.path.join(CONFIG_DIR, ".version")
if not os.path.isfile(version_file):
previous_version = 0.13
else:
with open(version_file) as f:
try:
previous_version = float(f.readline())
except Exception:
previous_version = 0.13
if not os.access(config_file, mode=os.W_OK):
logger.error("Config file is read-only, unable to migrate config file.")
return
yaml = YAML()
yaml.indent(mapping=2, sequence=4, offset=2)
with open(config_file, "r") as f:
config: dict[str, dict[str, any]] = yaml.load(f)
previous_version = config.get("version", 0.13)
if previous_version == CURRENT_CONFIG_VERSION:
logger.info("frigate config does not need migration...")
@@ -35,11 +38,6 @@ def migrate_frigate_config(config_file: str):
logger.info("copying config as backup...")
shutil.copy(config_file, os.path.join(CONFIG_DIR, "backup_config.yaml"))
yaml = YAML()
yaml.indent(mapping=2, sequence=4, offset=2)
with open(config_file, "r") as f:
config: dict[str, dict[str, any]] = yaml.load(f)
if previous_version < 0.14:
logger.info(f"Migrating frigate config from {previous_version} to 0.14...")
new_config = migrate_014(config)
@@ -57,9 +55,6 @@ def migrate_frigate_config(config_file: str):
os.path.join(EXPORT_DIR, file), os.path.join(EXPORT_DIR, new_name)
)
with open(version_file, "w") as f:
f.write(str(CURRENT_CONFIG_VERSION))
logger.info("Finished frigate config migration...")
@@ -92,8 +87,12 @@ def migrate_014(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
if not new_config["record"]:
del new_config["record"]
if new_config.get("ui", {}).get("use_experimental"):
del new_config["ui"]["experimental"]
if new_config.get("ui"):
if new_config["ui"].get("use_experimental"):
del new_config["ui"]["experimental"]
if new_config["ui"].get("live_mode"):
del new_config["ui"]["live_mode"]
if not new_config["ui"]:
del new_config["ui"]
@@ -141,6 +140,7 @@ def migrate_014(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
new_config["cameras"][name] = camera_config
new_config["version"] = 0.14
return new_config
@@ -200,3 +200,16 @@ def get_relative_coordinates(
return mask
return mask
class StreamInfoRetriever:
def __init__(self) -> None:
self.stream_cache: dict[str, tuple[int, int]] = {}
def get_stream_info(self, path: str) -> str:
if path in self.stream_cache:
return self.stream_cache[path]
info = asyncio.run(get_video_properties(path))
self.stream_cache[path] = info
return info

View File

@@ -33,7 +33,7 @@ def restart_frigate():
proc.terminate()
# otherwise, just try and exit frigate
else:
os.kill(os.getpid(), signal.SIGTERM)
os.kill(os.getpid(), signal.SIGINT)
def print_stack(sig, frame):

View File

@@ -300,7 +300,7 @@ class CameraWatchdog(threading.Thread):
for d in os.listdir(CACHE_DIR)
if os.path.isfile(os.path.join(CACHE_DIR, d))
and d.endswith(".mp4")
and not d.startswith("clip_")
and not d.startswith("preview_")
]
)
newest_segment_time = latest_segment
@@ -360,6 +360,7 @@ def capture_camera(name, config: CameraConfig, process_info):
stop_event = mp.Event()
def receiveSignal(signalNumber, frame):
logger.debug(f"Capture camera received signal {signalNumber}")
stop_event.set()
signal.signal(signal.SIGTERM, receiveSignal)
@@ -446,6 +447,12 @@ def track_camera(
region_grid,
)
# empty the frame queue
logger.info(f"{name}: emptying frame queue")
while not frame_queue.empty():
frame_time = frame_queue.get(False)
frame_manager.delete(f"{name}{frame_time}")
logger.info(f"{name}: exiting subprocess")

View File

@@ -0,0 +1,75 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "rmuF9iKWTbdk"
},
"outputs": [],
"source": [
"! pip install -q super_gradients==3.7.1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "dTB0jy_NNSFz"
},
"outputs": [],
"source": [
"from super_gradients.common.object_names import Models\n",
"from super_gradients.conversion import DetectionOutputFormatMode\n",
"from super_gradients.training import models\n",
"\n",
"model = models.get(Models.YOLO_NAS_S, pretrained_weights=\"coco\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "GymUghyCNXem"
},
"outputs": [],
"source": [
"# export the model for compatibility with Frigate\n",
"\n",
"model.export(\"yolo_nas_s.onnx\",\n",
" output_predictions_format=DetectionOutputFormatMode.FLAT_FORMAT,\n",
" max_predictions_per_image=20,\n",
" confidence_threshold=0.4,\n",
" input_image_shape=(320,320),\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "uBhXV5g4Nh42"
},
"outputs": [],
"source": [
"from google.colab import files\n",
"\n",
"files.download('yolo_nas_s.onnx')"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

687
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -46,9 +46,10 @@
"immer": "^10.1.1",
"konva": "^9.3.9",
"lodash": "^4.17.21",
"lucide-react": "^0.379.0",
"lucide-react": "^0.390.0",
"monaco-yaml": "^5.1.1",
"next-themes": "^0.3.0",
"nosleep.js": "^0.12.0",
"react": "^18.3.1",
"react-apexcharts": "^1.4.1",
"react-day-picker": "^8.10.1",
@@ -71,6 +72,7 @@
"strftime": "^0.10.2",
"swr": "^2.2.5",
"tailwind-merge": "^2.3.0",
"tailwind-scrollbar": "^3.1.0",
"tailwindcss-animate": "^1.0.7",
"vaul": "^0.9.1",
"vite-plugin-monaco-editor": "^1.1.0",
@@ -92,7 +94,7 @@
"@vitejs/plugin-react-swc": "^3.6.0",
"@vitest/coverage-v8": "^1.6.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.55.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.2.0",
"eslint-plugin-prettier": "^5.0.1",
@@ -105,7 +107,7 @@
"msw": "^2.3.0",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.14",
"prettier-plugin-tailwindcss": "^0.6.1",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5",
"vite": "^5.2.11",

View File

@@ -20,12 +20,11 @@ const System = lazy(() => import("@/pages/System"));
const Settings = lazy(() => import("@/pages/Settings"));
const UIPlayground = lazy(() => import("@/pages/UIPlayground"));
const Logs = lazy(() => import("@/pages/Logs"));
const NoMatch = lazy(() => import("@/pages/NoMatch"));
function App() {
return (
<Providers>
<BrowserRouter>
<BrowserRouter basename={window.baseUrl}>
<Wrapper>
<div className="size-full overflow-hidden">
{isDesktop && <Sidebar />}
@@ -52,7 +51,7 @@ function App() {
<Route path="/config" element={<ConfigEditor />} />
<Route path="/logs" element={<Logs />} />
<Route path="/playground" element={<UIPlayground />} />
<Route path="*" element={<NoMatch />} />
<Route path="*" element={<Redirect to="/" />} />
</Routes>
</Suspense>
</div>

View File

@@ -77,6 +77,7 @@ function useValue(): useValueReturn {
});
},
shouldReconnect: () => true,
retryOnError: true,
});
const setState = useCallback(

View File

@@ -1,33 +1,20 @@
import { useFrigateStats } from "@/api/ws";
import {
StatusBarMessagesContext,
StatusMessage,
} from "@/context/statusbar-provider";
import useStats from "@/hooks/use-stats";
import { FrigateStats } from "@/types/stats";
import useStats, { useAutoFrigateStats } from "@/hooks/use-stats";
import { useContext, useEffect, useMemo } from "react";
import { FaCheck } from "react-icons/fa";
import { IoIosWarning } from "react-icons/io";
import { MdCircle } from "react-icons/md";
import { Link } from "react-router-dom";
import useSWR from "swr";
export default function Statusbar() {
const { data: initialStats } = useSWR<FrigateStats>("stats", {
revalidateOnFocus: false,
});
const { payload: latestStats } = useFrigateStats();
const { messages, addMessage, clearMessages } = useContext(
StatusBarMessagesContext,
)!;
const stats = useMemo(() => {
if (latestStats) {
return latestStats;
}
return initialStats;
}, [initialStats, latestStats]);
const stats = useAutoFrigateStats();
const cpuPercent = useMemo(() => {
const systemCpu = stats?.cpu_usages["frigate.full_system"]?.cpu;
@@ -94,6 +81,10 @@ export default function Statusbar() {
const gpu = parseInt(stats.gpu);
if (isNaN(gpu)) {
return;
}
return (
<Link key={gpuTitle} to="/system#general">
{" "}

View File

@@ -69,7 +69,7 @@ export default function AutoUpdatingCameraImage({
<CameraImage
camera={camera}
onload={handleLoad}
searchParams={`cache=${key}&${searchParams}`}
searchParams={`cache=${key}${searchParams ? `&${searchParams}` : ""}`}
className={cameraClasses}
/>
{showFps ? <span className="text-xs">Displaying at {fps}fps</span> : null}

View File

@@ -7,17 +7,19 @@ import { REVIEW_PADDING, ReviewSegment } from "@/types/review";
import { useNavigate } from "react-router-dom";
import { RecordingStartingPoint } from "@/types/record";
import axios from "axios";
import {
InProgressPreview,
VideoPreview,
} from "../player/PreviewThumbnailPlayer";
import { VideoPreview } from "../player/PreviewThumbnailPlayer";
import { isCurrentHour } from "@/utils/dateUtil";
import { useCameraPreviews } from "@/hooks/use-camera-previews";
import { baseUrl } from "@/api/baseUrl";
type AnimatedEventCardProps = {
event: ReviewSegment;
selectedGroup?: string;
};
export function AnimatedEventCard({ event }: AnimatedEventCardProps) {
export function AnimatedEventCard({
event,
selectedGroup,
}: AnimatedEventCardProps) {
const { data: config } = useSWR<FrigateConfig>("config");
const currentHour = useMemo(() => isCurrentHour(event.start_time), [event]);
@@ -55,7 +57,8 @@ export function AnimatedEventCard({ event }: AnimatedEventCardProps) {
const navigate = useNavigate();
const onOpenReview = useCallback(() => {
navigate("review", {
const url = selectedGroup ? `review?group=${selectedGroup}` : "review";
navigate(url, {
state: {
severity: event.severity,
recording: {
@@ -66,13 +69,13 @@ export function AnimatedEventCard({ event }: AnimatedEventCardProps) {
},
});
axios.post(`reviews/viewed`, { ids: [event.id] });
}, [navigate, event]);
}, [navigate, selectedGroup, event]);
// image behavior
const aspectRatio = useMemo(() => {
if (!config) {
return 1;
if (!config || !Object.keys(config.cameras).includes(event.camera)) {
return 16 / 9;
}
const detect = config.cameras[event.camera].detect;
@@ -105,19 +108,19 @@ export function AnimatedEventCard({ event }: AnimatedEventCardProps) {
windowVisible={windowVisible}
/>
) : (
<InProgressPreview
review={event}
timeRange={{
after: event.start_time,
before: event.end_time ?? event.start_time + 20,
}}
<video
preload="auto"
autoPlay
playsInline
muted
disableRemotePlayback
loop
showProgress={false}
setReviewed={() => {}}
setIgnoreClick={() => {}}
isPlayingBack={() => {}}
windowVisible={windowVisible}
/>
>
<source
src={`${baseUrl}api/review/${event.id}/preview?format=mp4`}
type="video/mp4"
/>
</video>
)}
</div>
<div className="absolute inset-x-0 bottom-0 h-6 rounded bg-gradient-to-t from-slate-900/50 to-transparent">

View File

@@ -109,43 +109,38 @@ export default function ExportCard({
"relative flex aspect-video items-center justify-center rounded-lg bg-black md:rounded-2xl",
className,
)}
onMouseEnter={
isDesktop && !exportedRecording.in_progress
? () => setHovered(true)
: undefined
}
onMouseLeave={
isDesktop && !exportedRecording.in_progress
? () => setHovered(false)
: undefined
}
onClick={
isDesktop || exportedRecording.in_progress
? undefined
: () => setHovered(!hovered)
}
onMouseEnter={isDesktop ? () => setHovered(true) : undefined}
onMouseLeave={isDesktop ? () => setHovered(false) : undefined}
onClick={isDesktop ? undefined : () => setHovered(!hovered)}
>
{hovered && (
<>
<div className="absolute inset-0 z-10 rounded-lg bg-black bg-opacity-60 md:rounded-2xl" />
<div className="absolute right-1 top-1 flex items-center gap-2">
<a
className="z-20"
download
href={`${baseUrl}${exportedRecording.video_path.replace("/media/frigate/", "")}`}
>
<Chip className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500">
<FaDownload className="size-4 text-white" />
{!exportedRecording.in_progress && (
<a
className="z-20"
download
href={`${baseUrl}${exportedRecording.video_path.replace("/media/frigate/", "")}`}
>
<Chip className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500">
<FaDownload className="size-4 text-white" />
</Chip>
</a>
)}
{!exportedRecording.in_progress && (
<Chip
className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500"
onClick={() =>
setEditName({
original: exportedRecording.name,
update: "",
})
}
>
<MdEditSquare className="size-4 text-white" />
</Chip>
</a>
<Chip
className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500"
onClick={() =>
setEditName({ original: exportedRecording.name, update: "" })
}
>
<MdEditSquare className="size-4 text-white" />
</Chip>
)}
<Chip
className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500"
onClick={() =>
@@ -159,15 +154,17 @@ export default function ExportCard({
</Chip>
</div>
<Button
className="absolute left-1/2 top-1/2 z-20 h-20 w-20 -translate-x-1/2 -translate-y-1/2 cursor-pointer text-white hover:bg-transparent hover:text-white"
variant="ghost"
onClick={() => {
onSelect(exportedRecording);
}}
>
<FaPlay />
</Button>
{!exportedRecording.in_progress && (
<Button
className="absolute left-1/2 top-1/2 z-20 h-20 w-20 -translate-x-1/2 -translate-y-1/2 cursor-pointer text-white hover:bg-transparent hover:text-white"
variant="ghost"
onClick={() => {
onSelect(exportedRecording);
}}
>
<FaPlay />
</Button>
)}
</>
)}
{exportedRecording.in_progress ? (
@@ -177,7 +174,7 @@ export default function ExportCard({
{exportedRecording.thumb_path.length > 0 ? (
<img
className="absolute inset-0 aspect-video size-full rounded-lg object-contain md:rounded-2xl"
src={exportedRecording.thumb_path.replace("/media/frigate", "")}
src={`${baseUrl}${exportedRecording.thumb_path.replace("/media/frigate/", "")}`}
onLoad={() => setLoading(false)}
/>
) : (

View File

@@ -3,12 +3,24 @@ import { useFormattedTimestamp } from "@/hooks/use-date-utils";
import { FrigateConfig } from "@/types/frigateConfig";
import { ReviewSegment } from "@/types/review";
import { getIconForLabel } from "@/utils/iconUtil";
import { isSafari } from "react-device-detect";
import { isDesktop, isIOS, isSafari } from "react-device-detect";
import useSWR from "swr";
import TimeAgo from "../dynamic/TimeAgo";
import { useMemo } from "react";
import { useCallback, useMemo, useState } from "react";
import useImageLoaded from "@/hooks/use-image-loaded";
import ImageLoadingIndicator from "../indicators/ImageLoadingIndicator";
import { FaCompactDisc } from "react-icons/fa";
import { FaCircleCheck } from "react-icons/fa6";
import { HiTrash } from "react-icons/hi";
import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuTrigger,
} from "../ui/context-menu";
import { Drawer, DrawerContent } from "../ui/drawer";
import axios from "axios";
import { toast } from "sonner";
type ReviewCardProps = {
event: ReviewSegment;
@@ -33,10 +45,61 @@ export default function ReviewCard({
[event, currentTime],
);
return (
const [optionsOpen, setOptionsOpen] = useState(false);
const onMarkAsReviewed = useCallback(async () => {
await axios.post(`reviews/viewed`, { ids: [event.id] });
event.has_been_reviewed = true;
setOptionsOpen(false);
}, [event]);
const onExport = useCallback(async () => {
axios
.post(
`export/${event.camera}/start/${event.start_time}/end/${event.end_time}`,
{ playback: "realtime" },
)
.then((response) => {
if (response.status == 200) {
toast.success(
"Successfully started export. View the file in the /exports folder.",
{ position: "top-center" },
);
}
})
.catch((error) => {
if (error.response?.data?.message) {
toast.error(
`Failed to start export: ${error.response.data.message}`,
{ position: "top-center" },
);
} else {
toast.error(`Failed to start export: ${error.message}`, {
position: "top-center",
});
}
});
setOptionsOpen(false);
}, [event]);
const onDelete = useCallback(async () => {
await axios.post(`reviews/delete`, { ids: [event.id] });
event.id = "";
setOptionsOpen(false);
}, [event]);
const content = (
<div
className="relative flex w-full cursor-pointer flex-col gap-1.5"
onClick={onClick}
onContextMenu={
isDesktop
? undefined
: (e) => {
e.preventDefault();
setOptionsOpen(true);
}
}
>
<ImageLoadingIndicator
className="absolute inset-0"
@@ -47,6 +110,15 @@ export default function ReviewCard({
className={`size-full rounded-lg ${isSelected ? "outline outline-[3px] outline-offset-1 outline-selected" : ""} ${imgLoaded ? "visible" : "invisible"}`}
src={`${baseUrl}${event.thumb_path.replace("/media/frigate/", "")}`}
loading={isSafari ? "eager" : "lazy"}
style={
isIOS
? {
WebkitUserSelect: "none",
WebkitTouchCallout: "none",
}
: undefined
}
draggable={false}
onLoad={() => {
onImgLoad();
}}
@@ -69,4 +141,78 @@ export default function ReviewCard({
</div>
</div>
);
if (event.id == "") {
return;
}
if (isDesktop) {
return (
<ContextMenu>
<ContextMenuTrigger asChild>{content}</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem>
<div
className="flex w-full cursor-pointer items-center justify-start gap-2 p-2"
onClick={onExport}
>
<FaCompactDisc className="text-secondary-foreground" />
<div className="text-primary">Export</div>
</div>
</ContextMenuItem>
{!event.has_been_reviewed && (
<ContextMenuItem>
<div
className="flex w-full cursor-pointer items-center justify-start gap-2 p-2"
onClick={onMarkAsReviewed}
>
<FaCircleCheck className="text-secondary-foreground" />
<div className="text-primary">Mark as reviewed</div>
</div>
</ContextMenuItem>
)}
<ContextMenuItem>
<div
className="flex w-full cursor-pointer items-center justify-start gap-2 p-2"
onClick={onDelete}
>
<HiTrash className="text-secondary-foreground" />
<div className="text-primary">Delete</div>
</div>
</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>
);
}
return (
<Drawer open={optionsOpen} onOpenChange={setOptionsOpen}>
{content}
<DrawerContent>
<div
className="flex w-full items-center justify-start gap-2 p-2"
onClick={onExport}
>
<FaCompactDisc className="text-secondary-foreground" />
<div className="text-primary">Export</div>
</div>
{!event.has_been_reviewed && (
<div
className="flex w-full items-center justify-start gap-2 p-2"
onClick={onMarkAsReviewed}
>
<FaCircleCheck className="text-secondary-foreground" />
<div className="text-primary">Mark as reviewed</div>
</div>
)}
<div
className="flex w-full items-center justify-start gap-2 p-2"
onClick={onDelete}
>
<HiTrash className="text-secondary-foreground" />
<div className="text-primary">Delete</div>
</div>
</DrawerContent>
</Drawer>
);
}

View File

@@ -2,6 +2,7 @@ import { ReviewSegment } from "@/types/review";
import { Button } from "../ui/button";
import { LuRefreshCcw } from "react-icons/lu";
import { MutableRefObject, useMemo } from "react";
import { cn } from "@/lib/utils";
type NewReviewDataProps = {
className: string;
@@ -29,11 +30,12 @@ export default function NewReviewData({
<div className={className}>
<div className="pointer-events-auto mr-[65px] flex items-center justify-center md:mr-[115px]">
<Button
className={`${
className={cn(
hasUpdate
? "duration-500 animate-in slide-in-from-top"
: "invisible"
} mx-auto mt-5 bg-gray-400 text-center text-white`}
: "invisible",
"mx-auto mt-5 bg-gray-400 text-center text-white",
)}
onClick={() => {
pullLatestData();
if (contentRef.current) {

View File

@@ -310,7 +310,7 @@ function NewGroupDialog({
<Content
className={`min-w-0 ${isMobile ? "max-h-[90%] w-full rounded-t-2xl p-3" : "max-h-dvh w-6/12 overflow-y-hidden"}`}
>
<div className="my-4 flex flex-col overflow-y-auto">
<div className="scrollbar-container my-4 flex flex-col overflow-y-auto">
{editState === "none" && (
<>
<div className="flex flex-row items-center justify-between py-2">
@@ -400,7 +400,7 @@ export function EditGroupDialog({
<DialogContent
className={`min-w-0 ${isMobile ? "max-h-[90%] w-full rounded-t-2xl p-3" : "max-h-dvh w-6/12 overflow-y-hidden"}`}
>
<div className="my-4 flex flex-col overflow-y-auto">
<div className="scrollbar-container my-4 flex flex-col overflow-y-auto">
<div className="mb-3 flex flex-row items-center justify-between">
<DialogTitle>Edit Camera Group</DialogTitle>
</div>
@@ -468,7 +468,7 @@ export function CameraGroupRow({
{isMobile && (
<>
<DropdownMenu>
<DropdownMenu modal={false}>
<DropdownMenuTrigger>
<HiOutlineDotsVertical className="size-5" />
</DropdownMenuTrigger>
@@ -555,9 +555,7 @@ export function CameraGroupEdit({
message: "Invalid camera group name.",
}),
cameras: z.array(z.string()).min(2, {
message: "You must select at least two cameras.",
}),
cameras: z.array(z.string()),
icon: z
.string()
.min(1, { message: "You must select an icon." })
@@ -653,7 +651,7 @@ export function CameraGroupEdit({
/>
<Separator className="my-2 flex bg-secondary" />
<div className="max-h-[25dvh] overflow-y-auto md:max-h-[40dvh]">
<div className="scrollbar-container max-h-[25dvh] overflow-y-auto md:max-h-[40dvh]">
<FormField
control={form.control}
name="cameras"
@@ -663,6 +661,7 @@ export function CameraGroupEdit({
<FormDescription>
Select cameras for this group.
</FormDescription>
<FormMessage />
{[
...(birdseyeConfig?.enabled ? ["birdseye"] : []),
...Object.keys(config?.cameras ?? {}),
@@ -680,7 +679,6 @@ export function CameraGroupEdit({
/>
</FormControl>
))}
<FormMessage />
</FormItem>
)}
/>

View File

@@ -58,7 +58,7 @@ export function GeneralFilterContent({
}: GeneralFilterContentProps) {
return (
<>
<div className="h-auto overflow-y-auto overflow-x-hidden">
<div className="scrollbar-container h-auto overflow-y-auto overflow-x-hidden">
<div className="my-2.5 flex items-center justify-between">
<Label
className="mx-2 cursor-pointer text-primary"

View File

@@ -30,6 +30,7 @@ import MobileReviewSettingsDrawer, {
} from "../overlay/MobileReviewSettingsDrawer";
import useOptimisticState from "@/hooks/use-optimistic-state";
import FilterSwitch from "./FilterSwitch";
import { FilterList } from "@/types/filter";
const REVIEW_FILTERS = [
"cameras",
@@ -53,7 +54,7 @@ type ReviewFilterGroupProps = {
reviewSummary?: ReviewSummary;
filter?: ReviewFilter;
motionOnly: boolean;
filterLabels?: string[];
filterList?: FilterList;
onUpdateFilter: (filter: ReviewFilter) => void;
setMotionOnly: React.Dispatch<React.SetStateAction<boolean>>;
};
@@ -64,15 +65,15 @@ export default function ReviewFilterGroup({
reviewSummary,
filter,
motionOnly,
filterLabels,
filterList,
onUpdateFilter,
setMotionOnly,
}: ReviewFilterGroupProps) {
const { data: config } = useSWR<FrigateConfig>("config");
const allLabels = useMemo<string[]>(() => {
if (filterLabels) {
return filterLabels;
if (filterList?.labels) {
return filterList.labels;
}
if (!config) {
@@ -99,14 +100,43 @@ export default function ReviewFilterGroup({
});
return [...labels].sort();
}, [config, filterLabels, filter]);
}, [config, filterList, filter]);
const allZones = useMemo<string[]>(() => {
if (filterList?.zones) {
return filterList.zones;
}
if (!config) {
return [];
}
const zones = new Set<string>();
const cameras = filter?.cameras || Object.keys(config.cameras);
cameras.forEach((camera) => {
if (camera == "birdseye") {
return;
}
const cameraConfig = config.cameras[camera];
cameraConfig.review.alerts.required_zones.forEach((zone) => {
zones.add(zone);
});
cameraConfig.review.detections.required_zones.forEach((zone) => {
zones.add(zone);
});
});
return [...zones].sort();
}, [config, filterList, filter]);
const filterValues = useMemo(
() => ({
cameras: Object.keys(config?.cameras || {}),
labels: Object.values(allLabels || {}),
zones: Object.values(allZones || {}),
}),
[config, allLabels],
[config, allLabels, allZones],
);
const groups = useMemo(() => {
@@ -189,12 +219,17 @@ export default function ReviewFilterGroup({
selectedLabels={filter?.labels}
currentSeverity={currentSeverity}
showAll={filter?.showAll == true}
allZones={filterValues.zones}
selectedZones={filter?.zones}
setShowAll={(showAll) => {
onUpdateFilter({ ...filter, showAll });
}}
updateLabelFilter={(newLabels) => {
onUpdateFilter({ ...filter, labels: newLabels });
}}
updateZoneFilter={(newZones) =>
onUpdateFilter({ ...filter, zones: newZones })
}
/>
)}
{isMobile && mobileSettingsFeatures.length > 0 && (
@@ -204,6 +239,7 @@ export default function ReviewFilterGroup({
currentSeverity={currentSeverity}
reviewSummary={reviewSummary}
allLabels={allLabels}
allZones={allZones}
onUpdateFilter={onUpdateFilter}
// not applicable as exports are not used
camera=""
@@ -263,7 +299,7 @@ export function CamerasFilterButton({
<DropdownMenuSeparator />
</>
)}
<div className="h-auto max-h-[80dvh] overflow-y-auto overflow-x-hidden p-4">
<div className="scrollbar-container h-auto max-h-[80dvh] overflow-y-auto overflow-x-hidden p-4">
<FilterSwitch
isChecked={currentCameras == undefined}
label="All Cameras"
@@ -365,6 +401,7 @@ export function CamerasFilterButton({
return (
<DropdownMenu
modal={false}
open={open}
onOpenChange={(open) => {
if (!open) {
@@ -494,33 +531,44 @@ type GeneralFilterButtonProps = {
selectedLabels: string[] | undefined;
currentSeverity?: ReviewSeverity;
showAll: boolean;
allZones: string[];
selectedZones?: string[];
setShowAll: (showAll: boolean) => void;
updateLabelFilter: (labels: string[] | undefined) => void;
updateZoneFilter: (zones: string[] | undefined) => void;
};
function GeneralFilterButton({
allLabels,
selectedLabels,
currentSeverity,
showAll,
allZones,
selectedZones,
setShowAll,
updateLabelFilter,
updateZoneFilter,
}: GeneralFilterButtonProps) {
const [open, setOpen] = useState(false);
const [currentLabels, setCurrentLabels] = useState<string[] | undefined>(
selectedLabels,
);
const [currentZones, setCurrentZones] = useState<string[] | undefined>(
selectedZones,
);
const trigger = (
<Button
size="sm"
variant={selectedLabels?.length ? "select" : "default"}
variant={
selectedLabels?.length || selectedZones?.length ? "select" : "default"
}
className="flex items-center gap-2 capitalize"
>
<FaFilter
className={`${selectedLabels?.length ? "text-selected-foreground" : "text-secondary-foreground"}`}
className={`${selectedLabels?.length || selectedZones?.length ? "text-selected-foreground" : "text-secondary-foreground"}`}
/>
<div
className={`hidden md:block ${selectedLabels?.length ? "text-selected-foreground" : "text-primary"}`}
className={`hidden md:block ${selectedLabels?.length || selectedZones?.length ? "text-selected-foreground" : "text-primary"}`}
>
Filter
</div>
@@ -533,6 +581,11 @@ function GeneralFilterButton({
currentLabels={currentLabels}
currentSeverity={currentSeverity}
showAll={showAll}
allZones={allZones}
selectedZones={selectedZones}
currentZones={currentZones}
setCurrentZones={setCurrentZones}
updateZoneFilter={updateZoneFilter}
setShowAll={setShowAll}
updateLabelFilter={updateLabelFilter}
setCurrentLabels={setCurrentLabels}
@@ -583,9 +636,14 @@ type GeneralFilterContentProps = {
currentLabels: string[] | undefined;
currentSeverity?: ReviewSeverity;
showAll?: boolean;
allZones?: string[];
selectedZones?: string[];
currentZones?: string[];
setShowAll?: (showAll: boolean) => void;
updateLabelFilter: (labels: string[] | undefined) => void;
setCurrentLabels: (labels: string[] | undefined) => void;
updateZoneFilter?: (zones: string[] | undefined) => void;
setCurrentZones?: (zones: string[] | undefined) => void;
onClose: () => void;
};
export function GeneralFilterContent({
@@ -594,14 +652,19 @@ export function GeneralFilterContent({
currentLabels,
currentSeverity,
showAll,
allZones,
selectedZones,
currentZones,
setShowAll,
updateLabelFilter,
setCurrentLabels,
updateZoneFilter,
setCurrentZones,
onClose,
}: GeneralFilterContentProps) {
return (
<>
<div className="h-auto max-h-[80dvh] overflow-y-auto overflow-x-hidden">
<div className="scrollbar-container h-auto max-h-[80dvh] overflow-y-auto overflow-x-hidden">
{currentSeverity && setShowAll && (
<div className="my-2.5 flex flex-col gap-2.5">
<FilterSwitch
@@ -621,7 +684,7 @@ export function GeneralFilterContent({
<DropdownMenuSeparator />
</div>
)}
<div className="my-2.5 flex items-center justify-between">
<div className="mb-5 mt-2.5 flex items-center justify-between">
<Label
className="mx-2 cursor-pointer text-primary"
htmlFor="allLabels"
@@ -639,7 +702,6 @@ export function GeneralFilterContent({
}}
/>
</div>
<DropdownMenuSeparator />
<div className="my-2.5 flex flex-col gap-2.5">
{allLabels.map((item) => (
<FilterSwitch
@@ -664,6 +726,58 @@ export function GeneralFilterContent({
/>
))}
</div>
{allZones && setCurrentZones && (
<>
<DropdownMenuSeparator />
<div className="mb-5 mt-2.5 flex items-center justify-between">
<Label
className="mx-2 cursor-pointer text-primary"
htmlFor="allZones"
>
All Zones
</Label>
<Switch
className="ml-1"
id="allZones"
checked={currentZones == undefined}
onCheckedChange={(isChecked) => {
if (isChecked) {
setCurrentZones(undefined);
}
}}
/>
</div>
<div className="my-2.5 flex flex-col gap-2.5">
{allZones.map((item) => (
<FilterSwitch
label={item.replaceAll("_", " ")}
isChecked={currentZones?.includes(item) ?? false}
onCheckedChange={(isChecked) => {
if (isChecked) {
const updatedZones = currentZones
? [...currentZones]
: [];
updatedZones.push(item);
setCurrentZones(updatedZones);
} else {
const updatedZones = currentZones
? [...currentZones]
: [];
// can not deselect the last item
if (updatedZones.length > 1) {
updatedZones.splice(updatedZones.indexOf(item), 1);
setCurrentZones(updatedZones);
}
}
}}
/>
))}
</div>
</>
)}
</div>
<DropdownMenuSeparator />
<div className="flex items-center justify-evenly p-2">
@@ -674,6 +788,10 @@ export function GeneralFilterContent({
updateLabelFilter(currentLabels);
}
if (updateZoneFilter && selectedZones != currentZones) {
updateZoneFilter(currentZones);
}
onClose();
}}
>
@@ -682,6 +800,7 @@ export function GeneralFilterContent({
<Button
onClick={() => {
setCurrentLabels(undefined);
setCurrentZones?.(undefined);
updateLabelFilter(undefined);
}}
>

View File

@@ -0,0 +1,138 @@
import { useTheme } from "@/context/theme-provider";
import { FrigateConfig } from "@/types/frigateConfig";
import { useCallback, useEffect, useMemo } from "react";
import Chart from "react-apexcharts";
import { isMobileOnly } from "react-device-detect";
import { MdCircle } from "react-icons/md";
import useSWR from "swr";
const GRAPH_COLORS = ["#5C7CFA", "#ED5CFA", "#FAD75C"];
type CameraLineGraphProps = {
graphId: string;
unit: string;
dataLabels: string[];
updateTimes: number[];
data: ApexAxisChartSeries;
};
export function CameraLineGraph({
graphId,
unit,
dataLabels,
updateTimes,
data,
}: CameraLineGraphProps) {
const { data: config } = useSWR<FrigateConfig>("config", {
revalidateOnFocus: false,
});
const lastValues = useMemo<number[] | undefined>(() => {
if (!dataLabels || !data || data.length == 0) {
return undefined;
}
return dataLabels.map(
(_, labelIdx) =>
// @ts-expect-error y is valid
data[labelIdx].data[data[labelIdx].data.length - 1]?.y ?? 0,
) as number[];
}, [data, dataLabels]);
const { theme, systemTheme } = useTheme();
const formatTime = useCallback(
(val: unknown) => {
const date = new Date(updateTimes[Math.round(val as number)] * 1000);
return date.toLocaleTimeString([], {
hour12: config?.ui.time_format != "24hour",
hour: "2-digit",
minute: "2-digit",
});
},
[config, updateTimes],
);
const options = useMemo(() => {
return {
chart: {
id: graphId,
selection: {
enabled: false,
},
toolbar: {
show: false,
},
zoom: {
enabled: false,
},
},
colors: GRAPH_COLORS,
grid: {
show: false,
},
legend: {
show: false,
},
dataLabels: {
enabled: false,
},
stroke: {
width: 1,
},
tooltip: {
theme: systemTheme || theme,
},
markers: {
size: 0,
},
xaxis: {
tickAmount: isMobileOnly ? 3 : 4,
tickPlacement: "on",
labels: {
rotate: 0,
formatter: formatTime,
},
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
},
yaxis: {
show: true,
labels: {
formatter: (val: number) => Math.ceil(val).toString(),
},
min: 0,
},
} as ApexCharts.ApexOptions;
}, [graphId, systemTheme, theme, formatTime]);
useEffect(() => {
ApexCharts.exec(graphId, "updateOptions", options, true, true);
}, [graphId, options]);
return (
<div className="flex w-full flex-col">
{lastValues && (
<div className="flex flex-wrap items-center gap-2.5">
{dataLabels.map((label, labelIdx) => (
<div key={label} className="flex items-center gap-1">
<MdCircle
className="size-2"
style={{ color: GRAPH_COLORS[labelIdx] }}
/>
<div className="text-xs text-muted-foreground">{label}</div>
<div className="text-xs text-primary">
{lastValues[labelIdx]}
{unit}
</div>
</div>
))}
</div>
)}
<Chart type="line" options={options} series={data} height="120" />
</div>
);
}

Some files were not shown because too many files have changed in this diff Show More