Compare commits

...

79 Commits

Author SHA1 Message Date
Nicolas Mowen
a4eb435f1a Improve safari image scrolling performance (#12429)
* Don't set z-height on iOS

* More z-index cleanup
2024-07-13 11:54:24 -05:00
Nicolas Mowen
843d301950 Don't detach media (#12421) 2024-07-12 15:29:42 -06:00
Nicolas Mowen
d08fe170f2 Recordings improvements (#12417) 2024-07-12 15:17:38 -06:00
Josh Hawkins
51153af944 Attempt to support zoom-only onvif cams (#12415)
* Attempt to support zoom-only onvif cams

* don't skip ptz configuration
2024-07-12 11:01:52 -06:00
Josh Hawkins
e7ec014502 Ensure detections are cleared when limit box is unchecked (#12412) 2024-07-12 09:07:01 -06:00
Josh Hawkins
2ebd2dfcc7 Display activity indicators when debug and mask/zone images load (#12411) 2024-07-12 09:02:43 -05:00
Josh Hawkins
aaafd63b94 Move review classification settings to camera settings view (#12410)
* Camera settings view for alerts/detections

* flxes, beautifying, zone renaming, clean up

* replace underscores with spaces in zone names

* replace underscores with spaces in labels
2024-07-12 07:42:53 -06:00
Nicolas Mowen
a361372182 Update review docs (#12401) 2024-07-12 07:36:28 -06:00
Josh Thorpe
8f51f7b4c4 strip whitespaces when loading secrets (#12393)
* strip whitespaces when loading secrets

* formatting
2024-07-12 07:36:15 -06:00
Nicolas Mowen
e416e44998 Simplify ws updating (#12390)
* Simplify ws updating

* Simplify return values
2024-07-11 09:25:33 -06:00
Josh Hawkins
fe4a737421 Fix debug camera image not updating when loading (#12394) 2024-07-11 09:10:37 -06:00
Josh Hawkins
4ee8557061 Fix linter warnings on color order (#12389) 2024-07-11 08:22:02 -05:00
Nicolas Mowen
88e1d56799 Update Web deps (#12388)
* Update radix ui

* Update vite

* More ui deps

* Update typscript

* Update react router
2024-07-11 08:09:35 -05:00
Nicolas Mowen
40be915061 Fix review update causing api spam (#12387) 2024-07-11 08:09:11 -05:00
Josh Hawkins
0d7ee7a87a Clickable logo on desktop sidebar and useMatch for camera group visibility (#12379) 2024-07-10 09:28:05 -06:00
Nicolas Mowen
baf209f257 Docs tweaks (#12375)
* Add explanation of bounding box colors

* Add FAQ about offline camera
2024-07-10 06:34:03 -06:00
Josh Hawkins
c2824d153e Theme updates (#12373)
* remove hideous and ugly themes

* incorporate dei into ui design

* neutral as a theme color

* high contrast theme adjustments

* color tweaks
2024-07-10 07:04:02 -05:00
Josh Hawkins
d2f88491b1 Various UI tweaks and changes (#12364) 2024-07-09 13:36:55 -06:00
stephendb
aacb8c84e0 Bug fix for ONVIF cameras, adjust_time parameter added (#12352)
* adds adjust_time which allows users to fix an issue with onvif authentication where time is not syncrhonized

* updated adjust_time to ignore_time_mismatch to make it clearer what this option does

* adds ignore_time_mismatch to the reference.md and adds a line about the security risk this can introduce as well as the recommendation to setup NTP for both ends.

* fix format error

* happy now linter?

* white space

* Update docs/docs/configuration/reference.md

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

---------

Co-authored-by: Stephen Butler <stephen.butler@ni.com>
Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
2024-07-09 13:00:47 -06:00
Nicolas Mowen
f44df9fe61 Revert "Limited shm frame count (#12346)" (#12362)
This reverts commit 34812b7439.
2024-07-09 11:49:08 -05:00
Nicolas Mowen
34812b7439 Limited shm frame count (#12346)
* Only keep 2x detect fps frames in SHM

* Don't delete previous shm frames in output

* Catch case where images do not exist

* Ensure files are closed

* Clear out all frames when shutting down

* Correct the number of frames saved

* Simplify empty shm error handling

* Improve frame safety
2024-07-09 06:44:53 -06:00
Josh Hawkins
0ce596ec8f UI tweaks (#12297)
* Use full resolution aspect for main camera style in history view

* Only check for offline cameras after 60s of uptime

* only call onPlaying when loadeddata is fired or after timeout

* revert to inline funcs

* Portal frigate plus alert dialog

* remove duplicated logic

* increase onplaying timeout

* Use a ref instead of a state and clear timeout in AutoUpdatingCameraImage

* default to the selected month for selectedDay

* Use buffered time instead of timeout

* Use default cursor when not editing polygons
2024-07-08 07:14:10 -06:00
ubawurinna
2ea1d34f4f OpenVino - Error clarification for compile_model function (#12304)
* Error clarification for openvino's compile_model function

* run ruff format

---------

Co-authored-by: ubawurinna <you@example.com>
2024-07-08 08:13:33 -05:00
Josh Hawkins
a0741aa7b1 Remove matplotlib and generate color palette to mimic matplotlib's colors (#12327) 2024-07-07 12:53:00 -06:00
Josh Hawkins
188a7de467 Update export docs (#12288)
* Update exporting docs

* add timelapse clarification
2024-07-04 05:32:07 -06:00
Josh Hawkins
1f4ca32e8c Add exports message and default to webrtc on < iOS 17.1 (#12281) 2024-07-03 08:44:25 -05:00
Josh Hawkins
784b701cc5 Apply landscape margin to ptz controls on mobile only (#12272) 2024-07-02 18:14:38 -05:00
Josh Hawkins
be9e606ae4 Ensure MSE onPlaying always gets called, even if loadeddata never fires (#12271)
* Ensure MSE onPlaying always gets called, even if loadeddata never fires

* Call handleLoadedMetadata too if not playing yet
2024-07-02 16:48:38 -06:00
Steven Conaway
fe9a3c9205 docs(go2rtc): troubleshooting improvements (#12192) 2024-07-02 07:52:32 -06:00
Nicolas Mowen
012aa63571 Enforce minimum value for mqtt stats update (#12253) 2024-07-01 17:08:14 -05:00
Nicolas Mowen
ef7846bb41 Update ffmpeg source (#12251)
* Revert "Use latest 5.1 ffmpeg update (#12243)"

This reverts commit 93e08688be.

* Revert "Change qsv device arg to standard hwaccel arg (#12249)"

This reverts commit 56b4a551dc.

* Use different repo for build
2024-07-01 15:46:40 -06:00
Josh Hawkins
6948702891 Add fullscreen button to the default live grid on desktops (#12250) 2024-07-01 13:00:53 -06:00
Nicolas Mowen
56b4a551dc Change qsv device arg to standard hwaccel arg (#12249) 2024-07-01 12:57:04 -06:00
Nicolas Mowen
93e08688be Use latest 5.1 ffmpeg update (#12243)
* Use latesat 5.1 ffmpeg update

* Fix arm build
2024-07-01 11:08:36 -05:00
Josh Hawkins
0ed7e278eb Re-center ptz controls in mobile landscape and prevent text selection (#12242) 2024-07-01 09:53:36 -06:00
Josh Hawkins
b30fecbd28 Use cache key for mask/zone editor image (#12232) 2024-07-01 09:02:56 -06:00
Josh Hawkins
f050c7b37d Use camera name instead of stream_name for jsmpeg players (#12219) 2024-06-30 11:06:03 -06:00
Josh Hawkins
f9e1ad253f Check websocket readyState for disconnect and fix firefox pip (#12216) 2024-06-30 06:04:45 -06:00
Josh Hawkins
f0159bf41e Fix jsmpeg player flickering (#12213) 2024-06-29 17:45:28 -06:00
Nicolas Mowen
21a777ab45 Fix nginx 5000 template (#12210) 2024-06-29 18:36:24 -05:00
Nicolas Mowen
18b8e19847 Fix audio model download again (#12207)
* Fix audio model download again

* Update Dockerfile
2024-06-29 12:55:55 -06:00
Josh Hawkins
53a2a865f1 Live player fixes and improvements (#12202)
* Live player fixes and improvements

* remove comment

* Simplify wording
2024-06-29 09:02:30 -06:00
Nicolas Mowen
48a87b16b8 Fix yamnet model download (#12200) 2024-06-29 09:35:34 -05:00
Nicolas Mowen
46c3ef8c6b Nginx config tweaks (#12174)
* Change auth port and remove ipv6

* Add docs for nginx bind mount

* Consolidate listen statements

* Update port in docs

* Fix typing
2024-06-29 07:18:40 -06:00
Nicolas Mowen
bfbacee7b5 Quick fix (#12153)
* Use list for zones to keep chronological order

* Replace when changing playbackRate
2024-06-25 07:38:37 -05:00
On Freund
c3455518c2 Update TLS docs with certbot instructions (#12141)
* Update tls.md

Update TLS docs with certbot instructions

* Apply suggestions from code review

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

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2024-06-24 18:06:23 -05:00
Nicolas Mowen
00e235867a Downgrade go2rtc (#12139) 2024-06-24 08:26:32 -05:00
Nicolas Mowen
88046ebd15 Fix review items (#12126) 2024-06-23 18:52:02 -05:00
Nicolas Mowen
abc1ecfb60 Show correct previous state when updating for end (#12122)
* Show correct previous state when updating for end

* remove log

* Formatting
2024-06-23 08:45:10 -05:00
Nicolas Mowen
9bbb88cdcb Fix left swipe on preview (#12104)
* Fix left swipe

* Simplify
2024-06-21 16:06:40 -05:00
Nicolas Mowen
c867d90f50 Add reviews topic to MQTT docs (#12097) 2024-06-21 11:43:52 -05:00
Nicolas Mowen
3410290b45 Fix preview failing on cameras with - in name (#12093) 2024-06-21 07:33:20 -06:00
Nicolas Mowen
b34be991bd Simplify zone objects example (#12086) 2024-06-20 21:06:42 -05:00
Nicolas Mowen
73755e9777 Auto focus user field for login (#12083) 2024-06-20 11:37:54 -05:00
Nicolas Mowen
c871bebee6 Fix export timing (#12080) 2024-06-20 07:25:02 -06:00
Josh Hawkins
a60ffe06ac Prevent ptz keyboard shortcuts from reopening presets menu (#12079) 2024-06-20 07:24:50 -06:00
Josh Hawkins
9f81ce2876 Only close MSE websocket when it's already open (#12078) 2024-06-20 06:03:14 -06:00
Josh Hawkins
5c33cdba4e Timeline performance improvements (#12070)
* Use intersection observer for timeline segments

* only render when visible
2024-06-19 18:14:32 -05:00
Nicolas Mowen
e9cdef9f25 fix case where camera is disabled and has no previews (#12066)
* fix case where camera is disabled and has no previews

* Maintain slow loading behavior
2024-06-19 12:51:19 -06:00
Nicolas Mowen
d01457e64d Fix showing loading indicator when first loading a camera without previews (#12064) 2024-06-19 08:52:45 -06:00
Nicolas Mowen
c72d304515 Update go2rtc (#12063) 2024-06-19 08:46:23 -06:00
Sam Wright
10c1f7ead4 Update web readme (#12062)
* Update web readme

* Update /web readme

* Apply suggestions from code review

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

---------

Co-authored-by: Sam Wright <sam@sams-mbp.lan>
Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2024-06-19 08:11:51 -06:00
Josh Hawkins
7b57a66d45 Various UI tweaks (#12061) 2024-06-19 06:09:49 -06:00
Nicolas Mowen
767033e4d8 Treat meta key same as ctrl (#12051) 2024-06-18 20:26:00 -05:00
Nicolas Mowen
e6790d9a6a Add ability to select all on desktop (#12044)
* Add ability to select all review items

* Refactor keybaord listener
2024-06-18 09:32:17 -05:00
Marc Altmann
4bca405e29 fix key error for custom models (#12042) 2024-06-18 07:40:54 -06:00
Nicolas Mowen
bdda89b5e2 Fix case where S6 timestamp is missing (#12040) 2024-06-18 08:07:28 -05:00
Josh Hawkins
2cbc336bc0 Memoize onPlaying and only instantiate one jsmpeg player (#12033) 2024-06-17 17:10:41 -06:00
Josh Hawkins
6c107883b5 Small jsmpeg and mse player fixes (#12032) 2024-06-17 14:54:14 -06:00
Nicolas Mowen
4635e64b2e Use api path to determine type (#12031)
* Use api path to determine type

* Use in both cases

* Fix extension parsing
2024-06-17 14:53:35 -06:00
Nicolas Mowen
5b60785cca Increase resolution for mobile viewing (#12025) 2024-06-17 12:35:36 -05:00
Nicolas Mowen
ef304e6f7f Set image height to make bandwidth usage lower (#12024) 2024-06-17 08:21:51 -06:00
Nicolas Mowen
24770148a7 Don't fail when preview restore fails (#12022)
* Don't fail when preview restore fails

* Cleanup
2024-06-17 08:56:24 -05:00
Nicolas Mowen
ba6fc0fdb3 UI Tweaks (#12002)
* Adjust review padding

* Fix mse check

* Don't fail when cpu property is missing

* ignore lines without any spaces
2024-06-17 06:19:16 -06:00
Josh Hawkins
89a478ce0a Use modal on dropdowns for mobile only (#11993) 2024-06-16 13:58:28 -05:00
Blake Blackshear
f1bb797fe0 enable tls by default if undefined (#11994) 2024-06-16 07:55:28 -05:00
Miguel Angel Nubla
e208241eea Fix X-Proxy-Secret header passthrough (#11984) 2024-06-16 05:53:02 -05:00
Miguel Angel Nubla
02af1b0ac7 Fix header auth (#11985) 2024-06-16 05:52:17 -05:00
Nicolas Mowen
3c12872a56 Update template to include all detector types (#11981)
* Change from coral to general detector dropdown

* Update camera-support.yml

* Update config-support.yml

* Update general-support.yml
2024-06-15 15:26:09 -05:00
118 changed files with 3545 additions and 1978 deletions

View File

@@ -10,9 +10,9 @@
"features": { "features": {
"ghcr.io/devcontainers/features/common-utils:1": {} "ghcr.io/devcontainers/features/common-utils:1": {}
}, },
"forwardPorts": [8080, 5000, 5001, 5173, 8554, 8555], "forwardPorts": [8971, 5000, 5001, 5173, 8554, 8555],
"portsAttributes": { "portsAttributes": {
"8080": { "8971": {
"label": "External NGINX", "label": "External NGINX",
"onAutoForward": "silent" "onAutoForward": "silent"
}, },

View File

@@ -69,14 +69,14 @@ body:
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
id: coral id: object-detector
attributes: attributes:
label: Coral version label: Object Detector
options: options:
- USB - Coral
- PCIe - OpenVino
- M.2 - TensorRT
- Dev Board - RKNN
- Other - Other
- CPU (no coral) - CPU (no coral)
validations: validations:

View File

@@ -61,14 +61,14 @@ body:
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
id: coral id: object-detector
attributes: attributes:
label: Coral version label: Object Detector
options: options:
- USB - Coral
- PCIe - OpenVino
- M.2 - TensorRT
- Dev Board - RKNN
- Other - Other
- CPU (no coral) - CPU (no coral)
validations: validations:

View File

@@ -63,14 +63,14 @@ body:
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
id: coral id: object-detector
attributes: attributes:
label: Coral version label: Object Detector
options: options:
- USB - Coral
- PCIe - OpenVino
- M.2 - TensorRT
- Dev Board - RKNN
- Other - Other
- CPU (no coral) - CPU (no coral)
validations: validations:

View File

@@ -69,14 +69,14 @@ body:
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
id: coral id: object-detector
attributes: attributes:
label: Coral version label: Object Detector
options: options:
- USB - Coral
- PCIe - OpenVino
- M.2 - TensorRT
- Dev Board - RKNN
- Other - Other
- CPU (no coral) - CPU (no coral)
validations: validations:

View File

@@ -78,7 +78,7 @@ 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 && \ 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 sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt
# Get Audio Model and labels # Get Audio Model and labels
RUN wget -qO cpu_audio_model.tflite https://tfhub.dev/google/lite-model/yamnet/classification/tflite/1?lite-format=tflite RUN wget -qO - https://www.kaggle.com/api/v1/models/google/yamnet/tfLite/classification-tflite/1/download | tar xvz && mv 1.tflite cpu_audio_model.tflite
COPY audio-labelmap.txt . COPY audio-labelmap.txt .

View File

@@ -40,7 +40,7 @@ apt-get -qq install --no-install-recommends --no-install-suggests -y \
# btbn-ffmpeg -> amd64 # btbn-ffmpeg -> amd64
if [[ "${TARGETARCH}" == "amd64" ]]; then if [[ "${TARGETARCH}" == "amd64" ]]; then
mkdir -p /usr/lib/btbn-ffmpeg mkdir -p /usr/lib/btbn-ffmpeg
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux64-gpl-5.1.tar.xz" wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux64-gpl-5.1.tar.xz"
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1 tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1
rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay
fi fi
@@ -48,7 +48,7 @@ fi
# ffmpeg -> arm64 # ffmpeg -> arm64
if [[ "${TARGETARCH}" == "arm64" ]]; then if [[ "${TARGETARCH}" == "arm64" ]]; then
mkdir -p /usr/lib/btbn-ffmpeg mkdir -p /usr/lib/btbn-ffmpeg
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linuxarm64-gpl-5.1.tar.xz" wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linuxarm64-gpl-5.1.tar.xz"
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1 tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1
rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay
fi fi

View File

@@ -4,7 +4,6 @@ Flask_Limiter == 3.7.*
imutils == 0.5.* imutils == 0.5.*
joserfc == 0.11.* joserfc == 0.11.*
markupsafe == 2.1.* markupsafe == 2.1.*
matplotlib == 3.8.*
mypy == 1.6.1 mypy == 1.6.1
numpy == 1.26.* numpy == 1.26.*
onvif_zeep == 0.2.12 onvif_zeep == 0.2.12

View File

@@ -34,7 +34,7 @@ do
;; ;;
esac 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'` liveprint=`echo | openssl s_client -showcerts -connect 127.0.0.1:8971 2>&1 | openssl x509 -fingerprint 2>&1 | grep -i fingerprint || echo 'failed'`
case "$liveprint" in case "$liveprint" in
*Fingerprint*) *Fingerprint*)

View File

@@ -21,9 +21,9 @@ FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE
if os.path.isdir("/run/secrets"): if os.path.isdir("/run/secrets"):
for secret_file in os.listdir("/run/secrets"): for secret_file in os.listdir("/run/secrets"):
if secret_file.startswith("FRIGATE_"): if secret_file.startswith("FRIGATE_"):
FRIGATE_ENV_VARS[secret_file] = Path( FRIGATE_ENV_VARS[secret_file] = (
os.path.join("/run/secrets", secret_file) Path(os.path.join("/run/secrets", secret_file)).read_text().strip()
).read_text() )
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml") config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")

View File

@@ -59,9 +59,6 @@ http {
include go2rtc_upstream.conf; include go2rtc_upstream.conf;
server { server {
# intended for internal traffic, not protected by auth
listen [::]:5000 ipv6only=off;
include listen.conf; include listen.conf;
# vod settings # vod settings

View File

@@ -1,3 +1,6 @@
# Header used to validate reverse proxy trust
proxy_set_header X-Proxy-Secret $http_x_proxy_secret;
# these headers will be copied to the /auth request and are available # these headers will be copied to the /auth request and are available
# to be mapped in the config to Frigate's remote-user header # to be mapped in the config to Frigate's remote-user header
@@ -19,4 +22,4 @@ proxy_set_header X-authentik-username $http_x_authentik_username;
proxy_set_header X-authentik-groups $http_x_authentik_groups; proxy_set_header X-authentik-groups $http_x_authentik_groups;
proxy_set_header X-authentik-email $http_x_authentik_email; proxy_set_header X-authentik-email $http_x_authentik_email;
proxy_set_header X-authentik-name $http_x_authentik_name; proxy_set_header X-authentik-name $http_x_authentik_name;
proxy_set_header X-authentik-uid $http_x_authentik_uid; proxy_set_header X-authentik-uid $http_x_authentik_uid;

View File

@@ -23,6 +23,6 @@ try:
except FileNotFoundError: except FileNotFoundError:
config: dict[str, any] = {} config: dict[str, any] = {}
tls_config: dict[str, any] = config.get("tls", {}) tls_config: dict[str, any] = config.get("tls", {"enabled": True})
print(json.dumps(tls_config)) print(json.dumps(tls_config))

View File

@@ -1,9 +1,12 @@
# intended for internal traffic, not protected by auth
listen 5000;
{{ if not .enabled }} {{ if not .enabled }}
# intended for external traffic, protected by auth # intended for external traffic, protected by auth
listen [::]:8080 ipv6only=off; listen 8971;
{{ else }} {{ else }}
# intended for external traffic, protected by auth # intended for external traffic, protected by auth
listen [::]:8080 ipv6only=off ssl; listen 8971 ssl;
ssl_certificate /etc/letsencrypt/live/frigate/fullchain.pem; ssl_certificate /etc/letsencrypt/live/frigate/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/frigate/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/frigate/privkey.pem;

View File

@@ -106,7 +106,53 @@ Some labels have special handling and modifications can disable functionality.
::: :::
## Custom ffmpeg build ## Network Configuration
Changes to Frigate's internal network configuration can be made by bind mounting nginx.conf into the container. For example:
```yaml
services:
frigate:
container_name: frigate
...
volumes:
...
- /path/to/your/nginx.conf:/usr/local/nginx/conf/nginx.conf
```
### Enabling IPv6
IPv6 is disabled by default, to enable IPv6 listen.gotmpl needs to be bind mounted with IPv6 enabled. For example:
```
{{ if not .enabled }}
# intended for external traffic, protected by auth
listen 8971;
{{ else }}
# intended for external traffic, protected by auth
listen 8971 ssl;
# intended for internal traffic, not protected by auth
listen 5000;
```
becomes
```
{{ if not .enabled }}
# intended for external traffic, protected by auth
listen [::]:8971 ipv6only=off;
{{ else }}
# intended for external traffic, protected by auth
listen [::]:8971 ipv6only=off ssl;
# intended for internal traffic, not protected by auth
listen [::]:5000 ipv6only=off;
```
## Custom Dependencies
### Custom ffmpeg build
Included with Frigate is a build of ffmpeg that works for the vast majority of users. However, there exists some hardware setups which have incompatibilities with the included build. In this case, a docker volume mapping can be used to overwrite the included ffmpeg build with an ffmpeg build that works for your specific hardware setup. Included with Frigate is a build of ffmpeg that works for the vast majority of users. However, there exists some hardware setups which have incompatibilities with the included build. In this case, a docker volume mapping can be used to overwrite the included ffmpeg build with an ffmpeg build that works for your specific hardware setup.
@@ -118,9 +164,9 @@ To do this:
NOTE: The folder that is mapped from the host needs to be the folder that contains `/bin`. So if the full structure is `/home/appdata/frigate/custom-ffmpeg/bin/ffmpeg` then `/home/appdata/frigate/custom-ffmpeg` needs to be mapped to `/usr/lib/btbn-ffmpeg`. NOTE: The folder that is mapped from the host needs to be the folder that contains `/bin`. So if the full structure is `/home/appdata/frigate/custom-ffmpeg/bin/ffmpeg` then `/home/appdata/frigate/custom-ffmpeg` needs to be mapped to `/usr/lib/btbn-ffmpeg`.
## Custom go2rtc version ### Custom go2rtc version
Frigate currently includes go2rtc v1.9.2, there may be certain cases where you want to run a different version of go2rtc. Frigate currently includes go2rtc v1.9.4, there may be certain cases where you want to run a different version of go2rtc.
To do this: To do this:

View File

@@ -13,7 +13,7 @@ The following ports are available to access the Frigate web UI.
| Port | Description | | Port | Description |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `8080` | Authenticated UI and API. Reverse proxies should use this port. | | `8971` | 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. | | `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 ## Onboarding

View File

@@ -175,7 +175,7 @@ go2rtc:
- rtspx://192.168.1.1:7441/abcdefghijk - rtspx://192.168.1.1:7441/abcdefghijk
``` ```
[See the go2rtc docs for more information](https://github.com/AlexxIT/go2rtc/tree/v1.9.2#source-rtsp) [See the go2rtc docs for more information](https://github.com/AlexxIT/go2rtc/tree/v1.9.4#source-rtsp)
In the Unifi 2.0 update Unifi Protect Cameras had a change in audio sample rate which causes issues for ffmpeg. The input rate needs to be set for record if used directly with unifi protect. In the Unifi 2.0 update Unifi Protect Cameras had a change in audio sample rate which causes issues for ffmpeg. The input rate needs to be set for record if used directly with unifi protect.

View File

@@ -7,13 +7,15 @@ Frigate intelligently displays your camera streams on the Live view dashboard. Y
## Live View technologies ## Live View technologies
Frigate intelligently uses three different streaming technologies to display your camera streams. The highest quality and fluency of the Live view requires the bundled `go2rtc` to be configured as shown in the [step by step guide](/guides/configuring_go2rtc). Frigate intelligently uses three different streaming technologies to display your camera streams on the dashboard and the single camera view, switching between available modes based on network bandwidth, player errors, or required features like two-way talk. The highest quality and fluency of the Live view requires the bundled `go2rtc` to be configured as shown in the [step by step guide](/guides/configuring_go2rtc).
| Source | Latency | Frame Rate | Resolution | Audio | Requires go2rtc | Other Limitations | The jsmpeg live view will use more browser and client GPU resources. Using go2rtc is highly recommended and will provide a superior experience.
| ------ | ------- | ------------------------------------- | -------------- | ---------------------------- | --------------- | ------------------------------------------------ |
| jsmpeg | low | same as `detect -> fps`, capped at 10 | same as detect | no | no | none | | Source | Latency | Frame Rate | Resolution | Audio | Requires go2rtc | Other Limitations |
| mse | low | native | native | yes (depends on audio codec) | yes | iPhone requires iOS 17.1+, Firefox is h.264 only | | ------ | ------- | ------------------------------------- | ---------- | ---------------------------- | --------------- | ------------------------------------------------------------------------------------ |
| webrtc | lowest | native | native | yes (depends on audio codec) | yes | requires extra config, doesn't support h.265 | | jsmpeg | low | same as `detect -> fps`, capped at 10 | 720p | no | no | resolution is configurable, but go2rtc is recommended if you want higher resolutions |
| mse | low | native | native | yes (depends on audio codec) | yes | iPhone requires iOS 17.1+, Firefox is h.264 only |
| webrtc | lowest | native | native | yes (depends on audio codec) | yes | requires extra config, doesn't support h.265 |
### Audio Support ### Audio Support

View File

@@ -159,11 +159,14 @@ Using Frigate UI, HomeAssistant, or MQTT, cameras can be automated to only recor
## How do I export recordings? ## How do I export recordings?
The export page in the Frigate WebUI allows for exporting real time clips with a designated start and stop time as well as exporting a time-lapse for a designated start and stop time. These exports can take a while so it is important to leave the file until it is no longer in progress. Footage can be exported from Frigate by right-clicking (desktop) or long pressing (mobile) on a review item in the Review pane or by clicking the Export button in the History view. Exported footage is then organized and searchable through the Export view, accessible from the main navigation bar.
### Time-lapse export ### Time-lapse export
Time lapse exporting is available only via the [HTTP API](../integrations/api.md#post-apiexportcamerastartstart-timestampendend-timestamp).
When exporting a time-lapse the default speed-up is 25x with 30 FPS. This means that every 25 seconds of (real-time) recording is condensed into 1 second of time-lapse video (always without audio) with a smoothness of 30 FPS. When exporting a time-lapse the default speed-up is 25x with 30 FPS. This means that every 25 seconds of (real-time) recording is condensed into 1 second of time-lapse video (always without audio) with a smoothness of 30 FPS.
To configure the speed-up factor, the frame rate and further custom settings, the configuration parameter `timelapse_args` can be used. The below configuration example would change the time-lapse speed to 60x (for fitting 1 hour of recording into 1 minute of time-lapse) with 25 FPS: To configure the speed-up factor, the frame rate and further custom settings, the configuration parameter `timelapse_args` can be used. The below configuration example would change the time-lapse speed to 60x (for fitting 1 hour of recording into 1 minute of time-lapse) with 25 FPS:
```yaml ```yaml

View File

@@ -65,7 +65,7 @@ database:
# Optional: TLS configuration # Optional: TLS configuration
tls: tls:
# Optional: Enable TLS for port 8080 (default: shown below) # Optional: Enable TLS for port 8971 (default: shown below)
enabled: True enabled: True
# Optional: Proxy configuration # Optional: Proxy configuration
@@ -613,6 +613,9 @@ cameras:
user: admin user: admin
# Optional: password for login. # Optional: password for login.
password: admin password: admin
# Optional: Ignores time synchronization mismatches between the camera and the server during authentication.
# Using NTP on both ends is recommended and this should only be set to True in a "safe" environment due to the security risk it represents.
ignore_time_mismatch: False
# Optional: PTZ camera object autotracking. Keeps a moving object in # Optional: PTZ camera object autotracking. Keeps a moving object in
# the center of the frame by automatically moving the PTZ camera. # the center of the frame by automatically moving the PTZ camera.
autotracking: autotracking:

View File

@@ -7,7 +7,7 @@ title: Restream
Frigate can restream your video feed as an RTSP feed for other applications such as Home Assistant to utilize it at `rtsp://<frigate_host>:8554/<camera_name>`. Port 8554 must be open. [This allows you to use a video feed for detection in Frigate and Home Assistant live view at the same time without having to make two separate connections to the camera](#reduce-connections-to-camera). The video feed is copied from the original video feed directly to avoid re-encoding. This feed does not include any annotation by Frigate. Frigate can restream your video feed as an RTSP feed for other applications such as Home Assistant to utilize it at `rtsp://<frigate_host>:8554/<camera_name>`. Port 8554 must be open. [This allows you to use a video feed for detection in Frigate and Home Assistant live view at the same time without having to make two separate connections to the camera](#reduce-connections-to-camera). The video feed is copied from the original video feed directly to avoid re-encoding. This feed does not include any annotation by Frigate.
Frigate uses [go2rtc](https://github.com/AlexxIT/go2rtc/tree/v1.9.2) to provide its restream and MSE/WebRTC capabilities. The go2rtc config is hosted at the `go2rtc` in the config, see [go2rtc docs](https://github.com/AlexxIT/go2rtc/tree/v1.9.2#configuration) for more advanced configurations and features. Frigate uses [go2rtc](https://github.com/AlexxIT/go2rtc/tree/v1.9.4) to provide its restream and MSE/WebRTC capabilities. The go2rtc config is hosted at the `go2rtc` in the config, see [go2rtc docs](https://github.com/AlexxIT/go2rtc/tree/v1.9.4#configuration) for more advanced configurations and features.
:::note :::note
@@ -134,7 +134,7 @@ cameras:
## Advanced Restream Configurations ## Advanced Restream Configurations
The [exec](https://github.com/AlexxIT/go2rtc/tree/v1.9.2#source-exec) source in go2rtc can be used for custom ffmpeg commands. An example is below: The [exec](https://github.com/AlexxIT/go2rtc/tree/v1.9.4#source-exec) source in go2rtc can be used for custom ffmpeg commands. An example is below:
NOTE: The output will need to be passed with two curly braces `{{output}}` NOTE: The output will need to be passed with two curly braces `{{output}}`

View File

@@ -62,6 +62,6 @@ By default a review item will be created if any `review -> alerts -> labels` and
:::info :::info
Because zones don't apply to audio, audio labels will always be marked as an alert. Because zones don't apply to audio, audio labels will always be marked as a detection by default.
::: :::

View File

@@ -5,7 +5,7 @@ title: TLS
# 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's integrated NGINX server supports TLS certificates. By default Frigate will generate a self signed certificate that will be used for port 8971. 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. 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.
@@ -24,21 +24,33 @@ TLS certificates can be mounted at `/etc/letsencrypt/live/frigate` using a bind
frigate: frigate:
... ...
volumes: volumes:
- /path/to/your/certificate_folder:/etc/letsencrypt/live/frigate - /path/to/your/certificate_folder:/etc/letsencrypt/live/frigate:ro
... ...
``` ```
Within the folder, the private key is expected to be named `privkey.pem` and the certificate is expected to be named `fullchain.pem`. Within the folder, the private key is expected to be named `privkey.pem` and the certificate is expected to be named `fullchain.pem`.
Note that certbot uses symlinks, and those can't be followed by the container unless it has access to the targets as well, so if using certbot you'll also have to mount the `archive` folder for your domain, e.g.:
```yaml
frigate:
...
volumes:
- /etc/letsencrypt/live/frigate:/etc/letsencrypt/live/frigate:ro
- /etc/letsencrypt/archive/frigate:/etc/letsencrypt/archive/frigate:ro
...
```
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. 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. 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 8971 to 443.
```yaml ```yaml
frigate: frigate:
... ...
ports: ports:
- "443:8080" - "443:8971"
... ...
``` ```

View File

@@ -69,15 +69,6 @@ Sometimes you want to limit a zone to specific object types to have more granula
```yaml ```yaml
cameras: cameras:
name_of_your_camera: name_of_your_camera:
record:
events:
required_zones:
- entire_yard
- front_yard_street
snapshots:
required_zones:
- entire_yard
- front_yard_street
zones: zones:
entire_yard: entire_yard:
coordinates: ... (everywhere you want a person) coordinates: ... (everywhere you want a person)

View File

@@ -9,6 +9,13 @@ The glossary explains terms commonly used in Frigate's documentation.
A box returned from the object detection model that outlines an object in the frame. These have multiple colors depending on object type in the debug live view. A box returned from the object detection model that outlines an object in the frame. These have multiple colors depending on object type in the debug live view.
### Bounding Box Colors
- At startup different colors will be assigned to each object label
- A dark blue thin line indicates that object is not detected at this current point in time
- A gray thin line indicates that object is detected as being stationary
- A thick line indicates that object is the subject of autotracking (when enabled).
## Event ## Event
The time period starting when a tracked object entered the frame and ending when it left the frame, including any time that the object remained still. Events are saved when it is considered a [true positive](#threshold) and meets the requirements for a snapshot or recording to be saved. The time period starting when a tracked object entered the frame and ending when it left the frame, including any time that the object remained still. Events are saved when it is considered a [true positive](#threshold) and meets the requirements for a snapshot or recording to be saved.

View File

@@ -34,7 +34,7 @@ The following ports are used by Frigate and can be mapped via docker as required
| Port | Description | | Port | Description |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `8080` | Authenticated UI and API access without TLS. Reverse proxies should use this port. | | `8971` | 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. | | `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. | | `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. | | `8555` | WebRTC connections for low latency live views. |
@@ -171,7 +171,7 @@ services:
tmpfs: tmpfs:
size: 1000000000 size: 1000000000
ports: ports:
- "8080:8080" - "8971:8971"
# - "5000:5000" # Internal unauthenticated access. Expose carefully. # - "5000:5000" # Internal unauthenticated access. Expose carefully.
- "8554:8554" # RTSP feeds - "8554:8554" # RTSP feeds
- "8555:8555/tcp" # WebRTC over tcp - "8555:8555/tcp" # WebRTC over tcp
@@ -194,7 +194,7 @@ docker run -d \
-v /path/to/your/config:/config \ -v /path/to/your/config:/config \
-v /etc/localtime:/etc/localtime:ro \ -v /etc/localtime:/etc/localtime:ro \
-e FRIGATE_RTSP_PASSWORD='password' \ -e FRIGATE_RTSP_PASSWORD='password' \
-p 8080:8080 \ -p 8971:8971 \
-p 8554:8554 \ -p 8554:8554 \
-p 8555:8555/tcp \ -p 8555:8555/tcp \
-p 8555:8555/udp \ -p 8555:8555/udp \
@@ -370,7 +370,7 @@ docker run \
--network=bridge \ --network=bridge \
--privileged \ --privileged \
--workdir=/opt/frigate \ --workdir=/opt/frigate \
-p 8080:8080 \ -p 8971:8971 \
-p 8554:8554 \ -p 8554:8554 \
-p 8555:8555 \ -p 8555:8555 \
-p 8555:8555/udp \ -p 8555:8555/udp \

View File

@@ -13,7 +13,7 @@ Use of the bundled go2rtc is optional. You can still configure FFmpeg to connect
# Setup a go2rtc stream # Setup a go2rtc stream
First, you will want to configure go2rtc to connect to your camera stream by adding the stream you want to use for live view in your Frigate config file. If you set the stream name under go2rtc to match the name of your camera, it will automatically be mapped and you will get additional live view options for the camera. Avoid changing any other parts of your config at this step. Note that go2rtc supports [many different stream types](https://github.com/AlexxIT/go2rtc/tree/v1.9.2#module-streams), not just rtsp. First, you will want to configure go2rtc to connect to your camera stream by adding the stream you want to use for live view in your Frigate config file. If you set the stream name under go2rtc to match the name of your camera, it will automatically be mapped and you will get additional live view options for the camera. Avoid changing any other parts of your config at this step. Note that go2rtc supports [many different stream types](https://github.com/AlexxIT/go2rtc/tree/v1.9.4#module-streams), not just rtsp.
```yaml ```yaml
go2rtc: go2rtc:
@@ -24,59 +24,78 @@ go2rtc:
The easiest live view to get working is MSE. After adding this to the config, restart Frigate and try to watch the live stream by selecting MSE in the dropdown after clicking on the camera. The easiest live view to get working is MSE. After adding this to the config, restart Frigate and try to watch the live stream by selecting MSE in the dropdown after clicking on the camera.
### What if my video doesn't play? ### What if my video doesn't play?
If you are unable to see your video feed, first check the go2rtc logs in the Frigate UI under Logs in the sidebar. If go2rtc is having difficulty connecting to your camera, you should see some error messages in the log. If you do not see any errors, then the video codec of the stream may not be supported in your browser. If your camera stream is set to H265, try switching to H264. You can see more information about [video codec compatibility](https://github.com/AlexxIT/go2rtc/tree/v1.9.2#codecs-madness) in the go2rtc documentation. If you are not able to switch your camera settings from H265 to H264 or your stream is a different format such as MJPEG, you can use go2rtc to re-encode the video using the [FFmpeg parameters](https://github.com/AlexxIT/go2rtc/tree/v1.9.2#source-ffmpeg). It supports rotating and resizing video feeds and hardware acceleration. Keep in mind that transcoding video from one format to another is a resource intensive task and you may be better off using the built-in jsmpeg view. Here is an example of a config that will re-encode the stream to H264 without hardware acceleration: - Check Logs:
- Access the go2rtc logs in the Frigate UI under Logs in the sidebar.
- If go2rtc is having difficulty connecting to your camera, you should see some error messages in the log.
```yaml - Check go2rtc Web Interface: if you don't see any errors in the logs, try viewing the camera through go2rtc's web interface.
go2rtc: - Navigate to port 1984 in your browser to access go2rtc's web interface.
streams: - If using Frigate through Home Assistant, enable the web interface at port 1984.
back: - If using Docker, forward port 1984 before accessing the web interface.
- rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2 - Click `stream` for the specific camera to see if the camera's stream is being received.
- "ffmpeg:back#video=h264"
```
Some camera streams may need to use the ffmpeg module in go2rtc. This has the downside of slower startup times, but has compatibility with more stream types. - Check Video Codec:
- If the camera stream works in go2rtc but not in your browser, the video codec might be unsupported.
- If using H265, switch to H264. Refer to [video codec compatibility](https://github.com/AlexxIT/go2rtc/tree/v1.9.4#codecs-madness) in go2rtc documentation.
- If unable to switch from H265 to H264, or if the stream format is different (e.g., MJPEG), re-encode the video using [FFmpeg parameters](https://github.com/AlexxIT/go2rtc/tree/v1.9.4#source-ffmpeg). It supports rotating and resizing video feeds and hardware acceleration. Keep in mind that transcoding video from one format to another is a resource intensive task and you may be better off using the built-in jsmpeg view.
```yaml
go2rtc:
streams:
back:
- rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
- "ffmpeg:back#video=h264"
```
```yaml - Switch to FFmpeg if needed:
go2rtc: - Some camera streams may need to use the ffmpeg module in go2rtc. This has the downside of slower startup times, but has compatibility with more stream types.
streams: ```yaml
back: go2rtc:
- ffmpeg:rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2 streams:
``` back:
- ffmpeg:rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
```
If you can see the video but do not have audio, this is most likely because your camera's audio stream is not AAC. If possible, update your camera's audio settings to AAC. If your cameras do not support AAC audio, you will need to tell go2rtc to re-encode the audio to AAC on demand if you want audio. This will use additional CPU and add some latency. To add AAC audio on demand, you can update your go2rtc config as follows: - If you can see the video but do not have audio, this is most likely because your
camera's audio stream is not AAC.
- If possible, update your camera's audio settings to AAC.
- If your cameras do not support AAC audio, you will need to tell go2rtc to re-encode the audio to AAC on demand if you want audio. This will use additional CPU and add some latency. To add AAC audio on demand, you can update your go2rtc config as follows:
```yaml
go2rtc:
streams:
back:
- rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
- "ffmpeg:back#audio=aac"
```
```yaml If you need to convert **both** the audio and video streams, you can use the following:
go2rtc:
streams:
back:
- rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
- "ffmpeg:back#audio=aac"
```
If you need to convert **both** the audio and video streams, you can use the following: ```yaml
go2rtc:
streams:
back:
- rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
- "ffmpeg:back#video=h264#audio=aac"
```
```yaml When using the ffmpeg module, you would add AAC audio like this:
go2rtc:
streams:
back:
- rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
- "ffmpeg:back#video=h264#audio=aac"
```
When using the ffmpeg module, you would add AAC audio like this: ```yaml
go2rtc:
```yaml streams:
go2rtc: back:
streams: - "ffmpeg:rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2#video=copy#audio=copy#audio=aac"
back: ```
- "ffmpeg:rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2#video=copy#audio=copy#audio=aac"
```
:::warning :::warning
To access the go2rtc stream externally when utilizing the Frigate Add-On (for instance through VLC), you must first enable the RTSP Restream port. You can do this by visiting the Frigate Add-On configuration page within Home Assistant and revealing the hidden options under the "Show disabled ports" section. To access the go2rtc stream externally when utilizing the Frigate Add-On (for
instance through VLC), you must first enable the RTSP Restream port.
You can do this by visiting the Frigate Add-On configuration page within Home
Assistant and revealing the hidden options under the "Show disabled ports"
section.
::: :::

View File

@@ -117,7 +117,7 @@ services:
tmpfs: tmpfs:
size: 1000000000 size: 1000000000
ports: ports:
- "8080:8080" - "8971:8971"
- "8554:8554" # RTSP feeds - "8554:8554" # RTSP feeds
``` ```
@@ -137,7 +137,7 @@ cameras:
- detect - 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 `https://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:8971` where you can login with the `admin` user and finish the configuration using the built-in configuration editor.
## Configuring Frigate ## Configuring Frigate

View File

@@ -38,20 +38,20 @@ Here we access Frigate via https://cctv.mydomain.co.uk
ServerName cctv.mydomain.co.uk ServerName cctv.mydomain.co.uk
ProxyPreserveHost On ProxyPreserveHost On
ProxyPass "/" "http://frigatepi.local:8080/" ProxyPass "/" "http://frigatepi.local:8971/"
ProxyPassReverse "/" "http://frigatepi.local:8080/" ProxyPassReverse "/" "http://frigatepi.local:8971/"
ProxyPass /ws ws://frigatepi.local:8080/ws ProxyPass /ws ws://frigatepi.local:8971/ws
ProxyPassReverse /ws ws://frigatepi.local:8080/ws ProxyPassReverse /ws ws://frigatepi.local:8971/ws
ProxyPass /live/ ws://frigatepi.local:8080/live/ ProxyPass /live/ ws://frigatepi.local:8971/live/
ProxyPassReverse /live/ ws://frigatepi.local:8080/live/ ProxyPassReverse /live/ ws://frigatepi.local:8971/live/
RewriteEngine on RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC] RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://frigatepi.local:8080/$1 [P,L] RewriteRule /(.*) ws://frigatepi.local:8971/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC] RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://frigatepi.local:8080/$1 [P,L] RewriteRule /(.*) http://frigatepi.local:8971/$1 [P,L]
</VirtualHost> </VirtualHost>
``` ```
@@ -101,7 +101,7 @@ This is set in `$server` and `$port` this should match your ports you have expos
server { server {
set $forward_scheme http; set $forward_scheme http;
set $server "192.168.100.2"; # FRIGATE SERVER LOCATION set $server "192.168.100.2"; # FRIGATE SERVER LOCATION
set $port 8080; set $port 8971;
listen 80; listen 80;
listen 443 ssl http2; listen 443 ssl http2;

View File

@@ -92,6 +92,61 @@ Message published for each changed event. The first message is published when th
} }
``` ```
### `frigate/reviews`
Message published for each changed review item. The first message is published when the `detection` or `alert` is initiated. When additional objects are detected or when a zone change occurs, it will publish a, `update` message with the same id. When the review activity has ended a final `end` message is published.
```json
{
"type": "update", // new, update, end
"before": {
"id": "1718987129.308396-fqk5ka", // review_id
"camera": "front_cam",
"start_time": 1718987129.308396,
"end_time": null,
"severity": "detection",
"thumb_path": "/media/frigate/clips/review/thumb-front_cam-1718987129.308396-fqk5ka.webp",
"data": {
"detections": [ // list of event IDs
"1718987128.947436-g92ztx",
"1718987148.879516-d7oq7r",
"1718987126.934663-q5ywpt"
],
"objects": [
"person",
"car"
],
"sub_labels": [],
"zones": [],
"audio": []
}
},
"after": {
"id": "1718987129.308396-fqk5ka",
"camera": "front_cam",
"start_time": 1718987129.308396,
"end_time": null,
"severity": "alert",
"thumb_path": "/media/frigate/clips/review/thumb-front_cam-1718987129.308396-fqk5ka.webp",
"data": {
"detections": [
"1718987128.947436-g92ztx",
"1718987148.879516-d7oq7r",
"1718987126.934663-q5ywpt"
],
"objects": [
"person",
"car"
],
"sub_labels": [],
"zones": [
"front_yard"
],
"audio": []
}
}
```
### `frigate/stats` ### `frigate/stats`
Same data available at `/api/stats` published at a configurable interval. Same data available at `/api/stats` published at a configurable interval.

View File

@@ -57,3 +57,9 @@ SQLite does not work well on a network share, if the `/media` folder is mapped t
If MQTT isn't working in docker try using the IP of the device hosting the MQTT server instead of `localhost`, `127.0.0.1`, or `mosquitto.ix-mosquitto.svc.cluster.local`. If MQTT isn't working in docker try using the IP of the device hosting the MQTT server instead of `localhost`, `127.0.0.1`, or `mosquitto.ix-mosquitto.svc.cluster.local`.
This is because, by default, Frigate does not run in host mode so localhost points to the Frigate container and not the host device's network. This is because, by default, Frigate does not run in host mode so localhost points to the Frigate container and not the host device's network.
### How do I know if my camera is offline
A camera being offline can be detected via MQTT or /api/stats, the camera_fps for any offline camera will be 0.
Also, Home Assistant will mark any offline camera as being unavailable when the camera is offline

View File

@@ -22,7 +22,7 @@ module.exports = {
{ {
type: "link", type: "link",
label: "Go2RTC Configuration Reference", label: "Go2RTC Configuration Reference",
href: "https://github.com/AlexxIT/go2rtc/tree/v1.9.2#configuration", href: "https://github.com/AlexxIT/go2rtc/tree/v1.9.4#configuration",
}, },
], ],
Detectors: [ Detectors: [

View File

@@ -484,6 +484,10 @@ def logs(service: str):
if len(cleanLine) < 10: if len(cleanLine) < 10:
continue continue
# handle cases where S6 does not include date in log line
if " " not in cleanLine:
cleanLine = f"{datetime.now()} {cleanLine}"
if dateEnd == 0: if dateEnd == 0:
dateEnd = cleanLine.index(" ") dateEnd = cleanLine.index(" ")
keyLength = dateEnd - (6 if service_location == "frigate" else 0) keyLength = dateEnd - (6 if service_location == "frigate" else 0)

View File

@@ -89,7 +89,9 @@ def get_jwt_secret() -> str:
# check docker secrets # check docker secrets
elif os.path.isfile(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)): 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.") 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() jwt_secret = (
Path(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)).read_text().strip()
)
# check for the addon options file # check for the addon options file
elif os.path.isfile("/data/options.json"): elif os.path.isfile("/data/options.json"):
with open("/data/options.json") as f: with open("/data/options.json") as f:
@@ -193,7 +195,7 @@ def auth():
# or use anonymous if none are specified # or use anonymous if none are specified
if proxy_config.header_map.user is not None: if proxy_config.header_map.user is not None:
upstream_user_header_value = request.headers.get( upstream_user_header_value = request.headers.get(
current_app.frigate_config.auth.header_map.user, proxy_config.header_map.user,
type=str, type=str,
default="anonymous", default="anonymous",
) )

View File

@@ -105,6 +105,7 @@ def latest_frame(camera_name):
"regions": request.args.get("regions", type=int), "regions": request.args.get("regions", type=int),
} }
resize_quality = request.args.get("quality", default=70, type=int) resize_quality = request.args.get("quality", default=70, type=int)
extension = os.path.splitext(request.path)[1][1:]
if camera_name in current_app.frigate_config.cameras: if camera_name in current_app.frigate_config.cameras:
frame = current_app.detected_frames_processor.get_current_frame( frame = current_app.detected_frames_processor.get_current_frame(
@@ -147,10 +148,10 @@ def latest_frame(camera_name):
frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA) frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA)
ret, img = cv2.imencode( ret, img = cv2.imencode(
".webp", frame, [int(cv2.IMWRITE_WEBP_QUALITY), resize_quality] f".{extension}", frame, [int(cv2.IMWRITE_WEBP_QUALITY), resize_quality]
) )
response = make_response(img.tobytes()) response = make_response(img.tobytes())
response.headers["Content-Type"] = "image/webp" response.headers["Content-Type"] = f"image/{extension}"
response.headers["Cache-Control"] = "no-store" response.headers["Cache-Control"] = "no-store"
return response return response
elif camera_name == "birdseye" and current_app.frigate_config.birdseye.restream: elif camera_name == "birdseye" and current_app.frigate_config.birdseye.restream:
@@ -165,10 +166,10 @@ def latest_frame(camera_name):
frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA) frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA)
ret, img = cv2.imencode( ret, img = cv2.imencode(
".webp", frame, [int(cv2.IMWRITE_WEBP_QUALITY), resize_quality] f".{extension}", frame, [int(cv2.IMWRITE_WEBP_QUALITY), resize_quality]
) )
response = make_response(img.tobytes()) response = make_response(img.tobytes())
response.headers["Content-Type"] = "image/webp" response.headers["Content-Type"] = f"image/{extension}"
response.headers["Cache-Control"] = "no-store" response.headers["Cache-Control"] = "no-store"
return response return response
else: else:
@@ -636,7 +637,7 @@ def vod_event(id):
# If the recordings are not found and the event started more than 5 minutes ago, set has_clip to false # If the recordings are not found and the event started more than 5 minutes ago, set has_clip to false
if ( if (
event.start_time < datetime.now().timestamp() - 300 event.start_time < datetime.now().timestamp() - 300
and type(vod_response) == tuple and type(vod_response) is tuple
and len(vod_response) == 2 and len(vod_response) == 2
and vod_response[1] == 404 and vod_response[1] == 404
): ):

View File

@@ -7,7 +7,6 @@ from enum import Enum
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Any, Dict, List, Optional, Tuple, Union
import matplotlib.pyplot as plt
import numpy as np import numpy as np
from pydantic import ( from pydantic import (
BaseModel, BaseModel,
@@ -26,6 +25,7 @@ from frigate.const import (
CACHE_DIR, CACHE_DIR,
CACHE_SEGMENT_FORMAT, CACHE_SEGMENT_FORMAT,
DEFAULT_DB_PATH, DEFAULT_DB_PATH,
FREQUENCY_STATS_POINTS,
MAX_PRE_CAPTURE, MAX_PRE_CAPTURE,
REGEX_CAMERA_NAME, REGEX_CAMERA_NAME,
YAML_EXT, YAML_EXT,
@@ -42,6 +42,7 @@ from frigate.plus import PlusApi
from frigate.util.builtin import ( from frigate.util.builtin import (
deep_merge, deep_merge,
escape_special_characters, escape_special_characters,
generate_color_palette,
get_ffmpeg_arg_list, get_ffmpeg_arg_list,
load_config_with_no_duplicates, load_config_with_no_duplicates,
) )
@@ -61,9 +62,9 @@ FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE
if os.path.isdir("/run/secrets") and os.access("/run/secrets", os.R_OK): if os.path.isdir("/run/secrets") and os.access("/run/secrets", os.R_OK):
for secret_file in os.listdir("/run/secrets"): for secret_file in os.listdir("/run/secrets"):
if secret_file.startswith("FRIGATE_"): if secret_file.startswith("FRIGATE_"):
FRIGATE_ENV_VARS[secret_file] = Path( FRIGATE_ENV_VARS[secret_file] = (
os.path.join("/run/secrets", secret_file) Path(os.path.join("/run/secrets", secret_file)).read_text().strip()
).read_text() )
DEFAULT_TRACKED_OBJECTS = ["person"] DEFAULT_TRACKED_OBJECTS = ["person"]
DEFAULT_ALERT_OBJECTS = ["person", "car"] DEFAULT_ALERT_OBJECTS = ["person", "car"]
@@ -116,7 +117,7 @@ class UIConfig(FrigateBaseModel):
class TlsConfig(FrigateBaseModel): class TlsConfig(FrigateBaseModel):
enabled: bool = Field(default=True, title="Enable TLS for port 8080") enabled: bool = Field(default=True, title="Enable TLS for port 8971")
class HeaderMappingConfig(FrigateBaseModel): class HeaderMappingConfig(FrigateBaseModel):
@@ -193,7 +194,9 @@ class MqttConfig(FrigateBaseModel):
port: int = Field(default=1883, title="MQTT Port") port: int = Field(default=1883, title="MQTT Port")
topic_prefix: str = Field(default="frigate", title="MQTT Topic Prefix") topic_prefix: str = Field(default="frigate", title="MQTT Topic Prefix")
client_id: str = Field(default="frigate", title="MQTT Client ID") client_id: str = Field(default="frigate", title="MQTT Client ID")
stats_interval: int = Field(default=60, title="MQTT Camera Stats Interval") stats_interval: int = Field(
default=60, ge=FREQUENCY_STATS_POINTS, title="MQTT Camera Stats Interval"
)
user: Optional[str] = Field(None, title="MQTT Username") user: Optional[str] = Field(None, title="MQTT Username")
password: Optional[str] = Field(None, title="MQTT Password", validate_default=True) password: Optional[str] = Field(None, title="MQTT Password", validate_default=True)
tls_ca_certs: Optional[str] = Field(None, title="MQTT TLS CA Certificates") tls_ca_certs: Optional[str] = Field(None, title="MQTT TLS CA Certificates")
@@ -276,6 +279,10 @@ class OnvifConfig(FrigateBaseModel):
default_factory=PtzAutotrackConfig, default_factory=PtzAutotrackConfig,
title="PTZ auto tracking config.", title="PTZ auto tracking config.",
) )
ignore_time_mismatch: bool = Field(
default=False,
title="Onvif Ignore Time Synchronization Mismatch Between Camera and Server",
)
class RetainModeEnum(str, Enum): class RetainModeEnum(str, Enum):
@@ -1030,10 +1037,11 @@ class CameraConfig(FrigateBaseModel):
def __init__(self, **config): def __init__(self, **config):
# Set zone colors # Set zone colors
if "zones" in config: if "zones" in config:
colors = plt.cm.get_cmap("tab10", len(config["zones"])) colors = generate_color_palette(len(config["zones"]))
config["zones"] = { config["zones"] = {
name: {**z, "color": tuple(round(255 * c) for c in colors(idx)[:3])} name: {**z, "color": color}
for idx, (name, z) in enumerate(config["zones"].items()) for (name, z), color in zip(config["zones"].items(), colors)
} }
# add roles to the input if there is only one # add roles to the input if there is only one

View File

@@ -82,6 +82,10 @@ UPSERT_REVIEW_SEGMENT = "upsert_review_segment"
CLEAR_ONGOING_REVIEW_SEGMENTS = "clear_ongoing_review_segments" CLEAR_ONGOING_REVIEW_SEGMENTS = "clear_ongoing_review_segments"
UPDATE_CAMERA_ACTIVITY = "update_camera_activity" UPDATE_CAMERA_ACTIVITY = "update_camera_activity"
# Stats Values
FREQUENCY_STATS_POINTS = 15
# Autotracking # Autotracking
AUTOTRACKING_MAX_AREA_RATIO = 0.6 AUTOTRACKING_MAX_AREA_RATIO = 0.6

View File

@@ -5,13 +5,12 @@ import os
from enum import Enum from enum import Enum
from typing import Dict, Optional, Tuple from typing import Dict, Optional, Tuple
import matplotlib.pyplot as plt
import requests import requests
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from pydantic.fields import PrivateAttr from pydantic.fields import PrivateAttr
from frigate.plus import PlusApi from frigate.plus import PlusApi
from frigate.util.builtin import load_labels from frigate.util.builtin import generate_color_palette, load_labels
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -128,10 +127,9 @@ class ModelConfig(BaseModel):
def create_colormap(self, enabled_labels: set[str]) -> None: def create_colormap(self, enabled_labels: set[str]) -> None:
"""Get a list of colors for enabled labels.""" """Get a list of colors for enabled labels."""
cmap = plt.cm.get_cmap("tab10", len(enabled_labels)) colors = generate_color_palette(len(enabled_labels))
for key, val in enumerate(enabled_labels): self._colormap = {label: color for label, color in zip(enabled_labels, colors)}
self._colormap[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])
model_config = ConfigDict(extra="forbid", protected_namespaces=()) model_config = ConfigDict(extra="forbid", protected_namespaces=())

View File

@@ -1,4 +1,5 @@
import logging import logging
import os
import numpy as np import numpy as np
import openvino as ov import openvino as ov
@@ -35,6 +36,10 @@ class OvDetector(DetectionApi):
) )
detector_config.device = "GPU" detector_config.device = "GPU"
if not os.path.isfile(detector_config.model.path):
logger.error(f"OpenVino model file {detector_config.model.path} not found.")
raise FileNotFoundError
self.interpreter = self.ov_core.compile_model( self.interpreter = self.ov_core.compile_model(
model=detector_config.model.path, device_name=detector_config.device model=detector_config.model.path, device_name=detector_config.device
) )

View File

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

View File

@@ -174,10 +174,13 @@ def move_preview_frames(loc: str):
preview_holdover = os.path.join(CLIPS_DIR, "preview_restart_cache") preview_holdover = os.path.join(CLIPS_DIR, "preview_restart_cache")
preview_cache = os.path.join(CACHE_DIR, "preview_frames") preview_cache = os.path.join(CACHE_DIR, "preview_frames")
if loc == "clips": try:
shutil.move(preview_cache, preview_holdover) if loc == "clips":
elif loc == "cache": shutil.move(preview_cache, preview_holdover)
if not os.path.exists(preview_holdover): elif loc == "cache":
return if not os.path.exists(preview_holdover):
return
shutil.move(preview_holdover, preview_cache) shutil.move(preview_holdover, preview_cache)
except shutil.Error:
logger.error("Failed to restore preview cache.")

View File

@@ -219,13 +219,16 @@ class PreviewRecorder:
os.unlink(os.path.join(PREVIEW_CACHE_DIR, file)) os.unlink(os.path.join(PREVIEW_CACHE_DIR, file))
continue continue
file_time = file.split("-")[1][: -(len(PREVIEW_FRAME_TYPE) + 1)] try:
file_time = file.split("-")[-1][: -(len(PREVIEW_FRAME_TYPE) + 1)]
if not file_time: if not file_time:
continue
ts = float(file_time)
except ValueError:
continue continue
ts = float(file_time)
if self.start_time == 0: if self.start_time == 0:
self.start_time = ts self.start_time = ts

View File

@@ -42,7 +42,9 @@ class PlusApi:
and os.access("/run/secrets", os.R_OK) and os.access("/run/secrets", os.R_OK)
and PLUS_ENV_VAR in os.listdir("/run/secrets") and PLUS_ENV_VAR in os.listdir("/run/secrets")
): ):
self.key = Path(os.path.join("/run/secrets", PLUS_ENV_VAR)).read_text() self.key = (
Path(os.path.join("/run/secrets", PLUS_ENV_VAR)).read_text().strip()
)
# check for the addon options file # check for the addon options file
elif os.path.isfile("/data/options.json"): elif os.path.isfile("/data/options.json"):
with open("/data/options.json") as f: with open("/data/options.json") as f:

View File

@@ -54,6 +54,7 @@ class OnvifController:
wsdl_dir=str( wsdl_dir=str(
Path(find_spec("onvif").origin).parent / "wsdl" Path(find_spec("onvif").origin).parent / "wsdl"
).replace("dist-packages/onvif", "site-packages"), ).replace("dist-packages/onvif", "site-packages"),
adjust_time=cam.onvif.ignore_time_mismatch,
), ),
"init": False, "init": False,
"active": False, "active": False,
@@ -94,8 +95,12 @@ class OnvifController:
onvif_profile.VideoEncoderConfiguration onvif_profile.VideoEncoderConfiguration
and onvif_profile.VideoEncoderConfiguration.Encoding == "H264" and onvif_profile.VideoEncoderConfiguration.Encoding == "H264"
and onvif_profile.PTZConfiguration and onvif_profile.PTZConfiguration
and onvif_profile.PTZConfiguration.DefaultContinuousPanTiltVelocitySpace and (
is not None onvif_profile.PTZConfiguration.DefaultContinuousPanTiltVelocitySpace
is not None
or onvif_profile.PTZConfiguration.DefaultContinuousZoomVelocitySpace
is not None
)
): ):
profile = onvif_profile profile = onvif_profile
logger.debug(f"Selected Onvif profile for {camera_name}: {profile}") logger.debug(f"Selected Onvif profile for {camera_name}: {profile}")

View File

@@ -53,7 +53,7 @@ class PendingReviewSegment:
severity: SeverityEnum, severity: SeverityEnum,
detections: dict[str, str], detections: dict[str, str],
sub_labels: set[str], sub_labels: set[str],
zones: set[str], zones: list[str],
audio: set[str], audio: set[str],
): ):
rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6)) rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
@@ -137,7 +137,7 @@ class PendingReviewSegment:
"detections": list(set(self.detections.keys())), "detections": list(set(self.detections.keys())),
"objects": list(set(self.detections.values())), "objects": list(set(self.detections.values())),
"sub_labels": list(self.sub_labels), "sub_labels": list(self.sub_labels),
"zones": list(self.zones), "zones": self.zones,
"audio": list(self.audio), "audio": list(self.audio),
}, },
}.copy() }.copy()
@@ -213,18 +213,21 @@ class ReviewSegmentMaintainer(threading.Thread):
), ),
) )
def end_segment(self, segment: PendingReviewSegment) -> None: def end_segment(
self,
segment: PendingReviewSegment,
prev_data: dict[str, any],
) -> None:
"""End segment.""" """End segment."""
final_data = segment.get_data(ended=True) final_data = segment.get_data(ended=True)
self.requestor.send_data(UPSERT_REVIEW_SEGMENT, final_data) self.requestor.send_data(UPSERT_REVIEW_SEGMENT, final_data)
end_data = {k.name: v for k, v in final_data.items()}
self.requestor.send_data( self.requestor.send_data(
"reviews", "reviews",
json.dumps( json.dumps(
{ {
"type": "end", "type": "end",
"before": end_data, "before": {k.name: v for k, v in prev_data.items()},
"after": end_data, "after": {k.name: v for k, v in final_data.items()},
} }
), ),
) )
@@ -276,7 +279,9 @@ class ReviewSegmentMaintainer(threading.Thread):
# keep zones up to date # keep zones up to date
if len(object["current_zones"]) > 0: if len(object["current_zones"]) > 0:
segment.zones.update(object["current_zones"]) for zone in object["current_zones"]:
if zone not in segment.zones:
segment.zones.append(zone)
if len(active_objects) > segment.frame_active_count: if len(active_objects) > segment.frame_active_count:
should_update = True should_update = True
@@ -309,9 +314,9 @@ class ReviewSegmentMaintainer(threading.Thread):
if segment.severity == SeverityEnum.alert and frame_time > ( if segment.severity == SeverityEnum.alert and frame_time > (
segment.last_update + THRESHOLD_ALERT_ACTIVITY segment.last_update + THRESHOLD_ALERT_ACTIVITY
): ):
self.end_segment(segment) self.end_segment(segment, prev_data)
elif frame_time > (segment.last_update + THRESHOLD_DETECTION_ACTIVITY): elif frame_time > (segment.last_update + THRESHOLD_DETECTION_ACTIVITY):
self.end_segment(segment) self.end_segment(segment, prev_data)
def check_if_new_segment( def check_if_new_segment(
self, self,
@@ -326,7 +331,7 @@ class ReviewSegmentMaintainer(threading.Thread):
if len(active_objects) > 0: if len(active_objects) > 0:
detections: dict[str, str] = {} detections: dict[str, str] = {}
sub_labels = set() sub_labels = set()
zones: set = set() zones: list[str] = []
severity = None severity = None
for object in active_objects: for object in active_objects:
@@ -376,7 +381,9 @@ class ReviewSegmentMaintainer(threading.Thread):
): ):
severity = SeverityEnum.detection severity = SeverityEnum.detection
zones.update(object["current_zones"]) for zone in object["current_zones"]:
if zone not in zones:
zones.append(zone)
if severity: if severity:
self.active_review_segments[camera] = PendingReviewSegment( self.active_review_segments[camera] = PendingReviewSegment(
@@ -531,7 +538,7 @@ class ReviewSegmentMaintainer(threading.Thread):
severity, severity,
{}, {},
set(), set(),
set(), [],
detections, detections,
) )
elif topic == DetectionTypeEnum.api: elif topic == DetectionTypeEnum.api:
@@ -541,7 +548,7 @@ class ReviewSegmentMaintainer(threading.Thread):
SeverityEnum.alert, SeverityEnum.alert,
{manual_info["event_id"]: manual_info["label"]}, {manual_info["event_id"]: manual_info["label"]},
set(), set(),
set(), [],
set(), set(),
) )

View File

@@ -10,6 +10,7 @@ from typing import Optional
from frigate.comms.inter_process import InterProcessRequestor from frigate.comms.inter_process import InterProcessRequestor
from frigate.config import FrigateConfig from frigate.config import FrigateConfig
from frigate.const import FREQUENCY_STATS_POINTS
from frigate.stats.util import stats_snapshot from frigate.stats.util import stats_snapshot
from frigate.types import StatsTrackingTypes from frigate.types import StatsTrackingTypes
@@ -17,7 +18,6 @@ logger = logging.getLogger(__name__)
MAX_STATS_POINTS = 80 MAX_STATS_POINTS = 80
FREQUENCY_STATS_POINTS = 15
class StatsEmitter(threading.Thread): class StatsEmitter(threading.Thread):

View File

@@ -349,3 +349,39 @@ def empty_and_close_queue(q: mp.Queue):
q.close() q.close()
q.join_thread() q.join_thread()
return return
def generate_color_palette(n):
# mimic matplotlib's color scheme
base_colors = [
(31, 119, 180), # blue
(255, 127, 14), # orange
(44, 160, 44), # green
(214, 39, 40), # red
(148, 103, 189), # purple
(140, 86, 75), # brown
(227, 119, 194), # pink
(127, 127, 127), # gray
(188, 189, 34), # olive
(23, 190, 207), # cyan
]
def interpolate(color1, color2, factor):
return tuple(int(c1 + (c2 - c1) * factor) for c1, c2 in zip(color1, color2))
if n <= len(base_colors):
return base_colors[:n]
colors = base_colors.copy()
step = 1 / (n - len(base_colors) + 1)
extra_colors_needed = n - len(base_colors)
# interpolate between the base colors to generate more if needed
for i in range(extra_colors_needed):
index = i % (len(base_colors) - 1)
factor = (i + 1) * step
color1 = base_colors[index]
color2 = base_colors[index + 1]
colors.append(interpolate(color1, color2, factor))
return colors

5
web/.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}

View File

@@ -1,30 +1,25 @@
# React + TypeScript + Vite This is the Frigate frontend which connects to and provides a User Interface to the Python backend.
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. # Web Development
Currently, two official plugins are available: ## Installing Web Dependencies Via NPM
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh Within `/web`, run:
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## Expanding the ESLint configuration ```bash
npm install
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
- Configure the top-level `parserOptions` property like this:
```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
``` ```
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` ## Running development frontend
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list Within `/web`, run:
```bash
PROXY_HOST=<ip_address:port> npm run dev
```
The Proxy Host can point to your existing Frigate instance. Otherwise defaults to `localhost:5000` if running Frigate on the same machine.
## Extensions
Install these IDE extensions for an improved development experience:
- eslint

2308
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,38 +15,39 @@
}, },
"dependencies": { "dependencies": {
"@cycjimmy/jsmpeg-player": "^6.0.5", "@cycjimmy/jsmpeg-player": "^6.0.5",
"@hookform/resolvers": "^3.4.2", "@hookform/resolvers": "^3.9.0",
"@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-aspect-ratio": "^1.0.3", "@radix-ui/react-aspect-ratio": "^1.1.0",
"@radix-ui/react-context-menu": "^2.1.5", "@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-context-menu": "^2.2.1",
"@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-hover-card": "^1.0.7", "@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-label": "^2.0.2", "@radix-ui/react-hover-card": "^1.1.1",
"@radix-ui/react-popover": "^1.0.7", "@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-radio-group": "^1.1.3", "@radix-ui/react-popover": "^1.1.1",
"@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-radio-group": "^1.2.0",
"@radix-ui/react-select": "^2.0.0", "@radix-ui/react-scroll-area": "^1.1.0",
"@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slider": "^1.1.2", "@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-slider": "^1.2.0",
"@radix-ui/react-switch": "^1.0.3", "@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.0.4", "@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-toggle": "^1.0.3", "@radix-ui/react-tabs": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.0.4", "@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-tooltip": "^1.0.7", "@radix-ui/react-toggle-group": "^1.1.0",
"apexcharts": "^3.49.1", "@radix-ui/react-tooltip": "^1.1.2",
"apexcharts": "^3.50.0",
"axios": "^1.7.2", "axios": "^1.7.2",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"copy-to-clipboard": "^3.3.3", "copy-to-clipboard": "^3.3.3",
"date-fns": "^3.6.0", "date-fns": "^3.6.0",
"hls.js": "^1.5.8", "hls.js": "^1.5.13",
"idb-keyval": "^6.2.1", "idb-keyval": "^6.2.1",
"immer": "^10.1.1", "immer": "^10.1.1",
"konva": "^9.3.9", "konva": "^9.3.13",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"lucide-react": "^0.390.0", "lucide-react": "^0.407.0",
"monaco-yaml": "^5.1.1", "monaco-yaml": "^5.1.1",
"next-themes": "^0.3.0", "next-themes": "^0.3.0",
"nosleep.js": "^0.12.0", "nosleep.js": "^0.12.0",
@@ -56,22 +57,22 @@
"react-device-detect": "^2.2.3", "react-device-detect": "^2.2.3",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-grid-layout": "^1.4.4", "react-grid-layout": "^1.4.4",
"react-hook-form": "^7.51.5", "react-hook-form": "^7.52.1",
"react-icons": "^5.2.1", "react-icons": "^5.2.1",
"react-konva": "^18.2.10", "react-konva": "^18.2.10",
"react-router-dom": "^6.23.1", "react-router-dom": "^6.24.1",
"react-swipeable": "^7.0.1", "react-swipeable": "^7.0.1",
"react-tracked": "^2.0.0", "react-tracked": "^2.0.0",
"react-transition-group": "^4.4.5", "react-transition-group": "^4.4.5",
"react-use-websocket": "^4.8.1", "react-use-websocket": "^4.8.1",
"react-zoom-pan-pinch": "^3.4.4", "react-zoom-pan-pinch": "^3.6.1",
"recoil": "^0.7.7", "recoil": "^0.7.7",
"scroll-into-view-if-needed": "^3.1.0", "scroll-into-view-if-needed": "^3.1.0",
"sonner": "^1.4.41", "sonner": "^1.5.0",
"sort-by": "^1.2.0", "sort-by": "^1.2.0",
"strftime": "^0.10.2", "strftime": "^0.10.3",
"swr": "^2.2.5", "swr": "^2.2.5",
"tailwind-merge": "^2.3.0", "tailwind-merge": "^2.4.0",
"tailwind-scrollbar": "^3.1.0", "tailwind-scrollbar": "^3.1.0",
"tailwindcss-animate": "^1.0.7", "tailwindcss-animate": "^1.0.7",
"vaul": "^0.9.1", "vaul": "^0.9.1",
@@ -80,9 +81,9 @@
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/forms": "^0.5.7", "@tailwindcss/forms": "^0.5.7",
"@testing-library/jest-dom": "^6.4.5", "@testing-library/jest-dom": "^6.4.6",
"@types/lodash": "^4.17.4", "@types/lodash": "^4.17.6",
"@types/node": "^20.12.12", "@types/node": "^20.14.10",
"@types/react": "^18.3.2", "@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@types/react-grid-layout": "^1.3.5", "@types/react-grid-layout": "^1.3.5",
@@ -92,25 +93,25 @@
"@typescript-eslint/eslint-plugin": "^7.5.0", "@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0", "@typescript-eslint/parser": "^7.5.0",
"@vitejs/plugin-react-swc": "^3.6.0", "@vitejs/plugin-react-swc": "^3.6.0",
"@vitest/coverage-v8": "^1.6.0", "@vitest/coverage-v8": "^2.0.2",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.19",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.2.0", "eslint-plugin-jest": "^28.2.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6", "eslint-plugin-react-refresh": "^0.4.8",
"eslint-plugin-vitest-globals": "^1.5.0", "eslint-plugin-vitest-globals": "^1.5.0",
"fake-indexeddb": "^6.0.0", "fake-indexeddb": "^6.0.0",
"jest-websocket-mock": "^2.5.0", "jest-websocket-mock": "^2.5.0",
"jsdom": "^24.0.0", "jsdom": "^24.0.0",
"msw": "^2.3.0", "msw": "^2.3.0",
"postcss": "^8.4.38", "postcss": "^8.4.39",
"prettier": "^3.2.5", "prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.1", "prettier-plugin-tailwindcss": "^0.6.5",
"tailwindcss": "^3.4.3", "tailwindcss": "^3.4.3",
"typescript": "^5.4.5", "typescript": "^5.5.3",
"vite": "^5.2.11", "vite": "^5.3.3",
"vitest": "^1.6.0" "vitest": "^2.0.2"
} }
} }

View File

@@ -41,7 +41,7 @@ function App() {
> >
<Suspense> <Suspense>
<Routes> <Routes>
<Route path="/" element={<Live />} /> <Route index element={<Live />} />
<Route path="/events" element={<Redirect to="/review" />} /> <Route path="/events" element={<Redirect to="/review" />} />
<Route path="/review" element={<Events />} /> <Route path="/review" element={<Events />} />
<Route path="/export" element={<Exports />} /> <Route path="/export" element={<Exports />} />

View File

@@ -11,6 +11,7 @@ import {
import { FrigateStats } from "@/types/stats"; import { FrigateStats } from "@/types/stats";
import useSWR from "swr"; import useSWR from "swr";
import { createContainer } from "react-tracked"; import { createContainer } from "react-tracked";
import useDeepMemo from "@/hooks/use-deep-memo";
type Update = { type Update = {
topic: string; topic: string;
@@ -206,18 +207,18 @@ export function useFrigateEvents(): { payload: FrigateEvent } {
return { payload: JSON.parse(payload as string) }; return { payload: JSON.parse(payload as string) };
} }
export function useFrigateReviews(): { payload: FrigateReview } { export function useFrigateReviews(): FrigateReview {
const { const {
value: { payload }, value: { payload },
} = useWs("reviews", ""); } = useWs("reviews", "");
return { payload: JSON.parse(payload as string) }; return useDeepMemo(JSON.parse(payload as string));
} }
export function useFrigateStats(): { payload: FrigateStats } { export function useFrigateStats(): FrigateStats {
const { const {
value: { payload }, value: { payload },
} = useWs("stats", ""); } = useWs("stats", "");
return { payload: JSON.parse(payload as string) }; return useDeepMemo(JSON.parse(payload as string));
} }
export function useInitialCameraState( export function useInitialCameraState(
@@ -230,7 +231,8 @@ export function useInitialCameraState(
value: { payload }, value: { payload },
send: sendCommand, send: sendCommand,
} = useWs("camera_activity", "onConnect"); } = useWs("camera_activity", "onConnect");
const data = JSON.parse(payload as string);
const data = useDeepMemo(JSON.parse(payload as string));
useEffect(() => { useEffect(() => {
let listener = undefined; let listener = undefined;

View File

@@ -93,6 +93,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
<FormControl> <FormControl>
<Input <Input
className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]" className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
autoFocus
{...field} {...field}
/> />
</FormControl> </FormControl>

View File

@@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
import CameraImage from "./CameraImage"; import CameraImage from "./CameraImage";
type AutoUpdatingCameraImageProps = { type AutoUpdatingCameraImageProps = {
@@ -22,7 +22,7 @@ export default function AutoUpdatingCameraImage({
}: AutoUpdatingCameraImageProps) { }: AutoUpdatingCameraImageProps) {
const [key, setKey] = useState(Date.now()); const [key, setKey] = useState(Date.now());
const [fps, setFps] = useState<string>("0"); const [fps, setFps] = useState<string>("0");
const [timeoutId, setTimeoutId] = useState<NodeJS.Timeout>(); const timeoutRef = useRef<NodeJS.Timeout | null>(null);
useEffect(() => { useEffect(() => {
if (reloadInterval == -1) { if (reloadInterval == -1) {
@@ -32,9 +32,9 @@ export default function AutoUpdatingCameraImage({
setKey(Date.now()); setKey(Date.now());
return () => { return () => {
if (timeoutId) { if (timeoutRef.current) {
clearTimeout(timeoutId); clearTimeout(timeoutRef.current);
setTimeoutId(undefined); timeoutRef.current = null;
} }
}; };
// we know that these deps are correct // we know that these deps are correct
@@ -46,19 +46,21 @@ export default function AutoUpdatingCameraImage({
return; return;
} }
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
const loadTime = Date.now() - key; const loadTime = Date.now() - key;
if (showFps) { if (showFps) {
setFps((1000 / Math.max(loadTime, reloadInterval)).toFixed(1)); setFps((1000 / Math.max(loadTime, reloadInterval)).toFixed(1));
} }
setTimeoutId( timeoutRef.current = setTimeout(
setTimeout( () => {
() => { setKey(Date.now());
setKey(Date.now()); },
}, loadTime > reloadInterval ? 1 : reloadInterval,
loadTime > reloadInterval ? 1 : reloadInterval,
),
); );
// we know that these deps are correct // we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps

View File

@@ -1,8 +1,10 @@
import { useApiHost } from "@/api"; import { useApiHost } from "@/api";
import { useEffect, useRef, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import useSWR from "swr"; import useSWR from "swr";
import ActivityIndicator from "../indicators/activity-indicator"; import ActivityIndicator from "../indicators/activity-indicator";
import { useResizeObserver } from "@/hooks/resize-observer"; import { useResizeObserver } from "@/hooks/resize-observer";
import { isDesktop } from "react-device-detect";
import { cn } from "@/lib/utils";
type CameraImageProps = { type CameraImageProps = {
className?: string; className?: string;
@@ -19,54 +21,85 @@ export default function CameraImage({
}: CameraImageProps) { }: CameraImageProps) {
const { data: config } = useSWR("config"); const { data: config } = useSWR("config");
const apiHost = useApiHost(); const apiHost = useApiHost();
const [hasLoaded, setHasLoaded] = useState(false); const [imageLoaded, setImageLoaded] = useState(false);
const containerRef = useRef<HTMLDivElement | null>(null); const containerRef = useRef<HTMLDivElement | null>(null);
const imgRef = useRef<HTMLImageElement | null>(null); const imgRef = useRef<HTMLImageElement | null>(null);
const { name } = config ? config.cameras[camera] : ""; const { name } = config ? config.cameras[camera] : "";
const enabled = config ? config.cameras[camera].enabled : "True"; const enabled = config ? config.cameras[camera].enabled : "True";
const [{ width: containerWidth, height: containerHeight }] =
useResizeObserver(containerRef);
const requestHeight = useMemo(() => {
if (!config || containerHeight == 0) {
return 360;
}
return Math.min(
config.cameras[camera].detect.height,
Math.round(containerHeight * (isDesktop ? 1.1 : 1.25)),
);
}, [config, camera, containerHeight]);
const [isPortraitImage, setIsPortraitImage] = useState(false); const [isPortraitImage, setIsPortraitImage] = useState(false);
useEffect(() => {
setImageLoaded(false);
setIsPortraitImage(false);
}, [camera]);
useEffect(() => { useEffect(() => {
if (!config || !imgRef.current) { if (!config || !imgRef.current) {
return; return;
} }
imgRef.current.src = `${apiHost}api/${name}/latest.jpg${ const newSrc = `${apiHost}api/${name}/latest.webp?h=${requestHeight}${
searchParams ? `?${searchParams}` : "" searchParams ? `&${searchParams}` : ""
}`; }`;
}, [apiHost, name, imgRef, searchParams, config]);
const [{ width: containerWidth, height: containerHeight }] = if (imgRef.current.src !== newSrc) {
useResizeObserver(containerRef); imgRef.current.src = newSrc;
}
}, [apiHost, name, searchParams, requestHeight, config, camera]);
const handleImageLoad = () => {
if (imgRef.current && containerWidth && containerHeight) {
const { naturalWidth, naturalHeight } = imgRef.current;
setIsPortraitImage(
naturalWidth / naturalHeight < containerWidth / containerHeight,
);
}
setImageLoaded(true);
if (onload) {
onload();
}
};
return ( return (
<div className={className} ref={containerRef}> <div className={className} ref={containerRef}>
{enabled ? ( {enabled ? (
<img <img
ref={imgRef} ref={imgRef}
className={`object-contain ${isPortraitImage ? "h-full w-auto" : "h-auto w-full"} rounded-lg md:rounded-2xl`} className={cn(
onLoad={() => { "object-contain",
setHasLoaded(true); imageLoaded
? isPortraitImage
if (imgRef.current) { ? "h-full w-auto"
const { naturalHeight, naturalWidth } = imgRef.current; : "h-auto w-full"
setIsPortraitImage( : "invisible",
naturalWidth / naturalHeight < containerWidth / containerHeight, "rounded-lg md:rounded-2xl",
); )}
} onLoad={handleImageLoad}
if (onload) {
onload();
}
}}
/> />
) : ( ) : (
<div className="pt-6 text-center"> <div className="pt-6 text-center">
Camera is disabled in config, no stream or snapshot available! Camera is disabled in config, no stream or snapshot available!
</div> </div>
)} )}
{!hasLoaded && enabled ? ( {!imageLoaded && enabled ? (
<div className="absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center"> <div className="absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center">
<ActivityIndicator /> <ActivityIndicator />
</div> </div>

View File

@@ -89,7 +89,7 @@ export default function CameraImage({
if (!config || scaledHeight === 0 || !canvasRef.current) { if (!config || scaledHeight === 0 || !canvasRef.current) {
return; return;
} }
img.src = `${apiHost}api/${name}/latest.jpg?h=${scaledHeight}${ img.src = `${apiHost}api/${name}/latest.webp?h=${scaledHeight}${
searchParams ? `&${searchParams}` : "" searchParams ? `&${searchParams}` : ""
}`; }`;
}, [apiHost, canvasRef, name, img, searchParams, scaledHeight, config]); }, [apiHost, canvasRef, name, img, searchParams, scaledHeight, config]);

View File

@@ -49,8 +49,14 @@ export default function ExportCard({
useKeyboardListener( useKeyboardListener(
editName != undefined ? ["Enter"] : [], editName != undefined ? ["Enter"] : [],
(_, down, repeat) => { (key, modifiers) => {
if (down && !repeat && editName && editName.update.length > 0) { if (
key == "Enter" &&
modifiers.down &&
!modifiers.repeat &&
editName &&
editName.update.length > 0
) {
onRename(exportedRecording.id, editName.update); onRename(exportedRecording.id, editName.update);
setEditName(undefined); setEditName(undefined);
} }

View File

@@ -1,7 +1,7 @@
import { baseUrl } from "@/api/baseUrl"; import { baseUrl } from "@/api/baseUrl";
import { useFormattedTimestamp } from "@/hooks/use-date-utils"; import { useFormattedTimestamp } from "@/hooks/use-date-utils";
import { FrigateConfig } from "@/types/frigateConfig"; import { FrigateConfig } from "@/types/frigateConfig";
import { ReviewSegment } from "@/types/review"; import { REVIEW_PADDING, ReviewSegment } from "@/types/review";
import { getIconForLabel } from "@/utils/iconUtil"; import { getIconForLabel } from "@/utils/iconUtil";
import { isDesktop, isIOS, isSafari } from "react-device-detect"; import { isDesktop, isIOS, isSafari } from "react-device-detect";
import useSWR from "swr"; import useSWR from "swr";
@@ -54,9 +54,13 @@ export default function ReviewCard({
}, [event]); }, [event]);
const onExport = useCallback(async () => { const onExport = useCallback(async () => {
const endTime = event.end_time
? event.end_time + REVIEW_PADDING
: Date.now() / 1000;
axios axios
.post( .post(
`export/${event.camera}/start/${event.start_time}/end/${event.end_time}`, `export/${event.camera}/start/${event.start_time + REVIEW_PADDING}/end/${endTime}`,
{ playback: "realtime" }, { playback: "realtime" },
) )
.then((response) => { .then((response) => {

View File

@@ -468,7 +468,7 @@ export function CameraGroupRow({
{isMobile && ( {isMobile && (
<> <>
<DropdownMenu modal={false}> <DropdownMenu modal={!isDesktop}>
<DropdownMenuTrigger> <DropdownMenuTrigger>
<HiOutlineDotsVertical className="size-5" /> <HiOutlineDotsVertical className="size-5" />
</DropdownMenuTrigger> </DropdownMenuTrigger>

View File

@@ -1,3 +1,4 @@
import { forwardRef } from "react";
import { LuPlus } from "react-icons/lu"; import { LuPlus } from "react-icons/lu";
import Logo from "../Logo"; import Logo from "../Logo";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
@@ -6,17 +7,20 @@ type FrigatePlusIconProps = {
className?: string; className?: string;
onClick?: () => void; onClick?: () => void;
}; };
export default function FrigatePlusIcon({
className, const FrigatePlusIcon = forwardRef<HTMLDivElement, FrigatePlusIconProps>(
onClick, ({ className, onClick }, ref) => {
}: FrigatePlusIconProps) { return (
return ( <div
<div ref={ref}
className={cn("relative flex items-center", className)} className={cn("relative flex items-center", className)}
onClick={onClick} onClick={onClick}
> >
<Logo className="size-full" /> <Logo className="size-full" />
<LuPlus className="absolute size-2 translate-x-3 translate-y-3/4" /> <LuPlus className="absolute size-2 translate-x-3 translate-y-3/4" />
</div> </div>
); );
} },
);
export default FrigatePlusIcon;

View File

@@ -1,6 +1,7 @@
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { LogSeverity } from "@/types/log"; import { LogSeverity } from "@/types/log";
import { ReactNode, useMemo, useRef } from "react"; import { ReactNode, useMemo, useRef } from "react";
import { isIOS } from "react-device-detect";
import { CSSTransition } from "react-transition-group"; import { CSSTransition } from "react-transition-group";
type ChipProps = { type ChipProps = {
@@ -34,8 +35,9 @@ export default function Chip({
<div <div
ref={nodeRef} ref={nodeRef}
className={cn( className={cn(
"z-10 flex items-center rounded-2xl px-2 py-1.5", "flex items-center rounded-2xl px-2 py-1.5",
className, className,
!isIOS && "z-10",
)} )}
onClick={onClick} onClick={onClick}
> >

View File

@@ -48,7 +48,7 @@ function StatusAlertNav({ className }: StatusAlertNavProps) {
const { data: initialStats } = useSWR<FrigateStats>("stats", { const { data: initialStats } = useSWR<FrigateStats>("stats", {
revalidateOnFocus: false, revalidateOnFocus: false,
}); });
const { payload: latestStats } = useFrigateStats(); const latestStats = useFrigateStats();
const { messages, addMessage, clearMessages } = useContext( const { messages, addMessage, clearMessages } = useContext(
StatusBarMessagesContext, StatusBarMessagesContext,

View File

@@ -1,13 +1,18 @@
import Logo from "../Logo"; import Logo from "../Logo";
import NavItem from "./NavItem"; import NavItem from "./NavItem";
import { CameraGroupSelector } from "../filter/CameraGroupSelector"; import { CameraGroupSelector } from "../filter/CameraGroupSelector";
import { useLocation } from "react-router-dom"; import { Link, useMatch } from "react-router-dom";
import GeneralSettings from "../menu/GeneralSettings"; import GeneralSettings from "../menu/GeneralSettings";
import AccountSettings from "../menu/AccountSettings"; import AccountSettings from "../menu/AccountSettings";
import useNavigation from "@/hooks/use-navigation"; import useNavigation from "@/hooks/use-navigation";
import { baseUrl } from "@/api/baseUrl";
import { useMemo } from "react";
function Sidebar() { function Sidebar() {
const location = useLocation(); const basePath = useMemo(() => new URL(baseUrl).pathname, []);
const isRootMatch = useMatch("/");
const isBasePathMatch = useMatch(basePath);
const navbarLinks = useNavigation(); const navbarLinks = useNavigation();
@@ -15,10 +20,12 @@ function Sidebar() {
<aside className="scrollbar-container scrollbar-hidden absolute inset-y-0 left-0 z-10 flex w-[52px] flex-col justify-between overflow-y-auto border-r border-secondary-highlight bg-background_alt py-4"> <aside className="scrollbar-container scrollbar-hidden absolute inset-y-0 left-0 z-10 flex w-[52px] flex-col justify-between overflow-y-auto border-r border-secondary-highlight bg-background_alt py-4">
<span tabIndex={0} className="sr-only" /> <span tabIndex={0} className="sr-only" />
<div className="flex w-full flex-col items-center gap-0"> <div className="flex w-full flex-col items-center gap-0">
<Logo className="mb-6 h-8 w-8" /> <Link to="/">
<Logo className="mb-6 h-8 w-8" />
</Link>
{navbarLinks.map((item) => { {navbarLinks.map((item) => {
const showCameraGroups = const showCameraGroups =
item.id == 1 && item.url == location.pathname; (isRootMatch || isBasePathMatch) && item.id === 1;
return ( return (
<div key={item.id}> <div key={item.id}>

View File

@@ -61,6 +61,7 @@ export default function ReviewActivityCalendar({
return ( return (
<Calendar <Calendar
key={selectedDay ? selectedDay.toISOString() : "reset"}
mode="single" mode="single"
disabled={disabledDates} disabled={disabledDates}
showOutsideDays={false} showOutsideDays={false}
@@ -70,6 +71,7 @@ export default function ReviewActivityCalendar({
components={{ components={{
DayContent: ReviewActivityDay, DayContent: ReviewActivityDay,
}} }}
defaultMonth={selectedDay ?? new Date()}
/> />
); );
} }
@@ -152,12 +154,14 @@ export function TimezoneAwareCalendar({
return ( return (
<Calendar <Calendar
key={selectedDay ? selectedDay.toISOString() : "reset"}
mode="single" mode="single"
disabled={disabledDates} disabled={disabledDates}
showOutsideDays={false} showOutsideDays={false}
today={today} today={today}
selected={selectedDay} selected={selectedDay}
onSelect={onSelect} onSelect={onSelect}
defaultMonth={selectedDay ?? new Date()}
/> />
); );
} }

View File

@@ -12,7 +12,7 @@ type LivePlayerProps = {
birdseyeConfig: BirdseyeConfig; birdseyeConfig: BirdseyeConfig;
liveMode: LivePlayerMode; liveMode: LivePlayerMode;
onClick?: () => void; onClick?: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>; containerRef: React.MutableRefObject<HTMLDivElement | null>;
}; };
export default function BirdseyeLivePlayer({ export default function BirdseyeLivePlayer({
@@ -41,8 +41,7 @@ export default function BirdseyeLivePlayer({
} else { } else {
player = ( player = (
<div className="w-5xl text-center text-sm"> <div className="w-5xl text-center text-sm">
MSE is only supported on iOS 17.1+. You'll need to update if available iOS 17.1 or greater is required for this live stream type.
or use jsmpeg / webRTC streams. See the docs for more info.
</div> </div>
); );
} }
@@ -54,6 +53,7 @@ export default function BirdseyeLivePlayer({
width={birdseyeConfig.width} width={birdseyeConfig.width}
height={birdseyeConfig.height} height={birdseyeConfig.height}
containerRef={containerRef} containerRef={containerRef}
playbackEnabled={true}
/> />
); );
} else { } else {
@@ -62,6 +62,7 @@ export default function BirdseyeLivePlayer({
return ( return (
<div <div
ref={containerRef}
className={cn( className={cn(
"relative flex w-full cursor-pointer justify-center", "relative flex w-full cursor-pointer justify-center",
className, className,

View File

@@ -40,6 +40,7 @@ type HlsVideoPlayerProps = {
setFullResolution?: React.Dispatch<React.SetStateAction<VideoResolutionType>>; setFullResolution?: React.Dispatch<React.SetStateAction<VideoResolutionType>>;
onUploadFrame?: (playTime: number) => Promise<AxiosResponse> | undefined; onUploadFrame?: (playTime: number) => Promise<AxiosResponse> | undefined;
toggleFullscreen?: () => void; toggleFullscreen?: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
}; };
export default function HlsVideoPlayer({ export default function HlsVideoPlayer({
videoRef, videoRef,
@@ -54,6 +55,7 @@ export default function HlsVideoPlayer({
setFullResolution, setFullResolution,
onUploadFrame, onUploadFrame,
toggleFullscreen, toggleFullscreen,
containerRef,
}: HlsVideoPlayerProps) { }: HlsVideoPlayerProps) {
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
@@ -159,7 +161,7 @@ export default function HlsVideoPlayer({
}, [videoRef, controlsOpen]); }, [videoRef, controlsOpen]);
return ( return (
<TransformWrapper minScale={1.0}> <TransformWrapper minScale={1.0} wheel={{ smoothStep: 0.005 }}>
<VideoControls <VideoControls
className={cn( className={cn(
"absolute left-1/2 z-50 -translate-x-1/2", "absolute left-1/2 z-50 -translate-x-1/2",
@@ -202,7 +204,7 @@ export default function HlsVideoPlayer({
videoRef.current.currentTime = Math.max(0, currentTime + diff); videoRef.current.currentTime = Math.max(0, currentTime + diff);
}} }}
onSetPlaybackRate={(rate) => { onSetPlaybackRate={(rate) => {
setPlaybackRate(rate); setPlaybackRate(rate, true);
if (videoRef.current) { if (videoRef.current) {
videoRef.current.playbackRate = rate; videoRef.current.playbackRate = rate;
@@ -225,6 +227,7 @@ export default function HlsVideoPlayer({
}} }}
fullscreen={fullscreen} fullscreen={fullscreen}
toggleFullscreen={toggleFullscreen} toggleFullscreen={toggleFullscreen}
containerRef={containerRef}
/> />
<TransformComponent <TransformComponent
wrapperStyle={{ wrapperStyle={{

View File

@@ -1,15 +1,17 @@
import { baseUrl } from "@/api/baseUrl"; import { baseUrl } from "@/api/baseUrl";
import { useResizeObserver } from "@/hooks/resize-observer"; import { useResizeObserver } from "@/hooks/resize-observer";
import { cn } from "@/lib/utils";
// @ts-expect-error we know this doesn't have types // @ts-expect-error we know this doesn't have types
import JSMpeg from "@cycjimmy/jsmpeg-player"; import JSMpeg from "@cycjimmy/jsmpeg-player";
import React, { useEffect, useMemo, useRef, useId } from "react"; import React, { useEffect, useMemo, useRef, useState } from "react";
type JSMpegPlayerProps = { type JSMpegPlayerProps = {
className?: string; className?: string;
camera: string; camera: string;
width: number; width: number;
height: number; height: number;
containerRef?: React.MutableRefObject<HTMLDivElement | null>; containerRef: React.MutableRefObject<HTMLDivElement | null>;
playbackEnabled: boolean;
onPlaying?: () => void; onPlaying?: () => void;
}; };
@@ -19,15 +21,23 @@ export default function JSMpegPlayer({
height, height,
className, className,
containerRef, containerRef,
playbackEnabled,
onPlaying, onPlaying,
}: JSMpegPlayerProps) { }: JSMpegPlayerProps) {
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`; const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
const playerRef = useRef<HTMLDivElement | null>(null); const videoRef = useRef<HTMLDivElement>(null);
const canvasRef = useRef<HTMLCanvasElement>(null);
const internalContainerRef = useRef<HTMLDivElement | null>(null); const internalContainerRef = useRef<HTMLDivElement | null>(null);
const onPlayingRef = useRef(onPlaying);
const [showCanvas, setShowCanvas] = useState(false);
const [hasData, setHasData] = useState(false);
const [dimensionsReady, setDimensionsReady] = useState(false);
const selectedContainerRef = useMemo( const selectedContainerRef = useMemo(
() => containerRef ?? internalContainerRef, () => (containerRef.current ? containerRef : internalContainerRef),
[containerRef, internalContainerRef], // we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
[containerRef, containerRef.current, internalContainerRef],
); );
const [{ width: containerWidth, height: containerHeight }] = const [{ width: containerWidth, height: containerHeight }] =
@@ -62,6 +72,7 @@ export default function JSMpegPlayer({
return finalHeight; return finalHeight;
} }
} }
return undefined;
}, [ }, [
aspectRatio, aspectRatio,
containerWidth, containerWidth,
@@ -77,49 +88,88 @@ export default function JSMpegPlayer({
if (aspectRatio && scaledHeight) { if (aspectRatio && scaledHeight) {
return Math.ceil(scaledHeight * aspectRatio); return Math.ceil(scaledHeight * aspectRatio);
} }
return undefined;
}, [scaledHeight, aspectRatio]); }, [scaledHeight, aspectRatio]);
const uniqueId = useId(); useEffect(() => {
if (scaledWidth && scaledHeight) {
setDimensionsReady(true);
}
}, [scaledWidth, scaledHeight]);
useEffect(() => { useEffect(() => {
if (!playerRef.current) { onPlayingRef.current = onPlaying;
}, [onPlaying]);
useEffect(() => {
if (!selectedContainerRef?.current || !url) {
return; return;
} }
const video = new JSMpeg.VideoElement( const videoWrapper = videoRef.current;
playerRef.current, const canvas = canvasRef.current;
url, let videoElement: JSMpeg.VideoElement | null = null;
{ canvas: `#${CSS.escape(uniqueId)}` },
{
protocols: [],
audio: false,
videoBufferSize: 1024 * 1024 * 4,
onPlay: () => {
onPlaying?.();
},
},
);
return () => { if (videoWrapper && playbackEnabled) {
if (playerRef.current) { // Delayed init to avoid issues with react strict mode
try { const initPlayer = setTimeout(() => {
video.destroy(); videoElement = new JSMpeg.VideoElement(
// eslint-disable-next-line no-empty videoWrapper,
} catch (e) {} url,
playerRef.current = null; { canvas: canvas },
} {
}; protocols: [],
}, [url, uniqueId, onPlaying]); audio: false,
videoBufferSize: 1024 * 1024 * 4,
onVideoDecode: () => {
if (!hasData) {
setHasData(true);
onPlayingRef.current?.();
}
},
},
);
}, 0);
return () => {
clearTimeout(initPlayer);
if (videoElement) {
try {
// this causes issues in react strict mode
// https://stackoverflow.com/questions/76822128/issue-with-cycjimmy-jsmpeg-player-in-react-18-cannot-read-properties-of-null-o
videoElement.destroy();
// eslint-disable-next-line no-empty
} catch (e) {}
}
};
}
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [playbackEnabled, url]);
useEffect(() => {
setShowCanvas(hasData && dimensionsReady);
}, [hasData, dimensionsReady]);
return ( return (
<div className={className}> <div className={cn(className, !containerRef.current && "size-full")}>
<div className="size-full" ref={internalContainerRef}> <div
<div ref={playerRef} className="jsmpeg"> className="internal-jsmpeg-container size-full"
ref={internalContainerRef}
>
<div
ref={videoRef}
className={cn(
"jsmpeg flex h-full w-auto items-center justify-center",
!showCanvas && "hidden",
)}
>
<canvas <canvas
id={uniqueId} ref={canvasRef}
className="rounded-lg md:rounded-2xl"
style={{ style={{
width: scaledWidth ?? width, width: scaledWidth,
height: scaledHeight ?? height, height: scaledHeight,
}} }}
></canvas> ></canvas>
</div> </div>

View File

@@ -2,7 +2,7 @@ import WebRtcPlayer from "./WebRTCPlayer";
import { CameraConfig } from "@/types/frigateConfig"; import { CameraConfig } from "@/types/frigateConfig";
import AutoUpdatingCameraImage from "../camera/AutoUpdatingCameraImage"; import AutoUpdatingCameraImage from "../camera/AutoUpdatingCameraImage";
import ActivityIndicator from "../indicators/activity-indicator"; import ActivityIndicator from "../indicators/activity-indicator";
import { useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import MSEPlayer from "./MsePlayer"; import MSEPlayer from "./MsePlayer";
import JSMpegPlayer from "./JSMpegPlayer"; import JSMpegPlayer from "./JSMpegPlayer";
import { MdCircle } from "react-icons/md"; import { MdCircle } from "react-icons/md";
@@ -18,6 +18,7 @@ import { getIconForLabel } from "@/utils/iconUtil";
import Chip from "../indicators/Chip"; import Chip from "../indicators/Chip";
import { capitalizeFirstLetter } from "@/utils/stringUtil"; import { capitalizeFirstLetter } from "@/utils/stringUtil";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { TbExclamationCircle } from "react-icons/tb";
type LivePlayerProps = { type LivePlayerProps = {
cameraRef?: (ref: HTMLDivElement | null) => void; cameraRef?: (ref: HTMLDivElement | null) => void;
@@ -54,6 +55,7 @@ export default function LivePlayer({
setFullResolution, setFullResolution,
onError, onError,
}: LivePlayerProps) { }: LivePlayerProps) {
const internalContainerRef = useRef<HTMLDivElement | null>(null);
// camera activity // camera activity
const { activeMotion, activeTracking, objects, offline } = const { activeMotion, activeTracking, objects, offline } =
@@ -72,20 +74,12 @@ export default function LivePlayer({
const [liveReady, setLiveReady] = useState(false); const [liveReady, setLiveReady] = useState(false);
useEffect(() => { useEffect(() => {
if (!autoLive) { if (!autoLive || !liveReady) {
return;
}
if (!liveReady) {
if (cameraActive && liveMode == "jsmpeg") {
setLiveReady(true);
}
return; return;
} }
if (!cameraActive) { if (!cameraActive) {
setTimeout(() => setLiveReady(false), 500); setLiveReady(false);
} }
// live mode won't change // live mode won't change
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -125,6 +119,10 @@ export default function LivePlayer({
setLiveReady(false); setLiveReady(false);
}, [preferredLiveMode]); }, [preferredLiveMode]);
const playerIsPlaying = useCallback(() => {
setLiveReady(true);
}, []);
if (!cameraConfig) { if (!cameraConfig) {
return <ActivityIndicator />; return <ActivityIndicator />;
} }
@@ -141,7 +139,7 @@ export default function LivePlayer({
audioEnabled={playAudio} audioEnabled={playAudio}
microphoneEnabled={micEnabled} microphoneEnabled={micEnabled}
iOSCompatFullScreen={iOSCompatFullScreen} iOSCompatFullScreen={iOSCompatFullScreen}
onPlaying={() => setLiveReady(true)} onPlaying={playerIsPlaying}
pip={pip} pip={pip}
onError={onError} onError={onError}
/> />
@@ -154,7 +152,7 @@ export default function LivePlayer({
camera={cameraConfig.live.stream_name} camera={cameraConfig.live.stream_name}
playbackEnabled={cameraActive} playbackEnabled={cameraActive}
audioEnabled={playAudio} audioEnabled={playAudio}
onPlaying={() => setLiveReady(true)} onPlaying={playerIsPlaying}
pip={pip} pip={pip}
setFullResolution={setFullResolution} setFullResolution={setFullResolution}
onError={onError} onError={onError}
@@ -163,8 +161,7 @@ export default function LivePlayer({
} else { } else {
player = ( player = (
<div className="w-5xl text-center text-sm"> <div className="w-5xl text-center text-sm">
MSE is only supported on iOS 17.1+. You'll need to update if available iOS 17.1 or greater is required for this live stream type.
or use jsmpeg / webRTC streams. See the docs for more info.
</div> </div>
); );
} }
@@ -173,11 +170,12 @@ export default function LivePlayer({
player = ( player = (
<JSMpegPlayer <JSMpegPlayer
className="flex justify-center overflow-hidden rounded-lg md:rounded-2xl" className="flex justify-center overflow-hidden rounded-lg md:rounded-2xl"
camera={cameraConfig.live.stream_name} camera={cameraConfig.name}
width={cameraConfig.detect.width} width={cameraConfig.detect.width}
height={cameraConfig.detect.height} height={cameraConfig.detect.height}
containerRef={containerRef} playbackEnabled={cameraActive || !showStillWithoutActivity}
onPlaying={() => setLiveReady(true)} containerRef={containerRef ?? internalContainerRef}
onPlaying={playerIsPlaying}
/> />
); );
} else { } else {
@@ -189,7 +187,7 @@ export default function LivePlayer({
return ( return (
<div <div
ref={cameraRef} ref={cameraRef ?? internalContainerRef}
data-camera={cameraConfig.name} data-camera={cameraConfig.name}
className={cn( className={cn(
"relative flex w-full cursor-pointer justify-center outline", "relative flex w-full cursor-pointer justify-center outline",
@@ -258,9 +256,10 @@ export default function LivePlayer({
)} )}
<div <div
className={`absolute inset-0 w-full ${ className={cn(
showStillWithoutActivity && !liveReady ? "visible" : "invisible" "absolute inset-0 w-full",
}`} showStillWithoutActivity && !liveReady ? "visible" : "invisible",
)}
> >
<AutoUpdatingCameraImage <AutoUpdatingCameraImage
className="size-full" className="size-full"
@@ -271,6 +270,16 @@ export default function LivePlayer({
/> />
</div> </div>
{offline && !showStillWithoutActivity && (
<div className="flex size-full flex-col items-center">
<p className="mb-5">
{capitalizeFirstLetter(cameraConfig.name)} is offline
</p>
<TbExclamationCircle className="mb-3 size-10" />
<p>No frames have been received, check error logs</p>
</div>
)}
<div className="absolute right-2 top-2"> <div className="absolute right-2 top-2">
{autoLive && {autoLive &&
!offline && !offline &&
@@ -278,7 +287,7 @@ export default function LivePlayer({
((showStillWithoutActivity && !liveReady) || liveReady) && ( ((showStillWithoutActivity && !liveReady) || liveReady) && (
<MdCircle className="mr-2 size-2 animate-pulse text-danger shadow-danger drop-shadow-md" /> <MdCircle className="mr-2 size-2 animate-pulse text-danger shadow-danger drop-shadow-md" />
)} )}
{offline && ( {offline && showStillWithoutActivity && (
<Chip <Chip
className={`z-0 flex items-start justify-between space-x-1 bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500 text-xs capitalize`} className={`z-0 flex items-start justify-between space-x-1 bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500 text-xs capitalize`}
> >

View File

@@ -31,7 +31,7 @@ function MSEPlayer({
setFullResolution, setFullResolution,
onError, onError,
}: MSEPlayerProps) { }: MSEPlayerProps) {
const RECONNECT_TIMEOUT: number = 30000; const RECONNECT_TIMEOUT: number = 10000;
const CODECS: string[] = [ const CODECS: string[] = [
"avc1.640029", // H.264 high 4.1 (Chromecast 1st and 2nd Gen) "avc1.640029", // H.264 high 4.1 (Chromecast 1st and 2nd Gen)
@@ -45,10 +45,12 @@ function MSEPlayer({
]; ];
const visibilityCheck: boolean = !pip; const visibilityCheck: boolean = !pip;
const [isPlaying, setIsPlaying] = useState(false);
const [wsState, setWsState] = useState<number>(WebSocket.CLOSED); const [wsState, setWsState] = useState<number>(WebSocket.CLOSED);
const [connectTS, setConnectTS] = useState<number>(0); const [connectTS, setConnectTS] = useState<number>(0);
const [bufferTimeout, setBufferTimeout] = useState<NodeJS.Timeout>(); const [bufferTimeout, setBufferTimeout] = useState<NodeJS.Timeout>();
const [errorCount, setErrorCount] = useState<number>(0);
const videoRef = useRef<HTMLVideoElement>(null); const videoRef = useRef<HTMLVideoElement>(null);
const wsRef = useRef<WebSocket | null>(null); const wsRef = useRef<WebSocket | null>(null);
@@ -117,12 +119,19 @@ function MSEPlayer({
}, [wsURL]); }, [wsURL]);
const onDisconnect = useCallback(() => { const onDisconnect = useCallback(() => {
setWsState(WebSocket.CLOSED); if (bufferTimeout) {
clearTimeout(bufferTimeout);
setBufferTimeout(undefined);
}
setIsPlaying(false);
if (wsRef.current) { if (wsRef.current) {
setWsState(WebSocket.CLOSED);
wsRef.current.close(); wsRef.current.close();
wsRef.current = null; wsRef.current = null;
} }
}, []); }, [bufferTimeout]);
const onOpen = () => { const onOpen = () => {
setWsState(WebSocket.OPEN); setWsState(WebSocket.OPEN);
@@ -162,6 +171,26 @@ function MSEPlayer({
reconnect(); reconnect();
}; };
const sendWithTimeout = (value: object, timeout: number) => {
return new Promise<void>((resolve, reject) => {
const timeoutId = setTimeout(() => {
reject(new Error("Timeout waiting for response"));
}, timeout);
send(value);
// Override the onmessageRef handler for mse type to resolve the promise on response
const originalHandler = onmessageRef.current["mse"];
onmessageRef.current["mse"] = (msg) => {
if (msg.type === "mse") {
clearTimeout(timeoutId);
if (originalHandler) originalHandler(msg);
resolve();
}
};
});
};
const onMse = () => { const onMse = () => {
if ("ManagedMediaSource" in window) { if ("ManagedMediaSource" in window) {
const MediaSource = window.ManagedMediaSource; const MediaSource = window.ManagedMediaSource;
@@ -169,10 +198,22 @@ function MSEPlayer({
msRef.current?.addEventListener( msRef.current?.addEventListener(
"sourceopen", "sourceopen",
() => { () => {
send({ sendWithTimeout(
type: "mse", {
// @ts-expect-error for typing type: "mse",
value: codecs(MediaSource.isTypeSupported), // @ts-expect-error for typing
value: codecs(MediaSource.isTypeSupported),
},
3000,
).catch(() => {
if (wsRef.current) {
onDisconnect();
}
if (isIOS || isSafari) {
onError?.("mse-decode");
} else {
onError?.("startup");
}
}); });
}, },
{ once: true }, { once: true },
@@ -187,9 +228,21 @@ function MSEPlayer({
"sourceopen", "sourceopen",
() => { () => {
URL.revokeObjectURL(videoRef.current?.src || ""); URL.revokeObjectURL(videoRef.current?.src || "");
send({ sendWithTimeout(
type: "mse", {
value: codecs(MediaSource.isTypeSupported), type: "mse",
value: codecs(MediaSource.isTypeSupported),
},
3000,
).catch(() => {
if (wsRef.current) {
onDisconnect();
}
if (isIOS || isSafari) {
onError?.("mse-decode");
} else {
onError?.("startup");
}
}); });
}, },
{ once: true }, { once: true },
@@ -244,6 +297,11 @@ function MSEPlayer({
}; };
}; };
const getBufferedTime = (video: HTMLVideoElement | null) => {
if (!video || video.buffered.length === 0) return 0;
return video.buffered.end(video.buffered.length - 1) - video.currentTime;
};
useEffect(() => { useEffect(() => {
if (!playbackEnabled) { if (!playbackEnabled) {
return; return;
@@ -263,7 +321,7 @@ function MSEPlayer({
}; };
// we know that these deps are correct // we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [playbackEnabled, onDisconnect, onConnect]); }, [playbackEnabled]);
// check visibility // check visibility
@@ -301,6 +359,23 @@ function MSEPlayer({
videoRef.current.requestPictureInPicture(); videoRef.current.requestPictureInPicture();
}, [pip, videoRef]); }, [pip, videoRef]);
// ensure we disconnect for slower connections
useEffect(() => {
if (wsRef.current?.readyState === WebSocket.OPEN && !playbackEnabled) {
if (bufferTimeout) {
clearTimeout(bufferTimeout);
setBufferTimeout(undefined);
}
setTimeout(() => {
if (!playbackEnabled) onDisconnect();
}, 10000);
}
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [playbackEnabled]);
return ( return (
<video <video
ref={videoRef} ref={videoRef}
@@ -310,10 +385,20 @@ function MSEPlayer({
onLoadedData={() => { onLoadedData={() => {
handleLoadedMetadata?.(); handleLoadedMetadata?.();
onPlaying?.(); onPlaying?.();
setIsPlaying(true);
}} }}
muted={!audioEnabled} muted={!audioEnabled}
onPause={() => videoRef.current?.play()}
onProgress={() => { onProgress={() => {
if (isSafari || isIOS) { // if we have > 3 seconds of buffered data and we're still not playing,
// something might be wrong - maybe codec issue, no audio, etc
// so mark the player as playing so that error handlers will fire
if (
!isPlaying &&
playbackEnabled &&
getBufferedTime(videoRef.current) > 3
) {
setIsPlaying(true);
onPlaying?.(); onPlaying?.();
} }
if (onError != undefined) { if (onError != undefined) {
@@ -330,8 +415,10 @@ function MSEPlayer({
setTimeout(() => { setTimeout(() => {
if ( if (
document.visibilityState === "visible" && document.visibilityState === "visible" &&
wsRef.current != undefined wsRef.current != null &&
videoRef.current
) { ) {
onDisconnect();
onError("stalled"); onError("stalled");
} }
}, 3000), }, 3000),
@@ -343,6 +430,9 @@ function MSEPlayer({
// @ts-expect-error code does exist // @ts-expect-error code does exist
e.target.error.code == MediaError.MEDIA_ERR_NETWORK e.target.error.code == MediaError.MEDIA_ERR_NETWORK
) { ) {
if (wsRef.current) {
onDisconnect();
}
onError?.("startup"); onError?.("startup");
} }
@@ -351,15 +441,22 @@ function MSEPlayer({
e.target.error.code == MediaError.MEDIA_ERR_DECODE && e.target.error.code == MediaError.MEDIA_ERR_DECODE &&
(isSafari || isIOS) (isSafari || isIOS)
) { ) {
if (wsRef.current) {
onDisconnect();
}
onError?.("mse-decode"); onError?.("mse-decode");
clearTimeout(bufferTimeout);
setBufferTimeout(undefined);
} }
setErrorCount((prevCount) => prevCount + 1);
if (wsRef.current) { if (wsRef.current) {
wsRef.current.close(); onDisconnect();
wsRef.current = null; if (errorCount >= 3) {
reconnect(5000); // too many mse errors, try jsmpeg
onError?.("startup");
} else {
reconnect(5000);
}
} }
}} }}
/> />

View File

@@ -172,6 +172,12 @@ function PreviewVideoPlayer({
const [firstLoad, setFirstLoad] = useState(true); const [firstLoad, setFirstLoad] = useState(true);
useEffect(() => {
if (cameraPreviews && cameraPreviews.length > 0) {
setFirstLoad(false);
}
}, [cameraPreviews]);
const [currentPreview, setCurrentPreview] = useState(initialPreview); const [currentPreview, setCurrentPreview] = useState(initialPreview);
const onPreviewSeeked = useCallback(() => { const onPreviewSeeked = useCallback(() => {
@@ -483,6 +489,12 @@ function PreviewFramesPlayer({
const [firstLoad, setFirstLoad] = useState(true); const [firstLoad, setFirstLoad] = useState(true);
useEffect(() => {
if (previewFrames != undefined && previewFrames.length == 0) {
setFirstLoad(false);
}
}, [previewFrames]);
useEffect(() => { useEffect(() => {
if (!controller) { if (!controller) {
return; return;

View File

@@ -26,6 +26,7 @@ import { NoThumbSlider } from "../ui/slider";
import { PREVIEW_FPS, PREVIEW_PADDING } from "@/types/preview"; import { PREVIEW_FPS, PREVIEW_PADDING } from "@/types/preview";
import { capitalizeFirstLetter } from "@/utils/stringUtil"; import { capitalizeFirstLetter } from "@/utils/stringUtil";
import { baseUrl } from "@/api/baseUrl"; import { baseUrl } from "@/api/baseUrl";
import { cn } from "@/lib/utils";
type PreviewPlayerProps = { type PreviewPlayerProps = {
review: ReviewSegment; review: ReviewSegment;
@@ -70,12 +71,6 @@ export default function PreviewThumbnailPlayer({
[ignoreClick, review, onClick], [ignoreClick, review, onClick],
); );
const swipeHandlers = useSwipeable({
onSwipedLeft: () => (setReviewed ? setReviewed(review) : null),
onSwipedRight: () => setPlayback(true),
preventScrollOnSwipe: true,
});
const handleSetReviewed = useCallback(() => { const handleSetReviewed = useCallback(() => {
if (review.end_time && !review.has_been_reviewed) { if (review.end_time && !review.has_been_reviewed) {
review.has_been_reviewed = true; review.has_been_reviewed = true;
@@ -83,6 +78,15 @@ export default function PreviewThumbnailPlayer({
} }
}, [review, setReviewed]); }, [review, setReviewed]);
const swipeHandlers = useSwipeable({
onSwipedLeft: () => {
setPlayback(false);
handleSetReviewed();
},
onSwipedRight: () => setPlayback(true),
preventScrollOnSwipe: true,
});
useContextMenu(imgRef, () => { useContextMenu(imgRef, () => {
onClick(review, true); onClick(review, true);
}); });
@@ -226,8 +230,15 @@ export default function PreviewThumbnailPlayer({
onImgLoad(); onImgLoad();
}} }}
/> />
{!playingBack && (
<div className="absolute left-0 top-2 z-40"> <div
className={cn(
"rounded-t-l pointer-events-none absolute inset-x-0 top-0 h-[30%] w-full bg-gradient-to-b from-black/60 to-transparent",
!isIOS && "z-10",
)}
/>
)}
<div className={cn("absolute left-0 top-2", !isIOS && "z-40")}>
<Tooltip> <Tooltip>
<div <div
className="flex" className="flex"
@@ -273,21 +284,23 @@ export default function PreviewThumbnailPlayer({
</Tooltip> </Tooltip>
</div> </div>
{!playingBack && ( {!playingBack && (
<> <div
<div className="rounded-t-l pointer-events-none absolute inset-x-0 top-0 z-10 h-[30%] w-full bg-gradient-to-b from-black/60 to-transparent"></div> className={cn(
<div className="rounded-b-l pointer-events-none absolute inset-x-0 bottom-0 z-10 h-[20%] w-full bg-gradient-to-t from-black/60 to-transparent"> "rounded-b-l pointer-events-none absolute inset-x-0 bottom-0 h-[20%] w-full bg-gradient-to-t from-black/60 to-transparent",
<div className="mx-3 flex h-full items-end justify-between pb-1 text-sm text-white"> !isIOS && "z-10",
{review.end_time ? ( )}
<TimeAgo time={review.start_time * 1000} dense /> >
) : ( <div className="mx-3 flex h-full items-end justify-between pb-1 text-sm text-white">
<div> {review.end_time ? (
<ActivityIndicator size={24} /> <TimeAgo time={review.start_time * 1000} dense />
</div> ) : (
)} <div>
{formattedDate} <ActivityIndicator size={24} />
</div> </div>
)}
{formattedDate}
</div> </div>
</> </div>
)} )}
</div> </div>
</div> </div>

View File

@@ -1,5 +1,5 @@
import { useCallback, useMemo, useRef, useState } from "react"; import { useCallback, useMemo, useRef, useState } from "react";
import { isMobileOnly, isSafari } from "react-device-detect"; import { isDesktop, isMobileOnly, isSafari } from "react-device-detect";
import { LuPause, LuPlay } from "react-icons/lu"; import { LuPause, LuPlay } from "react-icons/lu";
import { import {
DropdownMenu, DropdownMenu,
@@ -16,7 +16,9 @@ import {
MdVolumeOff, MdVolumeOff,
MdVolumeUp, MdVolumeUp,
} from "react-icons/md"; } from "react-icons/md";
import useKeyboardListener from "@/hooks/use-keyboard-listener"; import useKeyboardListener, {
KeyModifiers,
} from "@/hooks/use-keyboard-listener";
import { VolumeSlider } from "../ui/slider"; import { VolumeSlider } from "../ui/slider";
import FrigatePlusIcon from "../icons/FrigatePlusIcon"; import FrigatePlusIcon from "../icons/FrigatePlusIcon";
import { import {
@@ -69,6 +71,7 @@ type VideoControlsProps = {
onSetPlaybackRate: (rate: number) => void; onSetPlaybackRate: (rate: number) => void;
onUploadFrame?: () => void; onUploadFrame?: () => void;
toggleFullscreen?: () => void; toggleFullscreen?: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
}; };
export default function VideoControls({ export default function VideoControls({
className, className,
@@ -89,10 +92,11 @@ export default function VideoControls({
onSetPlaybackRate, onSetPlaybackRate,
onUploadFrame, onUploadFrame,
toggleFullscreen, toggleFullscreen,
containerRef,
}: VideoControlsProps) { }: VideoControlsProps) {
// layout // layout
const containerRef = useRef<HTMLDivElement | null>(null); const controlsContainerRef = useRef<HTMLDivElement | null>(null);
// controls // controls
@@ -137,42 +141,36 @@ export default function VideoControls({
}, [volume, muted]); }, [volume, muted]);
const onKeyboardShortcut = useCallback( const onKeyboardShortcut = useCallback(
(key: string, down: boolean, repeat: boolean) => { (key: string, modifiers: KeyModifiers) => {
if (!modifiers.down) {
return;
}
switch (key) { switch (key) {
case "ArrowDown": case "ArrowDown":
if (down) { onSeek(-1);
onSeek(-1);
}
break; break;
case "ArrowLeft": case "ArrowLeft":
if (down) { onSeek(-10);
onSeek(-10);
}
break; break;
case "ArrowRight": case "ArrowRight":
if (down) { onSeek(10);
onSeek(10);
}
break; break;
case "ArrowUp": case "ArrowUp":
if (down) { onSeek(1);
onSeek(1);
}
break; break;
case "f": case "f":
if (toggleFullscreen && down && !repeat) { if (toggleFullscreen && !modifiers.repeat) {
toggleFullscreen(); toggleFullscreen();
} }
break; break;
case "m": case "m":
if (setMuted && down && !repeat && video) { if (setMuted && !modifiers.repeat && video) {
setMuted(!muted); setMuted(!muted);
} }
break; break;
case " ": case " ":
if (down) { onPlayPause(!isPlaying);
onPlayPause(!isPlaying);
}
break; break;
} }
}, },
@@ -201,7 +199,7 @@ export default function VideoControls({
MIN_ITEMS_WRAP && MIN_ITEMS_WRAP &&
"min-w-[75%] flex-wrap", "min-w-[75%] flex-wrap",
)} )}
ref={containerRef} ref={controlsContainerRef}
> >
{video && features.volume && ( {video && features.volume && (
<div className="flex cursor-pointer items-center justify-normal gap-2"> <div className="flex cursor-pointer items-center justify-normal gap-2">
@@ -242,7 +240,7 @@ export default function VideoControls({
)} )}
{features.playbackRate && ( {features.playbackRate && (
<DropdownMenu <DropdownMenu
modal={false} modal={!isDesktop}
onOpenChange={(open) => { onOpenChange={(open) => {
if (setControlsOpen) { if (setControlsOpen) {
setControlsOpen(open); setControlsOpen(open);
@@ -251,7 +249,7 @@ export default function VideoControls({
> >
<DropdownMenuTrigger>{`${playbackRate}x`}</DropdownMenuTrigger> <DropdownMenuTrigger>{`${playbackRate}x`}</DropdownMenuTrigger>
<DropdownMenuContent <DropdownMenuContent
portalProps={{ container: containerRef.current }} portalProps={{ container: controlsContainerRef.current }}
> >
<DropdownMenuRadioGroup <DropdownMenuRadioGroup
onValueChange={(rate) => onSetPlaybackRate(parseFloat(rate))} onValueChange={(rate) => onSetPlaybackRate(parseFloat(rate))}
@@ -285,6 +283,7 @@ export default function VideoControls({
} }
}} }}
onUploadFrame={onUploadFrame} onUploadFrame={onUploadFrame}
containerRef={containerRef}
/> />
)} )}
{features.fullscreen && toggleFullscreen && ( {features.fullscreen && toggleFullscreen && (
@@ -301,12 +300,14 @@ type FrigatePlusUploadButtonProps = {
onOpen: () => void; onOpen: () => void;
onClose: () => void; onClose: () => void;
onUploadFrame: () => void; onUploadFrame: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
}; };
function FrigatePlusUploadButton({ function FrigatePlusUploadButton({
video, video,
onOpen, onOpen,
onClose, onClose,
onUploadFrame, onUploadFrame,
containerRef,
}: FrigatePlusUploadButtonProps) { }: FrigatePlusUploadButtonProps) {
const [videoImg, setVideoImg] = useState<string>(); const [videoImg, setVideoImg] = useState<string>();
@@ -340,7 +341,10 @@ function FrigatePlusUploadButton({
}} }}
/> />
</AlertDialogTrigger> </AlertDialogTrigger>
<AlertDialogContent className="md:max-w-2xl lg:max-w-3xl xl:max-w-4xl"> <AlertDialogContent
portalProps={{ container: containerRef?.current }}
className="md:max-w-2xl lg:max-w-3xl xl:max-w-4xl"
>
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle>Submit this frame to Frigate+?</AlertDialogTitle> <AlertDialogTitle>Submit this frame to Frigate+?</AlertDialogTitle>
</AlertDialogHeader> </AlertDialogHeader>

View File

@@ -30,6 +30,7 @@ type DynamicVideoPlayerProps = {
onClipEnded?: () => void; onClipEnded?: () => void;
setFullResolution: React.Dispatch<React.SetStateAction<VideoResolutionType>>; setFullResolution: React.Dispatch<React.SetStateAction<VideoResolutionType>>;
toggleFullscreen: () => void; toggleFullscreen: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
}; };
export default function DynamicVideoPlayer({ export default function DynamicVideoPlayer({
className, className,
@@ -45,6 +46,7 @@ export default function DynamicVideoPlayer({
onClipEnded, onClipEnded,
setFullResolution, setFullResolution,
toggleFullscreen, toggleFullscreen,
containerRef,
}: DynamicVideoPlayerProps) { }: DynamicVideoPlayerProps) {
const apiHost = useApiHost(); const apiHost = useApiHost();
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
@@ -202,12 +204,12 @@ export default function DynamicVideoPlayer({
clearTimeout(loadingTimeout); clearTimeout(loadingTimeout);
} }
setIsLoading(false);
setNoRecording(false); setNoRecording(false);
}} }}
setFullResolution={setFullResolution} setFullResolution={setFullResolution}
onUploadFrame={onUploadFrameToPlus} onUploadFrame={onUploadFrameToPlus}
toggleFullscreen={toggleFullscreen} toggleFullscreen={toggleFullscreen}
containerRef={containerRef}
/> />
<PreviewPlayer <PreviewPlayer
className={cn( className={cn(

View File

@@ -5,6 +5,7 @@ import Konva from "konva";
import type { KonvaEventObject } from "konva/lib/Node"; import type { KonvaEventObject } from "konva/lib/Node";
import { Polygon, PolygonType } from "@/types/canvas"; import { Polygon, PolygonType } from "@/types/canvas";
import { useApiHost } from "@/api"; import { useApiHost } from "@/api";
import ActivityIndicator from "@/components/indicators/activity-indicator";
type PolygonCanvasProps = { type PolygonCanvasProps = {
containerRef: RefObject<HTMLDivElement>; containerRef: RefObject<HTMLDivElement>;
@@ -29,6 +30,7 @@ export function PolygonCanvas({
hoveredPolygonIndex, hoveredPolygonIndex,
selectedZoneMask, selectedZoneMask,
}: PolygonCanvasProps) { }: PolygonCanvasProps) {
const [isLoaded, setIsLoaded] = useState(false);
const [image, setImage] = useState<HTMLImageElement | undefined>(); const [image, setImage] = useState<HTMLImageElement | undefined>();
const imageRef = useRef<Konva.Image | null>(null); const imageRef = useRef<Konva.Image | null>(null);
const stageRef = useRef<Konva.Stage>(null); const stageRef = useRef<Konva.Stage>(null);
@@ -36,13 +38,16 @@ export function PolygonCanvas({
const videoElement = useMemo(() => { const videoElement = useMemo(() => {
if (camera && width && height) { if (camera && width && height) {
setIsLoaded(false);
const element = new window.Image(); const element = new window.Image();
element.width = width; element.width = width;
element.height = height; element.height = height;
element.src = `${apiHost}api/${camera}/latest.jpg`; element.src = `${apiHost}api/${camera}/latest.webp?cache=${Date.now()}`;
return element; return element;
} }
}, [camera, width, height, apiHost]); // we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [camera, apiHost]);
useEffect(() => { useEffect(() => {
if (!videoElement) { if (!videoElement) {
@@ -50,6 +55,7 @@ export function PolygonCanvas({
} }
const onload = function () { const onload = function () {
setImage(videoElement); setImage(videoElement);
setIsLoaded(true);
}; };
videoElement.addEventListener("load", onload); videoElement.addEventListener("load", onload);
return () => { return () => {
@@ -218,6 +224,10 @@ export function PolygonCanvas({
} }
}, [activePolygonIndex, polygons, setPolygons]); }, [activePolygonIndex, polygons, setPolygons]);
if (!isLoaded) {
return <ActivityIndicator />;
}
return ( return (
<Stage <Stage
ref={stageRef} ref={stageRef}

View File

@@ -131,10 +131,18 @@ export default function PolygonDrawer({
closed={isFinished} closed={isFinished}
fill={colorString(isActive || isHovered ? true : false)} fill={colorString(isActive || isHovered ? true : false)}
onMouseOver={() => onMouseOver={() =>
isFinished ? setCursor("move") : setCursor("crosshair") isActive
? isFinished
? setCursor("move")
: setCursor("crosshair")
: setCursor("default")
} }
onMouseOut={() => onMouseOut={() =>
isFinished ? setCursor("default") : setCursor("crosshair") isActive
? isFinished
? setCursor("default")
: setCursor("crosshair")
: setCursor("default")
} }
/> />
{isFinished && isActive && ( {isFinished && isActive && (

View File

@@ -19,7 +19,7 @@ import { LuCopy, LuPencil } from "react-icons/lu";
import { FaDrawPolygon, FaObjectGroup } from "react-icons/fa"; import { FaDrawPolygon, FaObjectGroup } from "react-icons/fa";
import { BsPersonBoundingBox } from "react-icons/bs"; import { BsPersonBoundingBox } from "react-icons/bs";
import { HiOutlineDotsVertical, HiTrash } from "react-icons/hi"; import { HiOutlineDotsVertical, HiTrash } from "react-icons/hi";
import { isMobile } from "react-device-detect"; import { isDesktop, isMobile } from "react-device-detect";
import { import {
flattenPoints, flattenPoints,
parseCoordinates, parseCoordinates,
@@ -266,7 +266,7 @@ export default function PolygonItem({
{isMobile && ( {isMobile && (
<> <>
<DropdownMenu modal={false}> <DropdownMenu modal={!isDesktop}>
<DropdownMenuTrigger> <DropdownMenuTrigger>
<HiOutlineDotsVertical className="size-5" /> <HiOutlineDotsVertical className="size-5" />
</DropdownMenuTrigger> </DropdownMenuTrigger>

View File

@@ -143,20 +143,6 @@ export default function ZoneEditPane({
config?.cameras[polygon.camera]?.zones[polygon.name]?.loitering_time, config?.cameras[polygon.camera]?.zones[polygon.name]?.loitering_time,
isFinished: polygon?.isFinished ?? false, isFinished: polygon?.isFinished ?? false,
objects: polygon?.objects ?? [], objects: polygon?.objects ?? [],
review_alerts:
(polygon?.camera &&
polygon?.name &&
config?.cameras[
polygon.camera
]?.review.alerts.required_zones.includes(polygon.name)) ||
false,
review_detections:
(polygon?.camera &&
polygon?.name &&
config?.cameras[
polygon.camera
]?.review.detections.required_zones.includes(polygon.name)) ||
false,
}, },
}); });
@@ -167,8 +153,6 @@ export default function ZoneEditPane({
inertia, inertia,
loitering_time, loitering_time,
objects: form_objects, objects: form_objects,
review_alerts,
review_detections,
}: ZoneFormValuesType, // values submitted via the form }: ZoneFormValuesType, // values submitted via the form
objects: string[], objects: string[],
) => { ) => {
@@ -176,11 +160,21 @@ export default function ZoneEditPane({
return; return;
} }
let mutatedConfig = config; let mutatedConfig = config;
let alertQueries = "";
let detectionQueries = "";
const renamingZone = zoneName != polygon.name && polygon.name != ""; const renamingZone = zoneName != polygon.name && polygon.name != "";
if (renamingZone) { if (renamingZone) {
// rename - delete old zone and replace with new // rename - delete old zone and replace with new
const zoneInAlerts =
cameraConfig?.review.alerts.required_zones.includes(polygon.name) ??
false;
const zoneInDetections =
cameraConfig?.review.detections.required_zones.includes(
polygon.name,
) ?? false;
const { const {
alertQueries: renameAlertQueries, alertQueries: renameAlertQueries,
detectionQueries: renameDetectionQueries, detectionQueries: renameDetectionQueries,
@@ -209,6 +203,18 @@ export default function ZoneEditPane({
}); });
return; return;
} }
// make sure new zone name is readded to review
({ alertQueries, detectionQueries } = reviewQueries(
zoneName,
zoneInAlerts,
zoneInDetections,
polygon.camera,
mutatedConfig?.cameras[polygon.camera]?.review.alerts
.required_zones || [],
mutatedConfig?.cameras[polygon.camera]?.review.detections
.required_zones || [],
));
} }
const coordinates = flattenPoints( const coordinates = flattenPoints(
@@ -233,17 +239,6 @@ export default function ZoneEditPane({
objectQueries = `&cameras.${polygon?.camera}.zones.${zoneName}.objects`; objectQueries = `&cameras.${polygon?.camera}.zones.${zoneName}.objects`;
} }
const { alertQueries, detectionQueries } = reviewQueries(
zoneName,
review_alerts,
review_detections,
polygon.camera,
mutatedConfig?.cameras[polygon.camera]?.review.alerts.required_zones ||
[],
mutatedConfig?.cameras[polygon.camera]?.review.detections
.required_zones || [],
);
let inertiaQuery = ""; let inertiaQuery = "";
if (inertia) { if (inertia) {
inertiaQuery = `&cameras.${polygon?.camera}.zones.${zoneName}.inertia=${inertia}`; inertiaQuery = `&cameras.${polygon?.camera}.zones.${zoneName}.inertia=${inertia}`;
@@ -449,52 +444,6 @@ export default function ZoneEditPane({
/> />
</FormItem> </FormItem>
<Separator className="my-2 flex bg-secondary" />
<FormField
control={form.control}
name="review_alerts"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between">
<div className="space-y-0.5">
<FormLabel>Alerts</FormLabel>
<FormDescription>
When an object enters this zone, ensure it is marked as an
alert.
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
className="ml-3"
/>
</FormControl>
</FormItem>
)}
/>
<FormField
control={form.control}
name="review_detections"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between">
<div className="space-y-0.5">
<FormLabel className="text-base">Detections</FormLabel>
<FormDescription>
When an object enters this zone, ensure it is marked as a
detection.
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
className="ml-3"
/>
</FormControl>
</FormItem>
)}
/>
<FormField <FormField
control={form.control} control={form.control}
name="isFinished" name="isFinished"

View File

@@ -8,6 +8,7 @@ import React, {
useEffect, useEffect,
useMemo, useMemo,
useRef, useRef,
useState,
} from "react"; } from "react";
import { import {
HoverCard, HoverCard,
@@ -151,7 +152,7 @@ export function EventSegment({
: "" : ""
} ${ } ${
isFirstSegmentInMinimap || isLastSegmentInMinimap isFirstSegmentInMinimap || isLastSegmentInMinimap
? "relative h-[8px] border-b-2 border-neutral-600" ? "relative h-[8px] border-b-2 border-neutral_variant"
: "" : ""
}`; }`;
@@ -195,9 +196,48 @@ export function EventSegment({
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [startTimestamp]); }, [startTimestamp]);
const [segmentRendered, setSegmentRendered] = useState(false);
const segmentObserverRef = useRef<IntersectionObserver | null>(null);
const segmentRef = useRef(null);
useEffect(() => {
const segmentObserver = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting && !segmentRendered) {
setSegmentRendered(true);
}
},
{ threshold: 0 },
);
if (segmentRef.current) {
segmentObserver.observe(segmentRef.current);
}
segmentObserverRef.current = segmentObserver;
return () => {
if (segmentObserverRef.current) {
segmentObserverRef.current.disconnect();
}
};
}, [segmentRendered]);
if (!segmentRendered) {
return (
<div
key={segmentKey}
ref={segmentRef}
data-segment-id={segmentKey}
className={`segment ${segmentClasses}`}
/>
);
}
return ( return (
<div <div
key={segmentKey} key={segmentKey}
ref={segmentRef}
data-segment-id={segmentKey} data-segment-id={segmentKey}
className={`segment ${segmentClasses}`} className={`segment ${segmentClasses}`}
onClick={segmentClick} onClick={segmentClick}

View File

@@ -1,9 +1,8 @@
import { useEffect, useCallback, useMemo, useRef, RefObject } from "react"; import { useCallback, useMemo, useRef, RefObject } from "react";
import MotionSegment from "./MotionSegment"; import MotionSegment from "./MotionSegment";
import { useTimelineUtils } from "@/hooks/use-timeline-utils"; import { useTimelineUtils } from "@/hooks/use-timeline-utils";
import { MotionData, ReviewSegment, ReviewSeverity } from "@/types/review"; import { MotionData, ReviewSegment, ReviewSeverity } from "@/types/review";
import ReviewTimeline from "./ReviewTimeline"; import ReviewTimeline from "./ReviewTimeline";
import { isDesktop } from "react-device-detect";
import { useMotionSegmentUtils } from "@/hooks/use-motion-segment-utils"; import { useMotionSegmentUtils } from "@/hooks/use-motion-segment-utils";
export type MotionReviewTimelineProps = { export type MotionReviewTimelineProps = {
@@ -165,42 +164,6 @@ export function MotionReviewTimeline({
], ],
); );
const segmentsObserver = useRef<IntersectionObserver | null>(null);
useEffect(() => {
if (selectedTimelineRef.current && segments && isDesktop) {
segmentsObserver.current = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const segmentId = entry.target.getAttribute("data-segment-id");
const segmentElements =
internalTimelineRef.current?.querySelectorAll(
`[data-segment-id="${segmentId}"] .motion-segment`,
);
segmentElements?.forEach((segmentElement) => {
segmentElement.classList.remove("hidden");
segmentElement.classList.add("animate-in");
});
}
});
},
{ threshold: 0 },
);
// Get all segment divs and observe each one
const segmentDivs =
selectedTimelineRef.current.querySelectorAll(".segment.has-data");
segmentDivs.forEach((segmentDiv) => {
segmentsObserver.current?.observe(segmentDiv);
});
}
return () => {
segmentsObserver.current?.disconnect();
};
}, [selectedTimelineRef, segments]);
return ( return (
<ReviewTimeline <ReviewTimeline
timelineRef={selectedTimelineRef} timelineRef={selectedTimelineRef}

View File

@@ -1,11 +1,17 @@
import { useTimelineUtils } from "@/hooks/use-timeline-utils"; import { useTimelineUtils } from "@/hooks/use-timeline-utils";
import { useEventSegmentUtils } from "@/hooks/use-event-segment-utils"; import { useEventSegmentUtils } from "@/hooks/use-event-segment-utils";
import { ReviewSegment } from "@/types/review"; import { ReviewSegment } from "@/types/review";
import React, { useCallback, useEffect, useMemo, useRef } from "react"; import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import scrollIntoView from "scroll-into-view-if-needed"; import scrollIntoView from "scroll-into-view-if-needed";
import { MinimapBounds, Tick, Timestamp } from "./segment-metadata"; import { MinimapBounds, Tick, Timestamp } from "./segment-metadata";
import { useMotionSegmentUtils } from "@/hooks/use-motion-segment-utils"; import { useMotionSegmentUtils } from "@/hooks/use-motion-segment-utils";
import { isDesktop, isMobile } from "react-device-detect"; import { isMobile } from "react-device-detect";
import useTapUtils from "@/hooks/use-tap-utils"; import useTapUtils from "@/hooks/use-tap-utils";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
@@ -139,11 +145,6 @@ export function MotionSegment({
: "" : ""
}`; }`;
const animationClassesSecondHalf = `motion-segment ${secondHalfSegmentWidth > 0 ? "hidden" : ""}
zoom-in-[0.2] ${secondHalfSegmentWidth < 5 ? "duration-200" : "duration-1000"}`;
const animationClassesFirstHalf = `motion-segment ${firstHalfSegmentWidth > 0 ? "hidden" : ""}
zoom-in-[0.2] ${firstHalfSegmentWidth < 5 ? "duration-200" : "duration-1000"}`;
const severityColorsBg: { [key: number]: string } = { const severityColorsBg: { [key: number]: string } = {
1: reviewed 1: reviewed
? "from-severity_significant_motion-dimmed/10 to-severity_significant_motion/10" ? "from-severity_significant_motion-dimmed/10 to-severity_significant_motion/10"
@@ -162,6 +163,44 @@ export function MotionSegment({
} }
}, [segmentTime, setHandlebarTime]); }, [segmentTime, setHandlebarTime]);
const [segmentRendered, setSegmentRendered] = useState(false);
const segmentObserverRef = useRef<IntersectionObserver | null>(null);
const segmentRef = useRef(null);
useEffect(() => {
const segmentObserver = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting && !segmentRendered) {
setSegmentRendered(true);
}
},
{ threshold: 0 },
);
if (segmentRef.current) {
segmentObserver.observe(segmentRef.current);
}
segmentObserverRef.current = segmentObserver;
return () => {
if (segmentObserverRef.current) {
segmentObserverRef.current.disconnect();
}
};
}, [segmentRendered]);
if (!segmentRendered) {
return (
<div
key={segmentKey}
ref={segmentRef}
data-segment-id={segmentKey}
className={`segment ${segmentClasses}`}
/>
);
}
return ( return (
<> <>
{(((firstHalfSegmentWidth > 0 || secondHalfSegmentWidth > 0) && {(((firstHalfSegmentWidth > 0 || secondHalfSegmentWidth > 0) &&
@@ -171,6 +210,7 @@ export function MotionSegment({
<div <div
key={segmentKey} key={segmentKey}
data-segment-id={segmentKey} data-segment-id={segmentKey}
ref={segmentRef}
className={cn( className={cn(
"segment", "segment",
{ {
@@ -221,7 +261,6 @@ export function MotionSegment({
key={`${segmentKey}_motion_data_1`} key={`${segmentKey}_motion_data_1`}
data-motion-value={secondHalfSegmentWidth} data-motion-value={secondHalfSegmentWidth}
className={cn( className={cn(
isDesktop && animationClassesSecondHalf,
"h-[2px]", "h-[2px]",
"rounded-full", "rounded-full",
secondHalfSegmentWidth secondHalfSegmentWidth
@@ -241,7 +280,6 @@ export function MotionSegment({
key={`${segmentKey}_motion_data_2`} key={`${segmentKey}_motion_data_2`}
data-motion-value={firstHalfSegmentWidth} data-motion-value={firstHalfSegmentWidth}
className={cn( className={cn(
isDesktop && animationClassesFirstHalf,
"h-[2px]", "h-[2px]",
"rounded-full", "rounded-full",
firstHalfSegmentWidth firstHalfSegmentWidth

View File

@@ -71,11 +71,11 @@ export function Tick({ timestamp, timestampSpread }: TickSegmentProps) {
className={`pointer-events-none h-0.5 select-none ${ className={`pointer-events-none h-0.5 select-none ${
timestamp.getMinutes() % timestampSpread === 0 && timestamp.getMinutes() % timestampSpread === 0 &&
timestamp.getSeconds() === 0 timestamp.getSeconds() === 0
? "w-[12px] bg-neutral-600 dark:bg-neutral-500" ? "w-[12px] bg-neutral_variant dark:bg-neutral"
: timestamp.getMinutes() % (timestampSpread == 15 ? 5 : 1) === : timestamp.getMinutes() % (timestampSpread == 15 ? 5 : 1) ===
0 && timestamp.getSeconds() === 0 0 && timestamp.getSeconds() === 0
? "w-[8px] bg-neutral-500" // Minor tick mark ? "w-[8px] bg-neutral" // Minor tick mark
: "w-[5px] bg-neutral-400 dark:bg-neutral-600" : "w-[5px] bg-neutral-400 dark:bg-neutral_variant"
}`} }`}
></div> ></div>
</div> </div>
@@ -97,7 +97,7 @@ export function Timestamp({
{!isFirstSegmentInMinimap && !isLastSegmentInMinimap && ( {!isFirstSegmentInMinimap && !isLastSegmentInMinimap && (
<div <div
key={`${segmentKey}_timestamp`} key={`${segmentKey}_timestamp`}
className="pointer-events-none select-none text-[8px] text-neutral-600 dark:text-neutral-500" className="pointer-events-none select-none text-[8px] text-neutral_variant dark:text-neutral"
> >
{timestamp.getMinutes() % timestampSpread === 0 && {timestamp.getMinutes() % timestampSpread === 0 &&
timestamp.getSeconds() === 0 && timestamp.getSeconds() === 0 &&

View File

@@ -1,14 +1,14 @@
import * as React from "react" import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button" import { buttonVariants } from "@/components/ui/button";
const AlertDialog = AlertDialogPrimitive.Root const AlertDialog = AlertDialogPrimitive.Root;
const AlertDialogTrigger = AlertDialogPrimitive.Trigger const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
const AlertDialogPortal = AlertDialogPrimitive.Portal const AlertDialogPortal = AlertDialogPrimitive.Portal;
const AlertDialogOverlay = React.forwardRef< const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>, React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
@@ -17,31 +17,33 @@ const AlertDialogOverlay = React.forwardRef<
<AlertDialogPrimitive.Overlay <AlertDialogPrimitive.Overlay
className={cn( className={cn(
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className className,
)} )}
{...props} {...props}
ref={ref} ref={ref}
/> />
)) ));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
const AlertDialogContent = React.forwardRef< const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>, React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> & {
>(({ className, ...props }, ref) => ( portalProps?: AlertDialogPrimitive.AlertDialogPortalProps;
<AlertDialogPortal> }
>(({ className, portalProps, ...props }, ref) => (
<AlertDialogPortal {...portalProps}>
<AlertDialogOverlay /> <AlertDialogOverlay />
<AlertDialogPrimitive.Content <AlertDialogPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg", "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className className,
)} )}
{...props} {...props}
/> />
</AlertDialogPortal> </AlertDialogPortal>
)) ));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
const AlertDialogHeader = ({ const AlertDialogHeader = ({
className, className,
@@ -50,12 +52,12 @@ const AlertDialogHeader = ({
<div <div
className={cn( className={cn(
"flex flex-col space-y-2 text-center sm:text-left", "flex flex-col space-y-2 text-center sm:text-left",
className className,
)} )}
{...props} {...props}
/> />
) );
AlertDialogHeader.displayName = "AlertDialogHeader" AlertDialogHeader.displayName = "AlertDialogHeader";
const AlertDialogFooter = ({ const AlertDialogFooter = ({
className, className,
@@ -64,12 +66,12 @@ const AlertDialogFooter = ({
<div <div
className={cn( className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className className,
)} )}
{...props} {...props}
/> />
) );
AlertDialogFooter.displayName = "AlertDialogFooter" AlertDialogFooter.displayName = "AlertDialogFooter";
const AlertDialogTitle = React.forwardRef< const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>, React.ElementRef<typeof AlertDialogPrimitive.Title>,
@@ -80,8 +82,8 @@ const AlertDialogTitle = React.forwardRef<
className={cn("text-lg font-semibold", className)} className={cn("text-lg font-semibold", className)}
{...props} {...props}
/> />
)) ));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
const AlertDialogDescription = React.forwardRef< const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>, React.ElementRef<typeof AlertDialogPrimitive.Description>,
@@ -92,9 +94,9 @@ const AlertDialogDescription = React.forwardRef<
className={cn("text-sm text-muted-foreground", className)} className={cn("text-sm text-muted-foreground", className)}
{...props} {...props}
/> />
)) ));
AlertDialogDescription.displayName = AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName AlertDialogPrimitive.Description.displayName;
const AlertDialogAction = React.forwardRef< const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>, React.ElementRef<typeof AlertDialogPrimitive.Action>,
@@ -105,8 +107,8 @@ const AlertDialogAction = React.forwardRef<
className={cn(buttonVariants(), className)} className={cn(buttonVariants(), className)}
{...props} {...props}
/> />
)) ));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
const AlertDialogCancel = React.forwardRef< const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>, React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
@@ -117,12 +119,12 @@ const AlertDialogCancel = React.forwardRef<
className={cn( className={cn(
buttonVariants({ variant: "outline" }), buttonVariants({ variant: "outline" }),
"mt-2 sm:mt-0", "mt-2 sm:mt-0",
className className,
)} )}
{...props} {...props}
/> />
)) ));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
export { export {
AlertDialog, AlertDialog,
@@ -136,4 +138,4 @@ export {
AlertDialogDescription, AlertDialogDescription,
AlertDialogAction, AlertDialogAction,
AlertDialogCancel, AlertDialogCancel,
} };

View File

@@ -0,0 +1,28 @@
import * as React from "react"
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { Check } from "lucide-react"
import { cn } from "@/lib/utils"
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName
export { Checkbox }

View File

@@ -3,25 +3,19 @@ import { createContext, useContext, useEffect, useMemo, useState } from "react";
type Theme = "dark" | "light" | "system"; type Theme = "dark" | "light" | "system";
type ColorScheme = type ColorScheme =
| "theme-blue" | "theme-blue"
| "theme-gold"
| "theme-green" | "theme-green"
| "theme-nature"
| "theme-netflix"
| "theme-nord" | "theme-nord"
| "theme-orange"
| "theme-red" | "theme-red"
| "theme-high-contrast"
| "theme-default"; | "theme-default";
// eslint-disable-next-line react-refresh/only-export-components // eslint-disable-next-line react-refresh/only-export-components
export const colorSchemes: ColorScheme[] = [ export const colorSchemes: ColorScheme[] = [
"theme-blue", "theme-blue",
"theme-gold",
"theme-green", "theme-green",
"theme-nature",
"theme-netflix",
"theme-nord", "theme-nord",
"theme-orange",
"theme-red", "theme-red",
"theme-high-contrast",
"theme-default", "theme-default",
]; ];

View File

@@ -27,13 +27,10 @@ export function useCameraActivity(
// init camera activity // init camera activity
const { payload: initialCameraState } = useInitialCameraState( const { payload: updatedCameraState } = useInitialCameraState(
camera.name, camera.name,
revalidateOnFocus, revalidateOnFocus,
); );
const updatedCameraState = useDeepMemo(initialCameraState);
useEffect(() => { useEffect(() => {
if (updatedCameraState) { if (updatedCameraState) {
setObjects(updatedCameraState.objects); setObjects(updatedCameraState.objects);
@@ -133,14 +130,14 @@ export function useCameraActivity(
return false; return false;
} }
return cameras[camera.name].camera_fps == 0; return cameras[camera.name].camera_fps == 0 && stats["service"].uptime > 60;
}, [camera, stats]); }, [camera, stats]);
return { return {
activeTracking: hasActiveObjects, activeTracking: hasActiveObjects,
activeMotion: detectingMotion activeMotion: detectingMotion
? detectingMotion === "ON" ? detectingMotion === "ON"
: initialCameraState?.motion === true, : updatedCameraState?.motion === true,
objects, objects,
offline, offline,
}; };

View File

@@ -1,8 +1,14 @@
import { useCallback, useEffect } from "react"; import { useCallback, useEffect } from "react";
export type KeyModifiers = {
down: boolean;
repeat: boolean;
ctrl: boolean;
};
export default function useKeyboardListener( export default function useKeyboardListener(
keys: string[], keys: string[],
listener: (key: string, down: boolean, repeat: boolean) => void, listener: (key: string, modifiers: KeyModifiers) => void,
) { ) {
const keyDownListener = useCallback( const keyDownListener = useCallback(
(e: KeyboardEvent) => { (e: KeyboardEvent) => {
@@ -12,7 +18,11 @@ export default function useKeyboardListener(
if (keys.includes(e.key)) { if (keys.includes(e.key)) {
e.preventDefault(); e.preventDefault();
listener(e.key, true, e.repeat); listener(e.key, {
down: true,
repeat: e.repeat,
ctrl: e.ctrlKey || e.metaKey,
});
} }
}, },
[keys, listener], [keys, listener],
@@ -26,7 +36,7 @@ export default function useKeyboardListener(
if (keys.includes(e.key)) { if (keys.includes(e.key)) {
e.preventDefault(); e.preventDefault();
listener(e.key, false, false); listener(e.key, { down: false, repeat: false, ctrl: false });
} }
}, },
[keys, listener], [keys, listener],

View File

@@ -97,7 +97,7 @@ export function useAutoFrigateStats() {
const { data: initialStats } = useSWR<FrigateStats>("stats", { const { data: initialStats } = useSWR<FrigateStats>("stats", {
revalidateOnFocus: false, revalidateOnFocus: false,
}); });
const { payload: latestStats } = useFrigateStats(); const latestStats = useFrigateStats();
const stats = useMemo(() => { const stats = useMemo(() => {
if (latestStats) { if (latestStats) {

View File

@@ -1,12 +1,9 @@
@import "/themes/tailwind-base.css"; @import "/themes/tailwind-base.css";
@import "/themes/theme-default.css"; @import "/themes/theme-default.css";
@import "/themes/theme-blue.css"; @import "/themes/theme-blue.css";
@import "/themes/theme-gold.css";
@import "/themes/theme-green.css"; @import "/themes/theme-green.css";
@import "/themes/theme-nature.css"; @import "/themes/theme-high-contrast.css";
@import "/themes/theme-netflix.css";
@import "/themes/theme-nord.css"; @import "/themes/theme-nord.css";
@import "/themes/theme-orange.css";
@import "/themes/theme-red.css"; @import "/themes/theme-red.css";
@tailwind base; @tailwind base;
@@ -26,10 +23,14 @@
@layer utilities { @layer utilities {
.scrollbar-container { .scrollbar-container {
@apply scrollbar-thumb-rounded-full scrollbar-track-rounded-full scrollbar-thin scrollbar-thumb-border scrollbar-track-background_alt; @apply scrollbar-thin scrollbar-track-background_alt scrollbar-thumb-border scrollbar-track-rounded-full scrollbar-thumb-rounded-full;
} }
} }
html {
overscroll-behavior: none;
}
/* Hide scrollbar for Chrome, Safari and Opera */ /* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar { .no-scrollbar::-webkit-scrollbar {
display: none; display: none;

View File

@@ -15,6 +15,7 @@ import { Input } from "@/components/ui/input";
import { DeleteClipType, Export } from "@/types/export"; import { DeleteClipType, Export } from "@/types/export";
import axios from "axios"; import axios from "axios";
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { LuFolderX } from "react-icons/lu";
import useSWR from "swr"; import useSWR from "swr";
function Exports() { function Exports() {
@@ -128,17 +129,19 @@ function Exports() {
</DialogContent> </DialogContent>
</Dialog> </Dialog>
<div className="flex w-full items-center justify-center p-2"> {exports && (
<Input <div className="flex w-full items-center justify-center p-2">
className="w-full bg-muted md:w-1/3" <Input
placeholder="Search" className="w-full bg-muted md:w-1/3"
value={search} placeholder="Search"
onChange={(e) => setSearch(e.target.value)} value={search}
/> onChange={(e) => setSearch(e.target.value)}
</div> />
</div>
)}
<div className="w-full overflow-hidden"> <div className="w-full overflow-hidden">
{exports && filteredExports && ( {exports && filteredExports && filteredExports.length > 0 ? (
<div className="scrollbar-container grid size-full gap-2 overflow-y-auto sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"> <div className="scrollbar-container grid size-full gap-2 overflow-y-auto sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{Object.values(exports).map((item) => ( {Object.values(exports).map((item) => (
<ExportCard <ExportCard
@@ -155,6 +158,11 @@ function Exports() {
/> />
))} ))}
</div> </div>
) : (
<div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center text-center">
<LuFolderX className="size-16" />
No exports found
</div>
)} )}
</div> </div>
</div> </div>

View File

@@ -2,6 +2,7 @@ import { useFullscreen } from "@/hooks/use-fullscreen";
import { import {
useHashState, useHashState,
usePersistedOverlayState, usePersistedOverlayState,
useSearchEffect,
} from "@/hooks/use-overlay-state"; } from "@/hooks/use-overlay-state";
import { FrigateConfig } from "@/types/frigateConfig"; import { FrigateConfig } from "@/types/frigateConfig";
import LiveBirdseyeView from "@/views/live/LiveBirdseyeView"; import LiveBirdseyeView from "@/views/live/LiveBirdseyeView";
@@ -16,11 +17,21 @@ function Live() {
// selection // selection
const [selectedCameraName, setSelectedCameraName] = useHashState(); const [selectedCameraName, setSelectedCameraName] = useHashState();
const [cameraGroup] = usePersistedOverlayState( const [cameraGroup, setCameraGroup] = usePersistedOverlayState(
"cameraGroup", "cameraGroup",
"default" as string, "default" as string,
); );
useSearchEffect("group", (cameraGroup) => {
if (config && cameraGroup) {
const group = config.camera_groups[cameraGroup];
if (group) {
setCameraGroup(cameraGroup);
}
}
});
// fullscreen // fullscreen
const mainRef = useRef<HTMLDivElement | null>(null); const mainRef = useRef<HTMLDivElement | null>(null);

View File

@@ -231,8 +231,8 @@ function Logs() {
useKeyboardListener( useKeyboardListener(
["PageDown", "PageUp", "ArrowDown", "ArrowUp"], ["PageDown", "PageUp", "ArrowDown", "ArrowUp"],
(key, down, _) => { (key, modifiers) => {
if (!down) { if (!modifiers.down) {
return; return;
} }

View File

@@ -30,6 +30,7 @@ import { PolygonType } from "@/types/canvas";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import scrollIntoView from "scroll-into-view-if-needed"; import scrollIntoView from "scroll-into-view-if-needed";
import GeneralSettingsView from "@/views/settings/GeneralSettingsView"; import GeneralSettingsView from "@/views/settings/GeneralSettingsView";
import CameraSettingsView from "@/views/settings/CameraSettingsView";
import ObjectSettingsView from "@/views/settings/ObjectSettingsView"; import ObjectSettingsView from "@/views/settings/ObjectSettingsView";
import MotionTunerView from "@/views/settings/MotionTunerView"; import MotionTunerView from "@/views/settings/MotionTunerView";
import MasksAndZonesView from "@/views/settings/MasksAndZonesView"; import MasksAndZonesView from "@/views/settings/MasksAndZonesView";
@@ -38,6 +39,7 @@ import AuthenticationView from "@/views/settings/AuthenticationView";
export default function Settings() { export default function Settings() {
const settingsViews = [ const settingsViews = [
"general", "general",
"camera settings",
"masks / zones", "masks / zones",
"motion tuner", "motion tuner",
"debug", "debug",
@@ -136,6 +138,7 @@ export default function Settings() {
</div> </div>
</ScrollArea> </ScrollArea>
{(page == "debug" || {(page == "debug" ||
page == "camera settings" ||
page == "masks / zones" || page == "masks / zones" ||
page == "motion tuner") && ( page == "motion tuner") && (
<div className="ml-2 flex flex-shrink-0 items-center gap-2"> <div className="ml-2 flex flex-shrink-0 items-center gap-2">
@@ -158,6 +161,12 @@ export default function Settings() {
{page == "debug" && ( {page == "debug" && (
<ObjectSettingsView selectedCamera={selectedCamera} /> <ObjectSettingsView selectedCamera={selectedCamera} />
)} )}
{page == "camera settings" && (
<CameraSettingsView
selectedCamera={selectedCamera}
setUnsavedChanges={setUnsavedChanges}
/>
)}
{page == "masks / zones" && ( {page == "masks / zones" && (
<MasksAndZonesView <MasksAndZonesView
selectedCamera={selectedCamera} selectedCamera={selectedCamera}

View File

@@ -456,7 +456,7 @@ function PlusFilterGroup({
<div className="hidden text-primary md:block"> <div className="hidden text-primary md:block">
{selectedScoreRange == undefined {selectedScoreRange == undefined
? "Score Range" ? "Score Range"
: `${selectedScoreRange[0] * 100}% - ${selectedScoreRange[1] * 100}%`} : `${Math.round(selectedScoreRange[0] * 100)}% - ${Math.round(selectedScoreRange[1] * 100)}%`}
</div> </div>
</Button> </Button>
</Trigger> </Trigger>

View File

@@ -130,6 +130,7 @@ const generateRandomEvent = (): ReviewSegment => {
function UIPlayground() { function UIPlayground() {
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
const contentRef = useRef<HTMLDivElement>(null); const contentRef = useRef<HTMLDivElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
const reviewTimelineRef = useRef<HTMLDivElement>(null); const reviewTimelineRef = useRef<HTMLDivElement>(null);
const [mockEvents, setMockEvents] = useState<ReviewSegment[]>([]); const [mockEvents, setMockEvents] = useState<ReviewSegment[]>([]);
const [mockMotionData, setMockMotionData] = useState<MotionData[]>([]); const [mockMotionData, setMockMotionData] = useState<MotionData[]>([]);
@@ -344,11 +345,12 @@ function UIPlayground() {
Zoom In Zoom In
</Button> </Button>
</p> </p>
<div className=""> <div ref={containerRef} className="">
{birdseyeConfig && ( {birdseyeConfig && (
<BirdseyeLivePlayer <BirdseyeLivePlayer
birdseyeConfig={birdseyeConfig} birdseyeConfig={birdseyeConfig}
liveMode={birdseyeConfig.restream ? "mse" : "jsmpeg"} liveMode={birdseyeConfig.restream ? "mse" : "jsmpeg"}
containerRef={containerRef}
/> />
)} )}
</div> </div>

View File

@@ -18,8 +18,6 @@ export type ZoneFormValuesType = {
loitering_time: number; loitering_time: number;
isFinished: boolean; isFinished: boolean;
objects: string[]; objects: string[];
review_alerts: boolean;
review_detections: boolean;
}; };
export type ObjectMaskFormValuesType = { export type ObjectMaskFormValuesType = {

View File

@@ -172,9 +172,11 @@ export interface CameraConfig {
review: { review: {
alerts: { alerts: {
required_zones: string[]; required_zones: string[];
labels: string[];
}; };
detections: { detections: {
required_zones: string[]; required_zones: string[];
labels: string[];
}; };
}; };
rtmp: { rtmp: {

View File

@@ -60,4 +60,4 @@ export type MotionData = {
camera: string; camera: string;
}; };
export const REVIEW_PADDING = 2; export const REVIEW_PADDING = 4;

View File

@@ -51,6 +51,7 @@ import { toast } from "sonner";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { FilterList, LAST_24_HOURS_KEY } from "@/types/filter"; import { FilterList, LAST_24_HOURS_KEY } from "@/types/filter";
import { GiSoundWaves } from "react-icons/gi"; import { GiSoundWaves } from "react-icons/gi";
import useKeyboardListener from "@/hooks/use-keyboard-listener";
type EventViewProps = { type EventViewProps = {
reviewItems?: SegmentedReviewData; reviewItems?: SegmentedReviewData;
@@ -158,6 +159,17 @@ export default function EventView({
}, },
[selectedReviews, setSelectedReviews, onOpenRecording, markItemAsReviewed], [selectedReviews, setSelectedReviews, onOpenRecording, markItemAsReviewed],
); );
const onSelectAllReviews = useCallback(() => {
if (!currentReviewItems || currentReviewItems.length == 0) {
return;
}
if (selectedReviews.length < currentReviewItems.length) {
setSelectedReviews(currentReviewItems.map((seg) => seg.id));
} else {
setSelectedReviews([]);
}
}, [currentReviewItems, selectedReviews]);
const exportReview = useCallback( const exportReview = useCallback(
(id: string) => { (id: string) => {
@@ -167,9 +179,13 @@ export default function EventView({
return; return;
} }
const endTime = review.end_time
? review.end_time + REVIEW_PADDING
: Date.now() / 1000;
axios axios
.post( .post(
`export/${review.camera}/start/${review.start_time}/end/${review.end_time}`, `export/${review.camera}/start/${review.start_time - REVIEW_PADDING}/end/${endTime}`,
{ playback: "realtime" }, { playback: "realtime" },
) )
.then((response) => { .then((response) => {
@@ -372,6 +388,7 @@ export default function EventView({
markItemAsReviewed={markItemAsReviewed} markItemAsReviewed={markItemAsReviewed}
markAllItemsAsReviewed={markAllItemsAsReviewed} markAllItemsAsReviewed={markAllItemsAsReviewed}
onSelectReview={onSelectReview} onSelectReview={onSelectReview}
onSelectAllReviews={onSelectAllReviews}
pullLatestData={pullLatestData} pullLatestData={pullLatestData}
/> />
)} )}
@@ -413,6 +430,7 @@ type DetectionReviewProps = {
markItemAsReviewed: (review: ReviewSegment) => void; markItemAsReviewed: (review: ReviewSegment) => void;
markAllItemsAsReviewed: (currentItems: ReviewSegment[]) => void; markAllItemsAsReviewed: (currentItems: ReviewSegment[]) => void;
onSelectReview: (review: ReviewSegment, ctrl: boolean) => void; onSelectReview: (review: ReviewSegment, ctrl: boolean) => void;
onSelectAllReviews: () => void;
pullLatestData: () => void; pullLatestData: () => void;
}; };
function DetectionReview({ function DetectionReview({
@@ -430,6 +448,7 @@ function DetectionReview({
markItemAsReviewed, markItemAsReviewed,
markAllItemsAsReviewed, markAllItemsAsReviewed,
onSelectReview, onSelectReview,
onSelectAllReviews,
pullLatestData, pullLatestData,
}: DetectionReviewProps) { }: DetectionReviewProps) {
const reviewTimelineRef = useRef<HTMLDivElement>(null); const reviewTimelineRef = useRef<HTMLDivElement>(null);
@@ -576,6 +595,18 @@ function DetectionReview({
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [startTime]); }, [startTime]);
// keyboard
useKeyboardListener(["a"], (key, modifiers) => {
if (modifiers.repeat || !modifiers.down) {
return;
}
if (key == "a" && modifiers.ctrl) {
onSelectAllReviews();
}
});
return ( return (
<> <>
<div <div

View File

@@ -314,7 +314,7 @@ export function RecordingView({
return undefined; return undefined;
} }
const aspect = camera.detect.width / camera.detect.height; const aspect = getCameraAspect(mainCamera);
if (!aspect) { if (!aspect) {
return undefined; return undefined;
@@ -336,7 +336,14 @@ export function RecordingView({
return { return {
width: `${Math.round(percent)}%`, width: `${Math.round(percent)}%`,
}; };
}, [config, mainCameraAspect, mainWidth, mainHeight, mainCamera]); }, [
config,
mainCameraAspect,
mainWidth,
mainHeight,
mainCamera,
getCameraAspect,
]);
const previewRowOverflows = useMemo(() => { const previewRowOverflows = useMemo(() => {
if (!previewRowRef.current) { if (!previewRowRef.current) {
@@ -532,6 +539,7 @@ export function RecordingView({
isScrubbing={scrubbing || exportMode == "timeline"} isScrubbing={scrubbing || exportMode == "timeline"}
setFullResolution={setFullResolution} setFullResolution={setFullResolution}
toggleFullscreen={toggleFullscreen} toggleFullscreen={toggleFullscreen}
containerRef={mainLayoutRef}
/> />
</div> </div>
{isDesktop && ( {isDesktop && (

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