Compare commits

..

47 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
88 changed files with 3122 additions and 1774 deletions

View File

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

View File

@@ -33,7 +33,7 @@ RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \
FROM scratch AS go2rtc
ARG TARGETARCH
WORKDIR /rootfs/usr/local/go2rtc/bin
ADD --link --chmod=755 "https://github.com/AlexxIT/go2rtc/releases/download/v1.9.4/go2rtc_linux_${TARGETARCH}" go2rtc
ADD --link --chmod=755 "https://github.com/AlexxIT/go2rtc/releases/download/v1.9.2/go2rtc_linux_${TARGETARCH}" go2rtc
FROM wget AS tempio
ARG TARGETARCH
@@ -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 && \
sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt
# 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 .

View File

@@ -40,7 +40,7 @@ apt-get -qq install --no-install-recommends --no-install-suggests -y \
# btbn-ffmpeg -> amd64
if [[ "${TARGETARCH}" == "amd64" ]]; then
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
rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay
fi
@@ -48,7 +48,7 @@ fi
# ffmpeg -> arm64
if [[ "${TARGETARCH}" == "arm64" ]]; then
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
rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay
fi

View File

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

View File

@@ -1,2 +1,2 @@
scikit-build == 0.18.*
scikit-build == 0.17.*
nvidia-pyindex

View File

@@ -34,7 +34,7 @@ do
;;
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
*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"):
for secret_file in os.listdir("/run/secrets"):
if secret_file.startswith("FRIGATE_"):
FRIGATE_ENV_VARS[secret_file] = Path(
os.path.join("/run/secrets", secret_file)
).read_text()
FRIGATE_ENV_VARS[secret_file] = (
Path(os.path.join("/run/secrets", secret_file)).read_text().strip()
)
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")

View File

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

View File

@@ -1,9 +1,12 @@
# intended for internal traffic, not protected by auth
listen 5000;
{{ if not .enabled }}
# intended for external traffic, protected by auth
listen [::]:8080 ipv6only=off;
listen 8971;
{{ else }}
# 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_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.
@@ -118,7 +164,7 @@ 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`.
## Custom go2rtc version
### Custom go2rtc version
Frigate currently includes go2rtc v1.9.4, there may be certain cases where you want to run a different version of go2rtc.

View File

@@ -13,7 +13,7 @@ The following ports are available to access the Frigate web UI.
| 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. |
## Onboarding

View File

@@ -7,13 +7,15 @@ Frigate intelligently displays your camera streams on the Live view dashboard. Y
## 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 |
| ------ | ------- | ------------------------------------- | -------------- | ---------------------------- | --------------- | ------------------------------------------------ |
| jsmpeg | low | same as `detect -> fps`, capped at 10 | same as detect | no | no | none |
| 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 |
The jsmpeg live view will use more browser and client GPU resources. Using go2rtc is highly recommended and will provide a superior experience.
| Source | Latency | Frame Rate | Resolution | Audio | Requires go2rtc | Other Limitations |
| ------ | ------- | ------------------------------------- | ---------- | ---------------------------- | --------------- | ------------------------------------------------------------------------------------ |
| 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

View File

@@ -159,11 +159,14 @@ Using Frigate UI, HomeAssistant, or MQTT, cameras can be automated to only recor
## 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 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.
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

View File

@@ -65,7 +65,7 @@ database:
# Optional: TLS configuration
tls:
# Optional: Enable TLS for port 8080 (default: shown below)
# Optional: Enable TLS for port 8971 (default: shown below)
enabled: True
# Optional: Proxy configuration
@@ -613,6 +613,9 @@ cameras:
user: admin
# Optional: password for login.
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
# the center of the frame by automatically moving the PTZ camera.
autotracking:

View File

@@ -62,6 +62,6 @@ By default a review item will be created if any `review -> alerts -> labels` and
:::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
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.
@@ -24,21 +24,33 @@ TLS certificates can be mounted at `/etc/letsencrypt/live/frigate` using a bind
frigate:
...
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`.
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.
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
frigate:
...
ports:
- "443:8080"
- "443:8971"
...
```

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.
### 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
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 |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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. |
| `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. |
@@ -171,7 +171,7 @@ services:
tmpfs:
size: 1000000000
ports:
- "8080:8080"
- "8971:8971"
# - "5000:5000" # Internal unauthenticated access. Expose carefully.
- "8554:8554" # RTSP feeds
- "8555:8555/tcp" # WebRTC over tcp
@@ -194,7 +194,7 @@ docker run -d \
-v /path/to/your/config:/config \
-v /etc/localtime:/etc/localtime:ro \
-e FRIGATE_RTSP_PASSWORD='password' \
-p 8080:8080 \
-p 8971:8971 \
-p 8554:8554 \
-p 8555:8555/tcp \
-p 8555:8555/udp \
@@ -370,7 +370,7 @@ docker run \
--network=bridge \
--privileged \
--workdir=/opt/frigate \
-p 8080:8080 \
-p 8971:8971 \
-p 8554:8554 \
-p 8555:8555 \
-p 8555:8555/udp \

View File

@@ -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.
### 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.4#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.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. 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
go2rtc:
streams:
back:
- rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
- "ffmpeg:back#video=h264"
```
- Check go2rtc Web Interface: if you don't see any errors in the logs, try viewing the camera through go2rtc's web interface.
- Navigate to port 1984 in your browser to access go2rtc's web interface.
- If using Frigate through Home Assistant, enable the web interface at port 1984.
- If using Docker, forward port 1984 before accessing the web interface.
- Click `stream` for the specific camera to see if the camera's stream is being received.
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
go2rtc:
streams:
back:
- ffmpeg:rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2
```
- Switch to FFmpeg if needed:
- 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.
```yaml
go2rtc:
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
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:
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
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:
When using the ffmpeg module, you would add AAC audio like this:
```yaml
go2rtc:
streams:
back:
- "ffmpeg:rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2#video=copy#audio=copy#audio=aac"
```
```yaml
go2rtc:
streams:
back:
- "ffmpeg:rtsp://user:password@10.0.10.10:554/cam/realmonitor?channel=1&subtype=2#video=copy#audio=copy#audio=aac"
```
:::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:
size: 1000000000
ports:
- "8080:8080"
- "8971:8971"
- "8554:8554" # RTSP feeds
```
@@ -137,7 +137,7 @@ cameras:
- detect
```
Now you should be able to start Frigate by running `docker compose up -d` from within the folder containing `docker-compose.yml`. On startup, an admin user and password will be created and outputted in the logs. You can see this by running `docker logs frigate`. Frigate should now be accessible at `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

View File

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

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`.
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

@@ -89,7 +89,9 @@ def get_jwt_secret() -> str:
# check docker secrets
elif os.path.isfile(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)):
logger.debug(f"Using jwt secret from {JWT_SECRET_ENV_VAR} docker secret file.")
jwt_secret = Path(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)).read_text()
jwt_secret = (
Path(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)).read_text().strip()
)
# check for the addon options file
elif os.path.isfile("/data/options.json"):
with open("/data/options.json") as f:

View File

@@ -637,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 (
event.start_time < datetime.now().timestamp() - 300
and type(vod_response) == tuple
and type(vod_response) is tuple
and len(vod_response) == 2
and vod_response[1] == 404
):

View File

@@ -7,7 +7,6 @@ from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
import matplotlib.pyplot as plt
import numpy as np
from pydantic import (
BaseModel,
@@ -26,6 +25,7 @@ from frigate.const import (
CACHE_DIR,
CACHE_SEGMENT_FORMAT,
DEFAULT_DB_PATH,
FREQUENCY_STATS_POINTS,
MAX_PRE_CAPTURE,
REGEX_CAMERA_NAME,
YAML_EXT,
@@ -42,6 +42,7 @@ from frigate.plus import PlusApi
from frigate.util.builtin import (
deep_merge,
escape_special_characters,
generate_color_palette,
get_ffmpeg_arg_list,
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):
for secret_file in os.listdir("/run/secrets"):
if secret_file.startswith("FRIGATE_"):
FRIGATE_ENV_VARS[secret_file] = Path(
os.path.join("/run/secrets", secret_file)
).read_text()
FRIGATE_ENV_VARS[secret_file] = (
Path(os.path.join("/run/secrets", secret_file)).read_text().strip()
)
DEFAULT_TRACKED_OBJECTS = ["person"]
DEFAULT_ALERT_OBJECTS = ["person", "car"]
@@ -116,7 +117,7 @@ class UIConfig(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):
@@ -193,7 +194,9 @@ class MqttConfig(FrigateBaseModel):
port: int = Field(default=1883, title="MQTT Port")
topic_prefix: str = Field(default="frigate", title="MQTT Topic Prefix")
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")
password: Optional[str] = Field(None, title="MQTT Password", validate_default=True)
tls_ca_certs: Optional[str] = Field(None, title="MQTT TLS CA Certificates")
@@ -276,6 +279,10 @@ class OnvifConfig(FrigateBaseModel):
default_factory=PtzAutotrackConfig,
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):
@@ -1030,10 +1037,11 @@ class CameraConfig(FrigateBaseModel):
def __init__(self, **config):
# Set zone colors
if "zones" in config:
colors = plt.cm.get_cmap("tab10", len(config["zones"]))
colors = generate_color_palette(len(config["zones"]))
config["zones"] = {
name: {**z, "color": tuple(round(255 * c) for c in colors(idx)[:3])}
for idx, (name, z) in enumerate(config["zones"].items())
name: {**z, "color": color}
for (name, z), color in zip(config["zones"].items(), colors)
}
# 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"
UPDATE_CAMERA_ACTIVITY = "update_camera_activity"
# Stats Values
FREQUENCY_STATS_POINTS = 15
# Autotracking
AUTOTRACKING_MAX_AREA_RATIO = 0.6

View File

@@ -5,13 +5,12 @@ import os
from enum import Enum
from typing import Dict, Optional, Tuple
import matplotlib.pyplot as plt
import requests
from pydantic import BaseModel, ConfigDict, Field
from pydantic.fields import PrivateAttr
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__)
@@ -128,10 +127,9 @@ class ModelConfig(BaseModel):
def create_colormap(self, enabled_labels: set[str]) -> None:
"""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[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])
self._colormap = {label: color for label, color in zip(enabled_labels, colors)}
model_config = ConfigDict(extra="forbid", protected_namespaces=())

View File

@@ -1,4 +1,5 @@
import logging
import os
import numpy as np
import openvino as ov
@@ -35,6 +36,10 @@ class OvDetector(DetectionApi):
)
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(
model=detector_config.model.path, device_name=detector_config.device
)

View File

@@ -42,7 +42,9 @@ class PlusApi:
and os.access("/run/secrets", os.R_OK)
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
elif os.path.isfile("/data/options.json"):
with open("/data/options.json") as f:

View File

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

View File

@@ -53,7 +53,7 @@ class PendingReviewSegment:
severity: SeverityEnum,
detections: dict[str, str],
sub_labels: set[str],
zones: set[str],
zones: list[str],
audio: set[str],
):
rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
@@ -137,7 +137,7 @@ class PendingReviewSegment:
"detections": list(set(self.detections.keys())),
"objects": list(set(self.detections.values())),
"sub_labels": list(self.sub_labels),
"zones": list(self.zones),
"zones": self.zones,
"audio": list(self.audio),
},
}.copy()
@@ -279,7 +279,9 @@ class ReviewSegmentMaintainer(threading.Thread):
# keep zones up to date
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:
should_update = True
@@ -329,7 +331,7 @@ class ReviewSegmentMaintainer(threading.Thread):
if len(active_objects) > 0:
detections: dict[str, str] = {}
sub_labels = set()
zones: set = set()
zones: list[str] = []
severity = None
for object in active_objects:
@@ -379,7 +381,9 @@ class ReviewSegmentMaintainer(threading.Thread):
):
severity = SeverityEnum.detection
zones.update(object["current_zones"])
for zone in object["current_zones"]:
if zone not in zones:
zones.append(zone)
if severity:
self.active_review_segments[camera] = PendingReviewSegment(
@@ -534,7 +538,7 @@ class ReviewSegmentMaintainer(threading.Thread):
severity,
{},
set(),
set(),
[],
detections,
)
elif topic == DetectionTypeEnum.api:
@@ -544,7 +548,7 @@ class ReviewSegmentMaintainer(threading.Thread):
SeverityEnum.alert,
{manual_info["event_id"]: manual_info["label"]},
set(),
set(),
[],
set(),
)

View File

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

View File

@@ -349,3 +349,39 @@ def empty_and_close_queue(q: mp.Queue):
q.close()
q.join_thread()
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

2308
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
import { cn } from "@/lib/utils";
import { LogSeverity } from "@/types/log";
import { ReactNode, useMemo, useRef } from "react";
import { isIOS } from "react-device-detect";
import { CSSTransition } from "react-transition-group";
type ChipProps = {
@@ -34,8 +35,9 @@ export default function Chip({
<div
ref={nodeRef}
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,
!isIOS && "z-10",
)}
onClick={onClick}
>

View File

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

View File

@@ -1,13 +1,18 @@
import Logo from "../Logo";
import NavItem from "./NavItem";
import { CameraGroupSelector } from "../filter/CameraGroupSelector";
import { useLocation } from "react-router-dom";
import { Link, useMatch } from "react-router-dom";
import GeneralSettings from "../menu/GeneralSettings";
import AccountSettings from "../menu/AccountSettings";
import useNavigation from "@/hooks/use-navigation";
import { baseUrl } from "@/api/baseUrl";
import { useMemo } from "react";
function Sidebar() {
const location = useLocation();
const basePath = useMemo(() => new URL(baseUrl).pathname, []);
const isRootMatch = useMatch("/");
const isBasePathMatch = useMatch(basePath);
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">
<span tabIndex={0} className="sr-only" />
<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) => {
const showCameraGroups =
item.id == 1 && item.url == location.pathname;
(isRootMatch || isBasePathMatch) && item.id === 1;
return (
<div key={item.id}>

View File

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

View File

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

View File

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

View File

@@ -3,14 +3,15 @@ import { useResizeObserver } from "@/hooks/resize-observer";
import { cn } from "@/lib/utils";
// @ts-expect-error we know this doesn't have types
import JSMpeg from "@cycjimmy/jsmpeg-player";
import React, { useEffect, useMemo, useRef, useId, useState } from "react";
import React, { useEffect, useMemo, useRef, useState } from "react";
type JSMpegPlayerProps = {
className?: string;
camera: string;
width: number;
height: number;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
containerRef: React.MutableRefObject<HTMLDivElement | null>;
playbackEnabled: boolean;
onPlaying?: () => void;
};
@@ -20,18 +21,23 @@ export default function JSMpegPlayer({
height,
className,
containerRef,
playbackEnabled,
onPlaying,
}: JSMpegPlayerProps) {
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
const playerRef = useRef<HTMLDivElement | null>(null);
const videoRef = useRef(null);
const videoRef = useRef<HTMLDivElement>(null);
const canvasRef = useRef<HTMLCanvasElement>(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(
() => containerRef ?? internalContainerRef,
[containerRef, internalContainerRef],
() => (containerRef.current ? 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 }] =
@@ -66,6 +72,7 @@ export default function JSMpegPlayer({
return finalHeight;
}
}
return undefined;
}, [
aspectRatio,
containerWidth,
@@ -81,44 +88,88 @@ export default function JSMpegPlayer({
if (aspectRatio && scaledHeight) {
return Math.ceil(scaledHeight * aspectRatio);
}
return undefined;
}, [scaledHeight, aspectRatio]);
const uniqueId = useId();
useEffect(() => {
if (scaledWidth && scaledHeight) {
setDimensionsReady(true);
}
}, [scaledWidth, scaledHeight]);
useEffect(() => {
onPlayingRef.current = onPlaying;
}, [onPlaying]);
useEffect(() => {
if (!playerRef.current || videoRef.current) {
if (!selectedContainerRef?.current || !url) {
return;
}
videoRef.current = new JSMpeg.VideoElement(
playerRef.current,
url,
{ canvas: `#${CSS.escape(uniqueId)}` },
{
protocols: [],
audio: false,
videoBufferSize: 1024 * 1024 * 4,
onPlay: () => {
setShowCanvas(true);
onPlayingRef.current?.();
},
},
);
}, [url, uniqueId]);
const videoWrapper = videoRef.current;
const canvas = canvasRef.current;
let videoElement: JSMpeg.VideoElement | null = null;
if (videoWrapper && playbackEnabled) {
// Delayed init to avoid issues with react strict mode
const initPlayer = setTimeout(() => {
videoElement = new JSMpeg.VideoElement(
videoWrapper,
url,
{ canvas: canvas },
{
protocols: [],
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 (
<div className={className}>
<div className="size-full" ref={internalContainerRef}>
<div ref={playerRef} className={cn("jsmpeg", !showCanvas && "hidden")}>
<div className={cn(className, !containerRef.current && "size-full")}>
<div
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
id={uniqueId}
ref={canvasRef}
className="rounded-lg md:rounded-2xl"
style={{
width: scaledWidth ?? width,
height: scaledHeight ?? height,
width: scaledWidth,
height: scaledHeight,
}}
></canvas>
</div>

View File

@@ -2,7 +2,7 @@ import WebRtcPlayer from "./WebRTCPlayer";
import { CameraConfig } from "@/types/frigateConfig";
import AutoUpdatingCameraImage from "../camera/AutoUpdatingCameraImage";
import ActivityIndicator from "../indicators/activity-indicator";
import { useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import MSEPlayer from "./MsePlayer";
import JSMpegPlayer from "./JSMpegPlayer";
import { MdCircle } from "react-icons/md";
@@ -55,6 +55,7 @@ export default function LivePlayer({
setFullResolution,
onError,
}: LivePlayerProps) {
const internalContainerRef = useRef<HTMLDivElement | null>(null);
// camera activity
const { activeMotion, activeTracking, objects, offline } =
@@ -73,20 +74,12 @@ export default function LivePlayer({
const [liveReady, setLiveReady] = useState(false);
useEffect(() => {
if (!autoLive) {
return;
}
if (!liveReady) {
if (cameraActive && liveMode == "jsmpeg") {
setLiveReady(true);
}
if (!autoLive || !liveReady) {
return;
}
if (!cameraActive) {
setTimeout(() => setLiveReady(false), 500);
setLiveReady(false);
}
// live mode won't change
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -168,8 +161,7 @@ export default function LivePlayer({
} else {
player = (
<div className="w-5xl text-center text-sm">
MSE is only supported on iOS 17.1+. You'll need to update if available
or use jsmpeg / webRTC streams. See the docs for more info.
iOS 17.1 or greater is required for this live stream type.
</div>
);
}
@@ -178,10 +170,11 @@ export default function LivePlayer({
player = (
<JSMpegPlayer
className="flex justify-center overflow-hidden rounded-lg md:rounded-2xl"
camera={cameraConfig.live.stream_name}
camera={cameraConfig.name}
width={cameraConfig.detect.width}
height={cameraConfig.detect.height}
containerRef={containerRef}
playbackEnabled={cameraActive || !showStillWithoutActivity}
containerRef={containerRef ?? internalContainerRef}
onPlaying={playerIsPlaying}
/>
);
@@ -194,7 +187,7 @@ export default function LivePlayer({
return (
<div
ref={cameraRef}
ref={cameraRef ?? internalContainerRef}
data-camera={cameraConfig.name}
className={cn(
"relative flex w-full cursor-pointer justify-center outline",
@@ -263,9 +256,10 @@ export default function LivePlayer({
)}
<div
className={`absolute inset-0 w-full ${
showStillWithoutActivity && !liveReady ? "visible" : "invisible"
}`}
className={cn(
"absolute inset-0 w-full",
showStillWithoutActivity && !liveReady ? "visible" : "invisible",
)}
>
<AutoUpdatingCameraImage
className="size-full"

View File

@@ -31,7 +31,7 @@ function MSEPlayer({
setFullResolution,
onError,
}: MSEPlayerProps) {
const RECONNECT_TIMEOUT: number = 30000;
const RECONNECT_TIMEOUT: number = 10000;
const CODECS: string[] = [
"avc1.640029", // H.264 high 4.1 (Chromecast 1st and 2nd Gen)
@@ -45,10 +45,12 @@ function MSEPlayer({
];
const visibilityCheck: boolean = !pip;
const [isPlaying, setIsPlaying] = useState(false);
const [wsState, setWsState] = useState<number>(WebSocket.CLOSED);
const [connectTS, setConnectTS] = useState<number>(0);
const [bufferTimeout, setBufferTimeout] = useState<NodeJS.Timeout>();
const [errorCount, setErrorCount] = useState<number>(0);
const videoRef = useRef<HTMLVideoElement>(null);
const wsRef = useRef<WebSocket | null>(null);
@@ -117,12 +119,19 @@ function MSEPlayer({
}, [wsURL]);
const onDisconnect = useCallback(() => {
if (wsRef.current && wsState == WebSocket.OPEN) {
if (bufferTimeout) {
clearTimeout(bufferTimeout);
setBufferTimeout(undefined);
}
setIsPlaying(false);
if (wsRef.current) {
setWsState(WebSocket.CLOSED);
wsRef.current.close();
wsRef.current = null;
}
}, [wsState]);
}, [bufferTimeout]);
const onOpen = () => {
setWsState(WebSocket.OPEN);
@@ -162,6 +171,26 @@ function MSEPlayer({
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 = () => {
if ("ManagedMediaSource" in window) {
const MediaSource = window.ManagedMediaSource;
@@ -169,10 +198,22 @@ function MSEPlayer({
msRef.current?.addEventListener(
"sourceopen",
() => {
send({
type: "mse",
// @ts-expect-error for typing
value: codecs(MediaSource.isTypeSupported),
sendWithTimeout(
{
type: "mse",
// @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 },
@@ -187,9 +228,21 @@ function MSEPlayer({
"sourceopen",
() => {
URL.revokeObjectURL(videoRef.current?.src || "");
send({
type: "mse",
value: codecs(MediaSource.isTypeSupported),
sendWithTimeout(
{
type: "mse",
value: codecs(MediaSource.isTypeSupported),
},
3000,
).catch(() => {
if (wsRef.current) {
onDisconnect();
}
if (isIOS || isSafari) {
onError?.("mse-decode");
} else {
onError?.("startup");
}
});
},
{ 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(() => {
if (!playbackEnabled) {
return;
@@ -260,10 +318,6 @@ function MSEPlayer({
return () => {
onDisconnect();
if (bufferTimeout) {
clearTimeout(bufferTimeout);
setBufferTimeout(undefined);
}
};
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -305,6 +359,23 @@ function MSEPlayer({
videoRef.current.requestPictureInPicture();
}, [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 (
<video
ref={videoRef}
@@ -314,10 +385,20 @@ function MSEPlayer({
onLoadedData={() => {
handleLoadedMetadata?.();
onPlaying?.();
setIsPlaying(true);
}}
muted={!audioEnabled}
onPause={() => videoRef.current?.play()}
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?.();
}
if (onError != undefined) {
@@ -334,8 +415,10 @@ function MSEPlayer({
setTimeout(() => {
if (
document.visibilityState === "visible" &&
wsRef.current != null
wsRef.current != null &&
videoRef.current
) {
onDisconnect();
onError("stalled");
}
}, 3000),
@@ -347,6 +430,9 @@ function MSEPlayer({
// @ts-expect-error code does exist
e.target.error.code == MediaError.MEDIA_ERR_NETWORK
) {
if (wsRef.current) {
onDisconnect();
}
onError?.("startup");
}
@@ -355,15 +441,22 @@ function MSEPlayer({
e.target.error.code == MediaError.MEDIA_ERR_DECODE &&
(isSafari || isIOS)
) {
if (wsRef.current) {
onDisconnect();
}
onError?.("mse-decode");
clearTimeout(bufferTimeout);
setBufferTimeout(undefined);
}
setErrorCount((prevCount) => prevCount + 1);
if (wsRef.current) {
wsRef.current.close();
wsRef.current = null;
reconnect(5000);
onDisconnect();
if (errorCount >= 3) {
// too many mse errors, try jsmpeg
onError?.("startup");
} else {
reconnect(5000);
}
}
}}
/>

View File

@@ -26,6 +26,7 @@ import { NoThumbSlider } from "../ui/slider";
import { PREVIEW_FPS, PREVIEW_PADDING } from "@/types/preview";
import { capitalizeFirstLetter } from "@/utils/stringUtil";
import { baseUrl } from "@/api/baseUrl";
import { cn } from "@/lib/utils";
type PreviewPlayerProps = {
review: ReviewSegment;
@@ -229,8 +230,15 @@ export default function PreviewThumbnailPlayer({
onImgLoad();
}}
/>
<div className="absolute left-0 top-2 z-40">
{!playingBack && (
<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>
<div
className="flex"
@@ -276,21 +284,23 @@ export default function PreviewThumbnailPlayer({
</Tooltip>
</div>
{!playingBack && (
<>
<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>
<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">
<div className="mx-3 flex h-full items-end justify-between pb-1 text-sm text-white">
{review.end_time ? (
<TimeAgo time={review.start_time * 1000} dense />
) : (
<div>
<ActivityIndicator size={24} />
</div>
)}
{formattedDate}
</div>
<div
className={cn(
"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",
!isIOS && "z-10",
)}
>
<div className="mx-3 flex h-full items-end justify-between pb-1 text-sm text-white">
{review.end_time ? (
<TimeAgo time={review.start_time * 1000} dense />
) : (
<div>
<ActivityIndicator size={24} />
</div>
)}
{formattedDate}
</div>
</>
</div>
)}
</div>
</div>

View File

@@ -71,6 +71,7 @@ type VideoControlsProps = {
onSetPlaybackRate: (rate: number) => void;
onUploadFrame?: () => void;
toggleFullscreen?: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
};
export default function VideoControls({
className,
@@ -91,10 +92,11 @@ export default function VideoControls({
onSetPlaybackRate,
onUploadFrame,
toggleFullscreen,
containerRef,
}: VideoControlsProps) {
// layout
const containerRef = useRef<HTMLDivElement | null>(null);
const controlsContainerRef = useRef<HTMLDivElement | null>(null);
// controls
@@ -197,7 +199,7 @@ export default function VideoControls({
MIN_ITEMS_WRAP &&
"min-w-[75%] flex-wrap",
)}
ref={containerRef}
ref={controlsContainerRef}
>
{video && features.volume && (
<div className="flex cursor-pointer items-center justify-normal gap-2">
@@ -247,7 +249,7 @@ export default function VideoControls({
>
<DropdownMenuTrigger>{`${playbackRate}x`}</DropdownMenuTrigger>
<DropdownMenuContent
portalProps={{ container: containerRef.current }}
portalProps={{ container: controlsContainerRef.current }}
>
<DropdownMenuRadioGroup
onValueChange={(rate) => onSetPlaybackRate(parseFloat(rate))}
@@ -281,6 +283,7 @@ export default function VideoControls({
}
}}
onUploadFrame={onUploadFrame}
containerRef={containerRef}
/>
)}
{features.fullscreen && toggleFullscreen && (
@@ -297,12 +300,14 @@ type FrigatePlusUploadButtonProps = {
onOpen: () => void;
onClose: () => void;
onUploadFrame: () => void;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
};
function FrigatePlusUploadButton({
video,
onOpen,
onClose,
onUploadFrame,
containerRef,
}: FrigatePlusUploadButtonProps) {
const [videoImg, setVideoImg] = useState<string>();
@@ -336,7 +341,10 @@ function FrigatePlusUploadButton({
}}
/>
</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>
<AlertDialogTitle>Submit this frame to Frigate+?</AlertDialogTitle>
</AlertDialogHeader>

View File

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

View File

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

View File

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

View File

@@ -143,20 +143,6 @@ export default function ZoneEditPane({
config?.cameras[polygon.camera]?.zones[polygon.name]?.loitering_time,
isFinished: polygon?.isFinished ?? false,
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,
loitering_time,
objects: form_objects,
review_alerts,
review_detections,
}: ZoneFormValuesType, // values submitted via the form
objects: string[],
) => {
@@ -176,11 +160,21 @@ export default function ZoneEditPane({
return;
}
let mutatedConfig = config;
let alertQueries = "";
let detectionQueries = "";
const renamingZone = zoneName != polygon.name && polygon.name != "";
if (renamingZone) {
// 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 {
alertQueries: renameAlertQueries,
detectionQueries: renameDetectionQueries,
@@ -209,6 +203,18 @@ export default function ZoneEditPane({
});
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(
@@ -233,17 +239,6 @@ export default function ZoneEditPane({
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 = "";
if (inertia) {
inertiaQuery = `&cameras.${polygon?.camera}.zones.${zoneName}.inertia=${inertia}`;
@@ -449,52 +444,6 @@ export default function ZoneEditPane({
/>
</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
control={form.control}
name="isFinished"

View File

@@ -152,7 +152,7 @@ export function EventSegment({
: ""
} ${
isFirstSegmentInMinimap || isLastSegmentInMinimap
? "relative h-[8px] border-b-2 border-neutral-600"
? "relative h-[8px] border-b-2 border-neutral_variant"
: ""
}`;

View File

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

View File

@@ -1,14 +1,14 @@
import * as React from "react"
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
import { cn } from "@/lib/utils";
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<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
@@ -17,31 +17,33 @@ const AlertDialogOverlay = React.forwardRef<
<AlertDialogPrimitive.Overlay
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",
className
className,
)}
{...props}
ref={ref}
/>
))
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
>(({ className, ...props }, ref) => (
<AlertDialogPortal>
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> & {
portalProps?: AlertDialogPrimitive.AlertDialogPortalProps;
}
>(({ className, portalProps, ...props }, ref) => (
<AlertDialogPortal {...portalProps}>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
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",
className
className,
)}
{...props}
/>
</AlertDialogPortal>
))
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
const AlertDialogHeader = ({
className,
@@ -50,12 +52,12 @@ const AlertDialogHeader = ({
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left",
className
className,
)}
{...props}
/>
)
AlertDialogHeader.displayName = "AlertDialogHeader"
);
AlertDialogHeader.displayName = "AlertDialogHeader";
const AlertDialogFooter = ({
className,
@@ -64,12 +66,12 @@ const AlertDialogFooter = ({
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
className,
)}
{...props}
/>
)
AlertDialogFooter.displayName = "AlertDialogFooter"
);
AlertDialogFooter.displayName = "AlertDialogFooter";
const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>,
@@ -80,8 +82,8 @@ const AlertDialogTitle = React.forwardRef<
className={cn("text-lg font-semibold", className)}
{...props}
/>
))
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>,
@@ -92,9 +94,9 @@ const AlertDialogDescription = React.forwardRef<
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
));
AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName
AlertDialogPrimitive.Description.displayName;
const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>,
@@ -105,8 +107,8 @@ const AlertDialogAction = React.forwardRef<
className={cn(buttonVariants(), className)}
{...props}
/>
))
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
@@ -117,12 +119,12 @@ const AlertDialogCancel = React.forwardRef<
className={cn(
buttonVariants({ variant: "outline" }),
"mt-2 sm:mt-0",
className
className,
)}
{...props}
/>
))
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
export {
AlertDialog,
@@ -136,4 +138,4 @@ export {
AlertDialogDescription,
AlertDialogAction,
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 ColorScheme =
| "theme-blue"
| "theme-gold"
| "theme-green"
| "theme-nature"
| "theme-netflix"
| "theme-nord"
| "theme-orange"
| "theme-red"
| "theme-high-contrast"
| "theme-default";
// eslint-disable-next-line react-refresh/only-export-components
export const colorSchemes: ColorScheme[] = [
"theme-blue",
"theme-gold",
"theme-green",
"theme-nature",
"theme-netflix",
"theme-nord",
"theme-orange",
"theme-red",
"theme-high-contrast",
"theme-default",
];

View File

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

View File

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

View File

@@ -1,12 +1,9 @@
@import "/themes/tailwind-base.css";
@import "/themes/theme-default.css";
@import "/themes/theme-blue.css";
@import "/themes/theme-gold.css";
@import "/themes/theme-green.css";
@import "/themes/theme-nature.css";
@import "/themes/theme-netflix.css";
@import "/themes/theme-high-contrast.css";
@import "/themes/theme-nord.css";
@import "/themes/theme-orange.css";
@import "/themes/theme-red.css";
@tailwind base;
@@ -26,10 +23,14 @@
@layer utilities {
.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 */
.no-scrollbar::-webkit-scrollbar {
display: none;

View File

@@ -15,6 +15,7 @@ import { Input } from "@/components/ui/input";
import { DeleteClipType, Export } from "@/types/export";
import axios from "axios";
import { useCallback, useEffect, useMemo, useState } from "react";
import { LuFolderX } from "react-icons/lu";
import useSWR from "swr";
function Exports() {
@@ -128,17 +129,19 @@ function Exports() {
</DialogContent>
</Dialog>
<div className="flex w-full items-center justify-center p-2">
<Input
className="w-full bg-muted md:w-1/3"
placeholder="Search"
value={search}
onChange={(e) => setSearch(e.target.value)}
/>
</div>
{exports && (
<div className="flex w-full items-center justify-center p-2">
<Input
className="w-full bg-muted md:w-1/3"
placeholder="Search"
value={search}
onChange={(e) => setSearch(e.target.value)}
/>
</div>
)}
<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">
{Object.values(exports).map((item) => (
<ExportCard
@@ -155,6 +158,11 @@ function Exports() {
/>
))}
</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>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -20,13 +20,13 @@ import {
} from "react-grid-layout";
import "react-grid-layout/css/styles.css";
import "react-resizable/css/styles.css";
import { LivePlayerMode } from "@/types/live";
import { LivePlayerError, LivePlayerMode } from "@/types/live";
import { ASPECT_VERTICAL_LAYOUT, ASPECT_WIDE_LAYOUT } from "@/types/record";
import { Skeleton } from "@/components/ui/skeleton";
import { useResizeObserver } from "@/hooks/resize-observer";
import { isEqual } from "lodash";
import useSWR from "swr";
import { isDesktop, isMobile, isSafari } from "react-device-detect";
import { isDesktop, isMobile } from "react-device-detect";
import BirdseyeLivePlayer from "@/components/player/BirdseyeLivePlayer";
import LivePlayer from "@/components/player/LivePlayer";
import { IoClose } from "react-icons/io5";
@@ -73,6 +73,39 @@ export default function DraggableGridLayout({
const { data: config } = useSWR<FrigateConfig>("config");
const birdseyeConfig = useMemo(() => config?.birdseye, [config]);
// preferred live modes per camera
const [preferredLiveModes, setPreferredLiveModes] = useState<{
[key: string]: LivePlayerMode;
}>({});
useEffect(() => {
if (!cameras) return;
const mseSupported =
"MediaSource" in window || "ManagedMediaSource" in window;
const newPreferredLiveModes = cameras.reduce(
(acc, camera) => {
const isRestreamed =
config &&
Object.keys(config.go2rtc.streams || {}).includes(
camera.live.stream_name,
);
if (!mseSupported) {
acc[camera.name] = isRestreamed ? "webrtc" : "jsmpeg";
} else {
acc[camera.name] = isRestreamed ? "mse" : "jsmpeg";
}
return acc;
},
{} as { [key: string]: LivePlayerMode },
);
setPreferredLiveModes(newPreferredLiveModes);
}, [cameras, config]);
const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);
const [gridLayout, setGridLayout, isGridLayoutLoaded] = usePersistence<
@@ -429,10 +462,21 @@ export default function DraggableGridLayout({
windowVisible && visibleCameras.includes(camera.name)
}
cameraConfig={camera}
preferredLiveMode={isSafari ? "webrtc" : "mse"}
preferredLiveMode={preferredLiveModes[camera.name] ?? "mse"}
onClick={() => {
!isEditMode && onSelectCamera(camera.name);
}}
onError={(e) => {
setPreferredLiveModes((prevModes) => {
const newModes = { ...prevModes };
if (e === "mse-decode") {
newModes[camera.name] = "webrtc";
} else {
newModes[camera.name] = "jsmpeg";
}
return newModes;
});
}}
>
{isEditMode && showCircles && <CornerCircles />}
</LivePlayerGridItem>
@@ -590,6 +634,7 @@ type LivePlayerGridItemProps = {
cameraConfig: CameraConfig;
preferredLiveMode: LivePlayerMode;
onClick: () => void;
onError: (e: LivePlayerError) => void;
};
const LivePlayerGridItem = React.forwardRef<
@@ -609,6 +654,7 @@ const LivePlayerGridItem = React.forwardRef<
cameraConfig,
preferredLiveMode,
onClick,
onError,
...props
},
ref,
@@ -629,6 +675,7 @@ const LivePlayerGridItem = React.forwardRef<
cameraConfig={cameraConfig}
preferredLiveMode={preferredLiveMode}
onClick={onClick}
onError={onError}
containerRef={ref as React.RefObject<HTMLDivElement>}
/>
{children}

View File

@@ -96,7 +96,10 @@ export default function LiveBirdseyeView({
return "jsmpeg";
}
if (isSafari) {
if (
isSafari ||
!("MediaSource" in window || "ManagedMediaSource" in window)
) {
return "webrtc";
}
@@ -108,7 +111,7 @@ export default function LiveBirdseyeView({
}
return (
<TransformWrapper minScale={1.0}>
<TransformWrapper minScale={1.0} wheel={{ smoothStep: 0.005 }}>
<div
ref={mainRef}
className={

View File

@@ -21,7 +21,11 @@ import { TooltipProvider } from "@/components/ui/tooltip";
import { useResizeObserver } from "@/hooks/resize-observer";
import useKeyboardListener from "@/hooks/use-keyboard-listener";
import { CameraConfig, FrigateConfig } from "@/types/frigateConfig";
import { LiveStreamMetadata, VideoResolutionType } from "@/types/live";
import {
LivePlayerError,
LiveStreamMetadata,
VideoResolutionType,
} from "@/types/live";
import { CameraPtzInfo } from "@/types/ptz";
import { RecordingStartingPoint } from "@/types/record";
import React, {
@@ -33,6 +37,7 @@ import React, {
} from "react";
import {
isDesktop,
isFirefox,
isIOS,
isMobile,
isTablet,
@@ -72,6 +77,7 @@ import {
import { useNavigate } from "react-router-dom";
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
import useSWR from "swr";
import { cn } from "@/lib/utils";
type LiveCameraViewProps = {
config?: FrigateConfig;
@@ -216,6 +222,10 @@ export default function LiveCameraView({
return "jsmpeg";
}
if (!("MediaSource" in window || "ManagedMediaSource" in window)) {
return "webrtc";
}
return "mse";
}, [lowBandwidth, mic, webRTC, isRestreamed]);
@@ -275,8 +285,17 @@ export default function LiveCameraView({
}
}, [fullscreen, isPortrait, cameraAspectRatio, containerAspectRatio]);
const handleError = useCallback((e: LivePlayerError) => {
if (e == "mse-decode") {
setWebRTC(true);
} else {
setWebRTC(false);
setLowBandwidth(true);
}
}, []);
return (
<TransformWrapper minScale={1.0}>
<TransformWrapper minScale={1.0} wheel={{ smoothStep: 0.005 }}>
<div
ref={mainRef}
className={
@@ -353,7 +372,7 @@ export default function LiveCameraView({
onClick={toggleFullscreen}
/>
)}
{!isIOS && (
{!isIOS && !isFirefox && (
<CameraFeatureToggle
className="p-2 md:p-0"
variant={fullscreen ? "overlay" : "primary"}
@@ -380,7 +399,7 @@ export default function LiveCameraView({
onClick={() => setMic(!mic)}
/>
)}
{supportsAudioOutput && (
{supportsAudioOutput && preferredLiveMode != "jsmpeg" && (
<CameraFeatureToggle
className="p-2 md:p-0"
variant={fullscreen ? "overlay" : "primary"}
@@ -435,26 +454,21 @@ export default function LiveCameraView({
pip={pip}
setFullResolution={setFullResolution}
containerRef={containerRef}
onError={(e) => {
if (e == "mse-decode") {
setWebRTC(true);
} else {
setWebRTC(false);
setLowBandwidth(true);
}
}}
onError={handleError}
/>
</div>
{camera.onvif.host != "" && (
<PtzControlPanel
camera={camera.name}
clickOverlay={clickOverlay}
setClickOverlay={setClickOverlay}
/>
)}
</TransformComponent>
</div>
</div>
{camera.onvif.host != "" && (
<div className="flex flex-col items-center justify-center">
<PtzControlPanel
camera={camera.name}
clickOverlay={clickOverlay}
setClickOverlay={setClickOverlay}
/>
</div>
)}
</TransformWrapper>
);
}
@@ -516,7 +530,12 @@ function PtzControlPanel({
);
return (
<div className="absolute inset-x-2 bottom-[10%] flex flex-wrap items-center justify-center gap-1 md:left-[50%] md:-translate-x-[50%] md:flex-nowrap">
<div
className={cn(
"absolute inset-x-2 bottom-[10%] flex select-none flex-wrap items-center justify-center gap-1 md:left-[50%] md:-translate-x-[50%] md:flex-nowrap",
isMobile && "landscape:ml-12",
)}
>
{ptz?.features?.includes("pt") && (
<>
<Button

View File

@@ -7,7 +7,12 @@ import BirdseyeLivePlayer from "@/components/player/BirdseyeLivePlayer";
import LivePlayer from "@/components/player/LivePlayer";
import { Button } from "@/components/ui/button";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import { TooltipProvider } from "@/components/ui/tooltip";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { usePersistence } from "@/hooks/use-persistence";
import { CameraConfig, FrigateConfig } from "@/types/frigateConfig";
import { ReviewSegment } from "@/types/review";
@@ -16,7 +21,6 @@ import {
isDesktop,
isMobile,
isMobileOnly,
isSafari,
isTablet,
} from "react-device-detect";
import useSWR from "swr";
@@ -24,6 +28,9 @@ import DraggableGridLayout from "./DraggableGridLayout";
import { IoClose } from "react-icons/io5";
import { LuLayoutDashboard } from "react-icons/lu";
import { cn } from "@/lib/utils";
import { LivePlayerError, LivePlayerMode } from "@/types/live";
import { FaCompress, FaExpand } from "react-icons/fa";
import { useResizeObserver } from "@/hooks/resize-observer";
type LiveDashboardViewProps = {
cameras: CameraConfig[];
@@ -56,7 +63,7 @@ export default function LiveDashboardView({
// recent events
const { payload: eventUpdate } = useFrigateReviews();
const eventUpdate = useFrigateReviews();
const { data: allEvents, mutate: updateEvents } = useSWR<ReviewSegment[]>([
"review",
{ limit: 10, severity: "alert" },
@@ -99,6 +106,47 @@ export default function LiveDashboardView({
// camera live views
const [autoLiveView] = usePersistence("autoLiveView", true);
const [preferredLiveModes, setPreferredLiveModes] = useState<{
[key: string]: LivePlayerMode;
}>({});
useEffect(() => {
if (!cameras) return;
const mseSupported =
"MediaSource" in window || "ManagedMediaSource" in window;
const newPreferredLiveModes = cameras.reduce(
(acc, camera) => {
const isRestreamed =
config &&
Object.keys(config.go2rtc.streams || {}).includes(
camera.live.stream_name,
);
if (!mseSupported) {
acc[camera.name] = isRestreamed ? "webrtc" : "jsmpeg";
} else {
acc[camera.name] = isRestreamed ? "mse" : "jsmpeg";
}
return acc;
},
{} as { [key: string]: LivePlayerMode },
);
setPreferredLiveModes(newPreferredLiveModes);
}, [cameras, config]);
const [{ height: containerHeight }] = useResizeObserver(containerRef);
const hasScrollbar = useMemo(() => {
if (containerHeight && containerRef.current) {
return (
containerRef.current.offsetHeight < containerRef.current.scrollHeight
);
}
}, [containerRef, containerHeight]);
const [windowVisible, setWindowVisible] = useState(true);
const visibilityListener = useCallback(() => {
setWindowVisible(document.visibilityState == "visible");
@@ -161,6 +209,21 @@ export default function LiveDashboardView({
const birdseyeConfig = useMemo(() => config?.birdseye, [config]);
const handleError = useCallback(
(cameraName: string, error: LivePlayerError) => {
setPreferredLiveModes((prevModes) => {
const newModes = { ...prevModes };
if (error === "mse-decode") {
newModes[cameraName] = "webrtc";
} else {
newModes[cameraName] = "jsmpeg";
}
return newModes;
});
},
[setPreferredLiveModes],
);
return (
<div
className="scrollbar-container size-full overflow-y-auto px-1 pt-2 md:p-2"
@@ -239,63 +302,95 @@ export default function LiveDashboardView({
)}
{!cameraGroup || cameraGroup == "default" || isMobileOnly ? (
<div
className={cn(
"mt-2 grid grid-cols-1 gap-2 px-2 md:gap-4",
mobileLayout == "grid" &&
"grid-cols-2 xl:grid-cols-3 3xl:grid-cols-4",
isMobile && "px-0",
)}
>
{includeBirdseye && birdseyeConfig?.enabled && (
<>
<div
className={cn(
"mt-2 grid grid-cols-1 gap-2 px-2 md:gap-4",
mobileLayout == "grid" &&
"grid-cols-2 xl:grid-cols-3 3xl:grid-cols-4",
isMobile && "px-0",
)}
>
{includeBirdseye && birdseyeConfig?.enabled && (
<div
className={(() => {
const aspectRatio =
birdseyeConfig.width / birdseyeConfig.height;
if (aspectRatio > 2) {
return `${mobileLayout == "grid" && "col-span-2"} aspect-wide`;
} else if (aspectRatio < 1) {
return `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
return "aspect-video";
}
})()}
ref={birdseyeContainerRef}
>
<BirdseyeLivePlayer
birdseyeConfig={birdseyeConfig}
liveMode={birdseyeConfig.restream ? "mse" : "jsmpeg"}
onClick={() => onSelectCamera("birdseye")}
containerRef={birdseyeContainerRef}
/>
</div>
)}
{cameras.map((camera) => {
let grow;
const aspectRatio = camera.detect.width / camera.detect.height;
if (aspectRatio > 2) {
grow = `${mobileLayout == "grid" && "col-span-2"} aspect-wide`;
} else if (aspectRatio < 1) {
grow = `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
grow = "aspect-video";
}
return (
<LivePlayer
cameraRef={cameraRef}
key={camera.name}
className={`${grow} rounded-lg bg-black md:rounded-2xl`}
windowVisible={
windowVisible && visibleCameras.includes(camera.name)
}
cameraConfig={camera}
preferredLiveMode={preferredLiveModes[camera.name] ?? "mse"}
autoLive={autoLiveView}
onClick={() => onSelectCamera(camera.name)}
onError={(e) => handleError(camera.name, e)}
/>
);
})}
</div>
{isDesktop && (
<div
className={(() => {
const aspectRatio =
birdseyeConfig.width / birdseyeConfig.height;
if (aspectRatio > 2) {
return `${mobileLayout == "grid" && "col-span-2"} aspect-wide`;
} else if (aspectRatio < 1) {
return `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
return "aspect-video";
}
})()}
ref={birdseyeContainerRef}
className={cn(
"fixed",
isDesktop && "bottom-12 lg:bottom-9",
isMobile && "bottom-12 lg:bottom-16",
hasScrollbar && isDesktop ? "right-6" : "right-3",
"z-50 flex flex-row gap-2",
)}
>
<BirdseyeLivePlayer
birdseyeConfig={birdseyeConfig}
liveMode={birdseyeConfig.restream ? "mse" : "jsmpeg"}
onClick={() => onSelectCamera("birdseye")}
containerRef={birdseyeContainerRef}
/>
<Tooltip>
<TooltipTrigger asChild>
<div
className="cursor-pointer rounded-lg bg-secondary text-secondary-foreground opacity-60 transition-all duration-300 hover:bg-muted hover:opacity-100"
onClick={toggleFullscreen}
>
{fullscreen ? (
<FaCompress className="size-5 md:m-[6px]" />
) : (
<FaExpand className="size-5 md:m-[6px]" />
)}
</div>
</TooltipTrigger>
<TooltipContent>
{fullscreen ? "Exit Fullscreen" : "Fullscreen"}
</TooltipContent>
</Tooltip>
</div>
)}
{cameras.map((camera) => {
let grow;
const aspectRatio = camera.detect.width / camera.detect.height;
if (aspectRatio > 2) {
grow = `${mobileLayout == "grid" && "col-span-2"} aspect-wide`;
} else if (aspectRatio < 1) {
grow = `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
grow = "aspect-video";
}
return (
<LivePlayer
cameraRef={cameraRef}
key={camera.name}
className={`${grow} rounded-lg bg-black md:rounded-2xl`}
windowVisible={
windowVisible && visibleCameras.includes(camera.name)
}
cameraConfig={camera}
preferredLiveMode={isSafari ? "webrtc" : "mse"}
autoLive={autoLiveView}
onClick={() => onSelectCamera(camera.name)}
/>
);
})}
</div>
</>
) : (
<DraggableGridLayout
cameras={cameras}

View File

@@ -0,0 +1,505 @@
import Heading from "@/components/ui/heading";
import { useCallback, useContext, useEffect, useMemo, useState } from "react";
import { Toaster } from "sonner";
import { toast } from "sonner";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Separator } from "../../components/ui/separator";
import { Button } from "../../components/ui/button";
import useSWR from "swr";
import { FrigateConfig } from "@/types/frigateConfig";
import { Checkbox } from "@/components/ui/checkbox";
import ActivityIndicator from "@/components/indicators/activity-indicator";
import { StatusBarMessagesContext } from "@/context/statusbar-provider";
import axios from "axios";
import { Link } from "react-router-dom";
import { LuExternalLink } from "react-icons/lu";
import { capitalizeFirstLetter } from "@/utils/stringUtil";
import { MdCircle } from "react-icons/md";
import { cn } from "@/lib/utils";
type CameraSettingsViewProps = {
selectedCamera: string;
setUnsavedChanges: React.Dispatch<React.SetStateAction<boolean>>;
};
type CameraReviewSettingsValueType = {
alerts_zones: string[];
detections_zones: string[];
};
export default function CameraSettingsView({
selectedCamera,
setUnsavedChanges,
}: CameraSettingsViewProps) {
const { data: config, mutate: updateConfig } =
useSWR<FrigateConfig>("config");
const cameraConfig = useMemo(() => {
if (config && selectedCamera) {
return config.cameras[selectedCamera];
}
}, [config, selectedCamera]);
const [changedValue, setChangedValue] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [selectDetections, setSelectDetections] = useState(false);
const { addMessage, removeMessage } = useContext(StatusBarMessagesContext)!;
// zones and labels
const zones = useMemo(() => {
if (cameraConfig) {
return Object.entries(cameraConfig.zones).map(([name, zoneData]) => ({
camera: cameraConfig.name,
name,
objects: zoneData.objects,
color: zoneData.color,
}));
}
}, [cameraConfig]);
const alertsLabels = useMemo(() => {
return cameraConfig?.review.alerts.labels
? cameraConfig.review.alerts.labels
.map((label) => label.replaceAll("_", " "))
.join(", ")
: "";
}, [cameraConfig]);
const detectionsLabels = useMemo(() => {
return cameraConfig?.review.detections.labels
? cameraConfig.review.detections.labels
.map((label) => label.replaceAll("_", " "))
.join(", ")
: "";
}, [cameraConfig]);
// form
const formSchema = z.object({
alerts_zones: z.array(z.string()),
detections_zones: z.array(z.string()),
});
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
mode: "onChange",
defaultValues: {
alerts_zones: cameraConfig?.review.alerts.required_zones || [],
detections_zones: cameraConfig?.review.detections.required_zones || [],
},
});
const watchedAlertsZones = form.watch("alerts_zones");
const watchedDetectionsZones = form.watch("detections_zones");
const handleCheckedChange = useCallback(
(isChecked: boolean) => {
if (!isChecked) {
form.reset({
alerts_zones: watchedAlertsZones,
detections_zones: [],
});
}
setChangedValue(true);
setSelectDetections(isChecked as boolean);
},
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
[watchedAlertsZones],
);
const saveToConfig = useCallback(
async (
{ alerts_zones, detections_zones }: CameraReviewSettingsValueType, // values submitted via the form
) => {
const createQuery = (zones: string[], type: "alerts" | "detections") =>
zones.length
? zones
.map(
(zone) =>
`&cameras.${selectedCamera}.review.${type}.required_zones=${zone}`,
)
.join("")
: cameraConfig?.review[type]?.required_zones &&
cameraConfig?.review[type]?.required_zones.length > 0
? `&cameras.${selectedCamera}.review.${type}.required_zones`
: "";
const alertQueries = createQuery(alerts_zones, "alerts");
const detectionQueries = createQuery(detections_zones, "detections");
axios
.put(`config/set?${alertQueries}${detectionQueries}`, {
requires_restart: 0,
})
.then((res) => {
if (res.status === 200) {
toast.success(
`Review classification configuration has been saved. Restart Frigate to apply changes.`,
{
position: "top-center",
},
);
updateConfig();
} else {
toast.error(`Failed to save config changes: ${res.statusText}`, {
position: "top-center",
});
}
})
.catch((error) => {
toast.error(
`Failed to save config changes: ${error.response.data.message}`,
{ position: "top-center" },
);
})
.finally(() => {
setIsLoading(false);
});
},
[updateConfig, setIsLoading, selectedCamera, cameraConfig],
);
const onCancel = useCallback(() => {
if (!cameraConfig) {
return;
}
setChangedValue(false);
setUnsavedChanges(false);
removeMessage(
"camera_settings",
`review_classification_settings_${selectedCamera}`,
);
form.reset({
alerts_zones: cameraConfig?.review.alerts.required_zones ?? [],
detections_zones: cameraConfig?.review.detections.required_zones || [],
});
setSelectDetections(
!!cameraConfig?.review.detections.required_zones?.length,
);
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [removeMessage, selectedCamera, setUnsavedChanges, cameraConfig]);
useEffect(() => {
onCancel();
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedCamera]);
useEffect(() => {
if (changedValue) {
addMessage(
"camera_settings",
`Unsaved review classification settings for ${capitalizeFirstLetter(selectedCamera)}`,
undefined,
`review_classification_settings_${selectedCamera}`,
);
} else {
removeMessage(
"camera_settings",
`review_classification_settings_${selectedCamera}`,
);
}
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [changedValue, selectedCamera]);
function onSubmit(values: z.infer<typeof formSchema>) {
setIsLoading(true);
saveToConfig(values as CameraReviewSettingsValueType);
}
useEffect(() => {
document.title = "Camera Settings - Frigate";
}, []);
if (!cameraConfig && !selectedCamera) {
return <ActivityIndicator />;
}
return (
<>
<div className="flex size-full flex-col md:flex-row">
<Toaster position="top-center" closeButton={true} />
<div className="scrollbar-container order-last mb-10 mt-2 flex h-full w-full flex-col overflow-y-auto rounded-lg border-[1px] border-secondary-foreground bg-background_alt p-2 md:order-none md:mb-0 md:mr-2 md:mt-0">
<Heading as="h3" className="my-2">
Camera Settings
</Heading>
<Separator className="my-2 flex bg-secondary" />
<Heading as="h4" className="my-2">
Review Classification
</Heading>
<div className="max-w-6xl">
<div className="mb-5 mt-2 flex max-w-5xl flex-col gap-2 text-sm text-primary-variant">
<p>
Frigate categorizes review items as Alerts and Detections. By
default, all <em>person</em> and <em>car</em> objects are
considered Alerts. You can refine categorization of your review
items by configuring required zones for them.
</p>
<div className="flex items-center text-primary">
<Link
to="https://docs.frigate.video/configuration/review"
target="_blank"
rel="noopener noreferrer"
className="inline"
>
Read the Documentation{" "}
<LuExternalLink className="ml-2 inline-flex size-3" />
</Link>
</div>
</div>
</div>
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="mt-2 space-y-6"
>
<div
className={cn(
"w-full max-w-5xl space-y-0",
zones &&
zones?.length > 0 &&
"grid items-start gap-5 md:grid-cols-2",
)}
>
<FormField
control={form.control}
name="alerts_zones"
render={() => (
<FormItem>
{zones && zones?.length > 0 ? (
<>
<div className="mb-2">
<FormLabel className="flex flex-row items-center text-base">
Alerts{" "}
<MdCircle className="ml-3 size-2 text-severity_alert" />
</FormLabel>
<FormDescription>
Select zones for Alerts
</FormDescription>
</div>
<div className="max-w-md rounded-lg bg-secondary p-4 md:max-w-full">
{zones?.map((zone) => (
<FormField
key={zone.name}
control={form.control}
name="alerts_zones"
render={({ field }) => {
return (
<FormItem
key={zone.name}
className="mb-3 flex flex-row items-center space-x-3 space-y-0 last:mb-0"
>
<FormControl>
<Checkbox
className="size-5 text-white accent-white data-[state=checked]:bg-selected data-[state=checked]:text-white"
checked={field.value?.includes(
zone.name,
)}
onCheckedChange={(checked) => {
setChangedValue(true);
return checked
? field.onChange([
...field.value,
zone.name,
])
: field.onChange(
field.value?.filter(
(value) =>
value !== zone.name,
),
);
}}
/>
</FormControl>
<FormLabel className="font-normal capitalize">
{zone.name.replaceAll("_", " ")}
</FormLabel>
</FormItem>
);
}}
/>
))}
</div>
</>
) : (
<div className="font-normal text-destructive">
No zones are defined for this camera.
</div>
)}
<FormMessage />
<div className="text-sm">
All {alertsLabels} objects
{watchedAlertsZones && watchedAlertsZones.length > 0
? ` detected in ${watchedAlertsZones.map((zone) => capitalizeFirstLetter(zone).replaceAll("_", " ")).join(", ")}`
: ""}{" "}
on{" "}
{capitalizeFirstLetter(
cameraConfig?.name ?? "",
).replaceAll("_", " ")}{" "}
will be shown as Alerts.
</div>
</FormItem>
)}
/>
<FormField
control={form.control}
name="detections_zones"
render={() => (
<FormItem>
{zones && zones?.length > 0 && (
<>
<div className="mb-2">
<FormLabel className="flex flex-row items-center text-base">
Detections{" "}
<MdCircle className="ml-3 size-2 text-severity_detection" />
</FormLabel>
{selectDetections && (
<FormDescription>
Select zones for Detections
</FormDescription>
)}
</div>
{selectDetections && (
<div className="max-w-md rounded-lg bg-secondary p-4 md:max-w-full">
{zones?.map((zone) => (
<FormField
key={zone.name}
control={form.control}
name="detections_zones"
render={({ field }) => {
return (
<FormItem
key={zone.name}
className="mb-3 flex flex-row items-center space-x-3 space-y-0 last:mb-0"
>
<FormControl>
<Checkbox
className="size-5 text-white accent-white data-[state=checked]:bg-selected data-[state=checked]:text-white"
checked={field.value?.includes(
zone.name,
)}
onCheckedChange={(checked) => {
return checked
? field.onChange([
...field.value,
zone.name,
])
: field.onChange(
field.value?.filter(
(value) =>
value !== zone.name,
),
);
}}
/>
</FormControl>
<FormLabel className="font-normal capitalize">
{zone.name.replaceAll("_", " ")}
</FormLabel>
</FormItem>
);
}}
/>
))}
</div>
)}
<FormMessage />
<div className="mb-0 flex flex-row items-center gap-2">
<Checkbox
id="select-detections"
className="size-5 text-white accent-white data-[state=checked]:bg-selected data-[state=checked]:text-white"
checked={selectDetections}
onCheckedChange={handleCheckedChange}
/>
<div className="grid gap-1.5 leading-none">
<label
htmlFor="select-detections"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Limit detections to specific zones
</label>
</div>
</div>
</>
)}
<div className="text-sm">
All {detectionsLabels} objects{" "}
<em>not classified as Alerts</em>{" "}
{watchedDetectionsZones &&
watchedDetectionsZones.length > 0
? ` that are detected in ${watchedDetectionsZones.map((zone) => capitalizeFirstLetter(zone).replaceAll("_", " ")).join(", ")}`
: ""}{" "}
on{" "}
{capitalizeFirstLetter(
cameraConfig?.name ?? "",
).replaceAll("_", " ")}{" "}
will be shown as Detections
{(!selectDetections ||
(watchedDetectionsZones &&
watchedDetectionsZones.length === 0)) &&
", regardless of zone"}
.
</div>
</FormItem>
)}
/>
</div>
<Separator className="my-2 flex bg-secondary" />
<div className="flex w-full flex-row items-center gap-2 pt-2 md:w-[25%]">
<Button
className="flex flex-1"
onClick={onCancel}
type="button"
>
Cancel
</Button>
<Button
variant="select"
disabled={isLoading}
className="flex flex-1"
type="submit"
>
{isLoading ? (
<div className="flex flex-row items-center gap-2">
<ActivityIndicator />
<span>Saving...</span>
</div>
) : (
"Save"
)}
</Button>
</div>
</form>
</Form>
</div>
</div>
</>
);
}

View File

@@ -26,7 +26,7 @@ export default function CameraMetrics({
);
const [statsHistory, setStatsHistory] = useState<FrigateStats[]>([]);
const { payload: updatedStats } = useFrigateStats();
const updatedStats = useFrigateStats();
useEffect(() => {
if (initialStats == undefined || initialStats.length == 0) {

View File

@@ -40,7 +40,7 @@ export default function GeneralMetrics({
);
const [statsHistory, setStatsHistory] = useState<FrigateStats[]>([]);
const { payload: updatedStats } = useFrigateStats();
const updatedStats = useFrigateStats();
useEffect(() => {
if (initialStats == undefined || initialStats.length == 0) {

View File

@@ -103,6 +103,12 @@ module.exports = {
audio_review: {
DEFAULT: "hsl(var(--audio_review))",
},
neutral: {
DEFAULT: "hsl(var(--neutral))",
},
neutral_variant: {
DEFAULT: "hsl(var(--neutral_variant))",
},
},
keyframes: {
"accordion-down": {

View File

@@ -13,6 +13,8 @@
--secondary: 210 40% 90.1%;
--secondary-foreground: 222.2 47.4% 61.2%;
--secondary-highlight: 210 40% 94%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 46.3% 46.9%;
--accent: 210 40% 80.1%;
@@ -42,6 +44,8 @@
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 60% 78%;
--secondary-highlight: 217.2 32.6% 25.5%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;

View File

@@ -39,6 +39,12 @@
--secondary-highlight: hsl(0, 0%, 94%);
--secondary-highlight: 0 0% 94%;
--neutral: hsl(0, 0%, 45.1%);
--neutral: 0 0% 45.1%;
--neutral_variant: hsl(0, 0%, 32.2%);
--neutral_variant: 0 0% 32.2%;
--muted: hsl(210, 40%, 96.1%);
--muted: 210 40% 96.1%;
@@ -137,6 +143,12 @@
--secondary-highlight: hsl(0, 0%, 25%);
--secondary-highlight: 0 0% 25%;
--neutral: hsl(0, 0%, 45.1%);
--neutral: 0 0% 45.1%;
--neutral_variant: hsl(0, 0%, 32.2%);
--neutral_variant: 0 0% 32.2%;
--muted: hsl(0, 0%, 12%);
--muted: 0 0% 12%;

View File

@@ -1,59 +0,0 @@
@layer base {
.theme-gold.light {
--background: 38 77% 88%;
--background-alt: 39 100% 85%;
--foreground: 16 43% 34%;
--muted: 28 46% 56%;
--muted-foreground: 16 43% 34%;
--popover: 38 77% 88%;
--popover-foreground: 16 43% 34%;
--border: 28 46% 56%;
--input: 28 46% 56%;
--card: 38 77% 88%;
--card-foreground: 16 43% 34%;
--primary: 28 46% 56%;
--primary-variant: 28 46% 46%;
--primary-foreground: 60 70% 90%;
--secondary: 39 100% 73%;
--secondary-foreground: 16 43% 34%;
--secondary-highlight: 39 100% 80%;
--accent: 39 100% 73%;
--accent-foreground: 16 43% 34%;
--destructive: 16 43% 34%;
--destructive-foreground: 38 77% 88%;
--warning: 45 100% 51%;
--warning-foreground: 16 43% 34%;
--ring: 28 46% 56%;
--selected: 39 100% 73%;
--selected-foreground: 16 43% 34%;
}
.theme-gold.dark {
--background: 28 46% 28%;
--background-alt: 28 46% 34%;
--foreground: 38 77% 88%;
--muted: 28 46% 56%;
--muted-foreground: 38 77% 88%;
--popover: 25 45% 34%;
--popover-foreground: 38 77% 88%;
--border: 28 46% 56%;
--input: 28 46% 56%;
--card: 16 43% 34%;
--card-foreground: 38 77% 88%;
--primary: 28 46% 50%;
--primary-variant: 28 46% 46%;
--primary-foreground: 60 70% 90%;
--secondary: 39 60% 63%;
--secondary-foreground: 28 50% 44%;
--secondary-highlight: 39 100% 65%;
--accent: 39 100% 52%;
--accent-foreground: 16 43% 34%;
--destructive: 38 77% 88%;
--destructive-foreground: 16 43% 34%;
--warning: 45 100% 51%;
--warning-foreground: 16 43% 34%;
--ring: 28 46% 56%;
--selected: 39 100% 52%;
--selected-foreground: 16 43% 34%;
}
}

View File

@@ -13,6 +13,8 @@
--secondary: 145 34.8% 85.9%;
--secondary-foreground: 145 35.9% 50%;
--secondary-highlight: 145 70% 92%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--muted: 145 14.8% 75.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 145 34.8% 85.9%;
@@ -42,6 +44,8 @@
--secondary: 145 13.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--secondary-highlight: 145 30% 20%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--muted: 145 20% 15%;
--muted-foreground: 145 25% 64.9%;
--accent: 145 16.5% 25.1%;

View File

@@ -0,0 +1,185 @@
@layer base {
.theme-high-contrast.light {
--background: hsl(0, 0%, 100%);
--background: 0 0% 100%;
--background-alt: hsl(0, 0%, 99.5%);
--background-alt: 0 0% 99.5%;
--foreground: hsl(222.2, 84%, 4.9%);
--foreground: 222.2 84% 4.9%;
--card: hsl(0, 0%, 100%);
--card: 0 0% 100%;
--card-foreground: hsl(222.2, 84%, 4.9%);
--card-foreground: 222.2 84% 4.9%;
--popover: hsl(0, 0%, 100%);
--popover: 0 0% 100%;
--popover-foreground: hsl(222.2, 84%, 4.9%);
--popover-foreground: 222.2 84% 4.9%;
--primary: hsl(222.2, 37.4%, 1.2%);
--primary: 222.2 47.4% 1.2%;
--primary-variant: hsl(222.2, 37.4%, 4.2%);
--primary-variant: 222.2 47.4% 4.2%;
--primary-foreground: hsl(210, 40%, 98%);
--primary-foreground: 210 40% 98%;
--secondary: hsl(0, 0%, 98.1%);
--secondary: 0 0% 98.1%;
--secondary-foreground: hsl(222.2, 17.4%, 6.2%);
--secondary-foreground: 222.2 17.4% 6.2%;
--secondary-highlight: hsl(0, 0%, 84%);
--secondary-highlight: 0 0% 84%;
--neutral: hsl(0, 0%, 5.1%);
--neutral: 0 0% 5.1%;
--neutral_variant: hsl(0, 0%, 2.2%);
--neutral_variant: 0 0% 2.2%;
--muted: hsl(0, 0%, 94.1%);
--muted: 0 0% 94.1%;
--muted-foreground: hsl(215.4, 6.3%, 46.9%);
--muted-foreground: 215.4 6.3% 46.9%;
--accent: hsl(0, 0%, 94.1%);
--accent: 0 0% 94.1%;
--accent-foreground: hsl(222.2, 47.4%, 11.2%);
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: hsl(0, 84.2%, 60.2%);
--destructive: 0 84.2% 60.2%;
--destructive-foreground: hsl(0, 100%, 83%);
--destructive-foreground: 0 100% 83%;
--warning: hsl(17, 87%, 18%);
--warning: 17 87% 18%;
--warning-foreground: hsl(32, 100%, 74%);
--warning-foreground: 32 100% 74%;
--border: hsl(214.3, 31.8%, 91.4%);
--border: 214.3 31.8% 91.4%;
--input: hsl(0, 0%, 85%);
--input: 0 0% 85%;
--ring: hsla(0, 0%, 25%, 0%);
--ring: 0 0% 25% 0%;
--selected: hsl(228, 89%, 63%);
--selected: 228 89% 63%;
--selected-foreground: hsl(0 0% 100%);
--selected-foreground: 0 0% 100%;
--severity_alert: var(--red-800);
--severity_alert_dimmed: var(--red-500);
--severity_detection: var(--orange-600);
--severity_detection_dimmed: var(--orange-400);
--severity_significant_motion: var(--yellow-400);
--severity_significant_motion_dimmed: var(--yellow-200);
--motion_review: hsl(44, 94%, 50%);
--motion_review: 44 94% 50%;
--motion_review_dimmed: hsl(44, 60%, 40%);
--motion_review_dimmed: 44 60% 40%;
--audio_review: hsl(228, 94%, 67%);
--audio_review: 228 94% 67%;
}
.theme-high-contrast.dark {
--background: hsl(0, 0, 0%);
--background: 0 0% 0%;
--background-alt: hsl(0, 0, 3%);
--background-alt: 0 0% 3%;
--foreground: hsl(0, 0%, 100%);
--foreground: 0, 0%, 100%;
--card: hsl(0, 0%, 11%);
--card: 0, 0%, 11%;
--card-foreground: hsl(210, 40%, 98%);
--card-foreground: 210 40% 98%;
--popover: hsl(0, 0%, 11%);
--popover: 0, 0%, 11%;
--popover-foreground: hsl(0, 0%, 98%);
--popover-foreground: 0 0% 98%;
--primary: hsl(0, 0%, 91%);
--primary: 0 0% 91%;
--primary-variant: hsl(0, 0%, 64%);
--primary-variant: 0 0% 64%;
--primary-foreground: hsl(0, 0%, 29%);
--primary-foreground: 0 0% 29%;
--secondary: hsl(0, 0%, 5%);
--secondary: 0 0% 5%;
--secondary-foreground: hsl(0, 0%, 82%);
--secondary-foreground: 0 0% 82%;
--secondary-highlight: hsl(0, 0%, 45%);
--secondary-highlight: 0 0% 45%;
--neutral: hsl(0, 0%, 97.1%);
--neutral: 0 0% 97.1%;
--neutral_variant: hsl(0, 0%, 92.2%);
--neutral_variant: 0 0% 92.2%;
--muted: hsl(0, 0%, 22%);
--muted: 0 0% 22%;
--muted-foreground: hsl(0, 0%, 82%);
--muted-foreground: 0 0% 82%;
--accent: hsl(0, 0%, 11%);
--accent: 0 0% 11%;
--accent-foreground: hsl(210, 40%, 95%);
--accent-foreground: 210 40% 95%;
--destructive: hsl(0, 62.8%, 30.6%);
--destructive: 0 62.8% 30.6%;
--destructive-foreground: hsl(0, 100%, 83%);
--destructive-foreground: 0 100% 83%;
--warning: hsl(17, 87%, 18%);
--warning: 17 87% 18%;
--warning-foreground: hsl(32, 100%, 74%);
--warning-foreground: 32 100% 74%;
--border: hsl(0, 0%, 92%);
--border: 0 0% 92%;
--input: hsl(0, 0%, 45%);
--input: 0 0% 45%;
--ring: hsla(0, 0%, 25%, 0%);
--ring: 0 0% 25% 0%;
}
}

View File

@@ -1,59 +0,0 @@
@layer base {
.theme-nature.light {
--background: 70 30% 92%;
--background-alt: 58 45% 89%;
--foreground: 187 33% 43%;
--muted: 70 20% 68%;
--muted-foreground: 187 33% 43%;
--popover: 58 45% 83%;
--popover-foreground: 187 33% 43%;
--border: 93 28% 56%;
--input: 93 28% 56%;
--card: 58 65% 83%;
--card-foreground: 187 33% 43%;
--primary: 93 28% 56%;
--primary-variant: 93 28% 46%;
--primary-foreground: 58 65% 83%;
--secondary: 70 20% 78%;
--secondary-foreground: 187 33% 43%;
--secondary-highlight: 70 30% 75%;
--accent: 70 20% 68%;
--accent-foreground: 187 33% 43%;
--destructive: 187 33% 43%;
--destructive-foreground: 58 65% 83%;
--warning: 45 100% 51%;
--warning-foreground: 187 33% 43%;
--ring: 93 28% 56%;
--selected: 70 20% 68%;
--selected-foreground: 187 33% 43%;
}
.theme-nature.dark {
--background: 187 33% 43%;
--background-alt: 187 33% 33%;
--foreground: 58 65% 83%;
--muted: 70 20% 68%;
--muted-foreground: 58 65% 83%;
--popover: 187 33% 43%;
--popover-foreground: 58 65% 83%;
--border: 93 28% 56%;
--input: 93 28% 56%;
--card: 187 33% 43%;
--card-foreground: 58 65% 83%;
--primary: 93 38% 36%;
--primary-variant: 93 28% 46%;
--primary-foreground: 187 33% 43%;
--secondary: 70 20% 58%;
--secondary-foreground: 58 65% 83%;
--secondary-highlight: 70 30% 60%;
--accent: 70 20% 68%;
--accent-foreground: 58 65% 83%;
--destructive: 58 65% 83%;
--destructive-foreground: 187 33% 43%;
--warning: 45 100% 51%;
--warning-foreground: 187 33% 43%;
--ring: 93 28% 56%;
--selected: 70 20% 68%;
--selected-foreground: 58 65% 83%;
}
}

View File

@@ -1,59 +0,0 @@
@layer base {
.theme-netflix.light {
--background: 0 0% 100%;
--background-alt: 0 0% 96%;
--foreground: 0 0% 0%;
--muted: 0 0% 68%;
--muted-foreground: 0 0% 0%;
--popover: 0 0% 95%;
--popover-foreground: 0 0% 0%;
--border: 0 68% 39%;
--input: 0 68% 39%;
--card: 0 0% 95%;
--card-foreground: 0 0% 0%;
--primary: 0 100% 44%;
--primary-variant: 0 100% 34%;
--primary-foreground: 0 0% 100%;
--secondary: 0 0% 80%;
--secondary-foreground: 0 0% 100%;
--secondary-highlight: 0 0% 10%;
--accent: 0 100% 50%;
--accent-foreground: 0 0% 0%;
--destructive: 0 68% 39%;
--destructive-foreground: 0 0% 100%;
--warning: 45 100% 51%;
--warning-foreground: 0 0% 0%;
--ring: 0 100% 44%;
--selected: 0 100% 44%;
--selected-foreground: 0 0% 100%;
}
.theme-netflix.dark {
--background: 0 0% 0%;
--background-alt: 0 0% 5%;
--foreground: 0 0% 100%;
--muted: 0 0% 50%;
--muted-foreground: 0 0% 100%;
--popover: 0 0% 5%;
--popover-foreground: 0 0% 100%;
--border: 0 68% 39%;
--input: 0 68% 39%;
--card: 0 0% 5%;
--card-foreground: 0 0% 100%;
--primary: 0 70% 44%;
--primary-variant: 0 100% 34%;
--primary-foreground: 0 0% 0%;
--secondary: 0 0% 20%;
--secondary-foreground: 0 0% 40%;
--secondary-highlight: 0 0% 90%;
--accent: 0 100% 50%;
--accent-foreground: 0 0% 100%;
--destructive: 0 68% 39%;
--destructive-foreground: 0 0% 100%;
--warning: 45 100% 51%;
--warning-foreground: 0 0% 0%;
--ring: 0 100% 44%;
--selected: 0 100% 44%;
--selected-foreground: 0 0% 0%;
}
}

View File

@@ -17,6 +17,8 @@
--secondary: 215 14% 80%;
--secondary-foreground: 222 20% 16%;
--secondary-highlight: 215 14% 88%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--accent: 215 14% 80%;
--accent-foreground: 222 20% 16%;
--destructive: 0 80% 50%;
@@ -46,6 +48,8 @@
--secondary: 215 14% 25%;
--secondary-foreground: 222 20% 86%;
--secondary-highlight: 215 14% 35%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--accent: 215 14% 25%;
--accent-foreground: 222 20% 96%;
--destructive: 0 80% 50%;

View File

@@ -1,59 +0,0 @@
@layer base {
.theme-orange.light {
--background: 24 50% 98.3%;
--background-alt: 30 50% 96%;
--foreground: 20 14.3% 4.1%;
--card: 0 0% 100%;
--card-foreground: 20 14.3% 4.1%;
--popover: 24 30% 95%;
--popover-foreground: 24 24.3% 14.1%;
--primary: 24.6 55% 53.1%;
--primary-variant: 24.6 55% 43.1%;
--primary-foreground: 60 9.1% 97.8%;
--secondary: 24 54.8% 95.9%;
--secondary-foreground: 24 79.8% 60%;
--secondary-highlight: 30 50% 92%;
--muted: 24 4.8% 75.9%;
--muted-foreground: 25 25.3% 44.7%;
--accent: 24 14.8% 95.9%;
--accent-foreground: 24 14.8% 10%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 60 9.1% 97.8%;
--warning: 45 100% 51%;
--warning-foreground: 20 14.3% 4.1%;
--border: 20 5.9% 90%;
--input: 24 25.9% 90%;
--ring: 24.6 95% 53.1%;
--selected: 24.6 85% 53.1%;
--selected-foreground: 60 9.1% 97.8%;
}
.theme-orange.dark {
--background: 20 14.3% 4.1%;
--background-alt: 20 14.3% 9.1%;
--foreground: 60 9.1% 97.8%;
--card: 20 14.3% 4.1%;
--card-foreground: 60 9.1% 97.8%;
--popover: 20 14.3% 4.1%;
--popover-foreground: 60 9.1% 97.8%;
--primary: 20.5 90.2% 68.2%;
--primary-variant: 20.5 90.2% 58.2%;
--primary-foreground: 60 9.1% 97.8%;
--secondary: 12 6.5% 15.1%;
--secondary-foreground: 20 49.1% 57.8%;
--secondary-highlight: 12 6.5% 25.1%;
--muted: 20.5 26.5% 15.1%;
--muted-foreground: 20 25.4% 53.9%;
--accent: 20 16.5% 15.1%;
--accent-foreground: 20 19.1% 79.8%;
--destructive: 0 72.2% 50.6%;
--destructive-foreground: 60 9.1% 97.8%;
--warning: 45 100% 51%;
--warning-foreground: 60 9.1% 97.8%;
--border: 12 6.5% 15.1%;
--input: 12 6.5% 15.1%;
--ring: 20.5 90.2% 48.2%;
--selected: 20.5 90.2% 38.2%;
--selected-foreground: 60 9.1% 97.8%;
}
}

View File

@@ -13,6 +13,8 @@
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 0 35.9% 50%;
--secondary-highlight: 0 0% 92%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
@@ -42,6 +44,8 @@
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--secondary-highlight: 0 0% 25.9%;
--neutral: 0 0% 45.1%;
--neutral_variant: 0 0% 32.2%;
--muted: 0 0% 15%;
--muted-foreground: 240 5% 64.9%;
--accent: 12 6.5% 15.1%;