mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-21 21:13:01 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a19e23ae2d | ||
|
|
aadbda1104 | ||
|
|
d04ed58d8f | ||
|
|
8e9607eccd | ||
|
|
190f4e0bd2 | ||
|
|
d3b7d4ea44 | ||
|
|
cc94cbc2da | ||
|
|
2d25f9a8b5 | ||
|
|
7d12583ebc | ||
|
|
c60843cc24 | ||
|
|
dd4134edc9 | ||
|
|
94e570017c | ||
|
|
748cdc5eb2 | ||
|
|
d95245a286 | ||
|
|
ed0f7c34c7 | ||
|
|
dc116ecaf4 | ||
|
|
cf418dd6b6 | ||
|
|
aa42b17911 | ||
|
|
698b1ce628 |
@@ -1,7 +1,7 @@
|
||||
default_target: local
|
||||
|
||||
COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1)
|
||||
VERSION = 0.18.2
|
||||
VERSION = 0.18.3
|
||||
IMAGE_REPO ?= ghcr.io/blakeblackshear/frigate
|
||||
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||
BOARDS= #Initialized empty
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
NGINX_VERSION="1.27.4"
|
||||
VOD_MODULE_VERSION="1.31"
|
||||
SECURE_TOKEN_MODULE_VERSION="1.5"
|
||||
NGINX_VERSION="1.30.7"
|
||||
VOD_MODULE_VERSION="v1.9.1"
|
||||
SET_MISC_MODULE_VERSION="v0.33"
|
||||
NGX_DEVEL_KIT_VERSION="v0.3.3"
|
||||
|
||||
@@ -31,32 +30,27 @@ wget -nv https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
|
||||
tar -zxf nginx-${NGINX_VERSION}.tar.gz -C /tmp/nginx --strip-components=1
|
||||
rm nginx-${NGINX_VERSION}.tar.gz
|
||||
mkdir /tmp/nginx-vod-module
|
||||
wget -nv https://github.com/kaltura/nginx-vod-module/archive/refs/tags/${VOD_MODULE_VERSION}.tar.gz
|
||||
wget -nv https://github.com/dio-az/nginx-vod-module/archive/refs/tags/${VOD_MODULE_VERSION}.tar.gz
|
||||
tar -zxf ${VOD_MODULE_VERSION}.tar.gz -C /tmp/nginx-vod-module --strip-components=1
|
||||
rm ${VOD_MODULE_VERSION}.tar.gz
|
||||
# Patch MAX_CLIPS to allow more clips to be added than the default 128
|
||||
sed -i 's/MAX_CLIPS (128)/MAX_CLIPS (1080)/g' /tmp/nginx-vod-module/vod/media_set.h
|
||||
patch -d /tmp/nginx-vod-module/ -p1 << 'EOF'
|
||||
--- a/vod/avc_hevc_parser.c 2022-06-27 11:38:10.000000000 +0000
|
||||
+++ b/vod/avc_hevc_parser.c 2023-01-16 11:25:10.900521298 +0000
|
||||
@@ -3,6 +3,9 @@
|
||||
--- a/vod/avc_hevc_parser.c
|
||||
+++ b/vod/avc_hevc_parser.c
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
bool_t
|
||||
avc_hevc_parser_rbsp_trailing_bits(bit_reader_state_t* reader)
|
||||
{
|
||||
avc_hevc_parser_rbsp_trailing_bits(bit_reader_state_t* reader) {
|
||||
+ // https://github.com/blakeblackshear/frigate/issues/4572
|
||||
+ return TRUE;
|
||||
+
|
||||
uint32_t one_bit;
|
||||
|
||||
if (reader->stream.eof_reached)
|
||||
if (reader->stream.eof_reached) {
|
||||
EOF
|
||||
|
||||
|
||||
mkdir /tmp/nginx-secure-token-module
|
||||
wget https://github.com/kaltura/nginx-secure-token-module/archive/refs/tags/${SECURE_TOKEN_MODULE_VERSION}.tar.gz
|
||||
tar -zxf ${SECURE_TOKEN_MODULE_VERSION}.tar.gz -C /tmp/nginx-secure-token-module --strip-components=1
|
||||
rm ${SECURE_TOKEN_MODULE_VERSION}.tar.gz
|
||||
|
||||
mkdir /tmp/ngx_devel_kit
|
||||
wget https://github.com/vision5/ngx_devel_kit/archive/refs/tags/${NGX_DEVEL_KIT_VERSION}.tar.gz
|
||||
tar -zxf ${NGX_DEVEL_KIT_VERSION}.tar.gz -C /tmp/ngx_devel_kit --strip-components=1
|
||||
@@ -80,7 +74,6 @@ cd /tmp/nginx
|
||||
--add-module=../ngx_devel_kit \
|
||||
--add-module=../nginx-set-misc-module \
|
||||
--add-module=../nginx-vod-module \
|
||||
--add-module=../nginx-secure-token-module \
|
||||
--with-cc-opt="-O3 -Wno-error=implicit-fallthrough"
|
||||
|
||||
make CC="ccache gcc" -j$(nproc) && make install
|
||||
|
||||
@@ -10,13 +10,15 @@ from ruamel.yaml import YAML
|
||||
|
||||
sys.path.insert(0, "/opt/frigate")
|
||||
from frigate.config.env import substitute_frigate_vars
|
||||
from frigate.const import (
|
||||
BIRDSEYE_PIPE,
|
||||
LIBAVFORMAT_VERSION_MAJOR,
|
||||
)
|
||||
from frigate.const import BIRDSEYE_PIPE
|
||||
from frigate.ffmpeg_presets import parse_preset_hardware_acceleration_encode
|
||||
from frigate.util.config import find_config_file, resolve_ffmpeg_path
|
||||
from frigate.util.config import (
|
||||
find_config_file,
|
||||
is_valid_ffmpeg_path,
|
||||
resolve_ffmpeg_path,
|
||||
)
|
||||
from frigate.util.services import (
|
||||
apply_go2rtc_ffmpeg_config,
|
||||
is_go2rtc_arbitrary_exec_allowed,
|
||||
is_restricted_go2rtc_source,
|
||||
)
|
||||
@@ -92,20 +94,17 @@ if go2rtc_config.get("rtsp", {}).get("password") is not None:
|
||||
|
||||
# ensure ffmpeg path is set correctly
|
||||
path = config.get("ffmpeg", {}).get("path", "default")
|
||||
if not is_valid_ffmpeg_path(path):
|
||||
print(
|
||||
"[ERROR] ffmpeg path contains spaces, quotes or shell characters, using the default ffmpeg instead."
|
||||
)
|
||||
ffmpeg_path = resolve_ffmpeg_path(path, "ffmpeg")
|
||||
|
||||
if go2rtc_config.get("ffmpeg") is None:
|
||||
go2rtc_config["ffmpeg"] = {"bin": ffmpeg_path}
|
||||
elif go2rtc_config["ffmpeg"].get("bin") is None:
|
||||
go2rtc_config["ffmpeg"]["bin"] = ffmpeg_path
|
||||
|
||||
# need to replace ffmpeg command when using ffmpeg4
|
||||
if LIBAVFORMAT_VERSION_MAJOR < 59:
|
||||
rtsp_args = "-fflags nobuffer -flags low_delay -stimeout 10000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}"
|
||||
if go2rtc_config.get("ffmpeg") is None:
|
||||
go2rtc_config["ffmpeg"] = {"rtsp": rtsp_args}
|
||||
elif go2rtc_config["ffmpeg"].get("rtsp") is None:
|
||||
go2rtc_config["ffmpeg"]["rtsp"] = rtsp_args
|
||||
for key in apply_go2rtc_ffmpeg_config(go2rtc_config, ffmpeg_path):
|
||||
print(
|
||||
f"[ERROR] go2rtc option '{key}' was ignored because it is disabled by default for security. "
|
||||
f"Set GO2RTC_ALLOW_ARBITRARY_EXEC=true to enable arbitrary exec."
|
||||
)
|
||||
|
||||
|
||||
for name in list(go2rtc_config.get("streams", {})):
|
||||
@@ -116,7 +115,7 @@ for name in list(go2rtc_config.get("streams", {})):
|
||||
formatted_stream = stream.format(**FRIGATE_ENV_VARS)
|
||||
if is_restricted_go2rtc_source(formatted_stream):
|
||||
print(
|
||||
f"[ERROR] Stream '{name}' uses a restricted source (echo/expr/exec) which is disabled by default for security. "
|
||||
f"[ERROR] Stream '{name}' uses a restricted source (echo/expr/exec or ${{VAR}}) which is disabled by default for security. "
|
||||
f"Set GO2RTC_ALLOW_ARBITRARY_EXEC=true to enable arbitrary exec sources."
|
||||
)
|
||||
del go2rtc_config["streams"][name]
|
||||
@@ -135,7 +134,7 @@ for name in list(go2rtc_config.get("streams", {})):
|
||||
formatted_stream = stream_item.format(**FRIGATE_ENV_VARS)
|
||||
if is_restricted_go2rtc_source(formatted_stream):
|
||||
print(
|
||||
f"[ERROR] Stream '{name}' item {i + 1} uses a restricted source (echo/expr/exec) which is disabled by default for security. "
|
||||
f"[ERROR] Stream '{name}' item {i + 1} uses a restricted source (echo/expr/exec or ${{VAR}}) which is disabled by default for security. "
|
||||
f"Set GO2RTC_ALLOW_ARBITRARY_EXEC=true to enable arbitrary exec sources."
|
||||
)
|
||||
continue
|
||||
@@ -151,7 +150,7 @@ for name in list(go2rtc_config.get("streams", {})):
|
||||
go2rtc_config["streams"][name] = filtered_streams
|
||||
else:
|
||||
print(
|
||||
f"[ERROR] Stream '{name}' was removed because all sources were restricted (echo/expr/exec). "
|
||||
f"[ERROR] Stream '{name}' was removed because all sources were restricted (echo/expr/exec or ${{VAR}}). "
|
||||
f"Set GO2RTC_ALLOW_ARBITRARY_EXEC=true to enable arbitrary exec sources."
|
||||
)
|
||||
del go2rtc_config["streams"][name]
|
||||
|
||||
@@ -5,6 +5,8 @@ location /auth {
|
||||
## Essential Proxy Configuration
|
||||
internal;
|
||||
proxy_pass $upstream_auth;
|
||||
# $go2rtc_stream_proxy is only set by the go2rtc stream locations
|
||||
uninitialized_variable_warn off;
|
||||
|
||||
## Headers
|
||||
|
||||
|
||||
@@ -114,21 +114,23 @@ http {
|
||||
# Smaller segments, faster generation, better browser compatibility
|
||||
vod_hls_container_format fmp4;
|
||||
|
||||
secure_token $args;
|
||||
secure_token_types application/vnd.apple.mpegurl;
|
||||
# fMP4 playlists use EXT-X-MAP, which requires HLS protocol
|
||||
# version 6 (RFC 8216 section 7); the module default is 4
|
||||
vod_hls_version 6;
|
||||
|
||||
# Pass the playlist's query args (e.g. Home Assistant's authSig) on
|
||||
# to every URL in it. These match the only URL endings vod writes
|
||||
# with fmp4 and no subtitles.
|
||||
sub_filter_types application/vnd.apple.mpegurl;
|
||||
sub_filter_once off;
|
||||
sub_filter '.m3u8' '.m3u8$is_args$args';
|
||||
sub_filter '.m4s' '.m4s$is_args$args';
|
||||
sub_filter '.mp4"' '.mp4$is_args$args"';
|
||||
|
||||
add_header Cache-Control "no-store";
|
||||
expires off;
|
||||
|
||||
keepalive_disable safari;
|
||||
|
||||
# vod module returns 502 for non-existent media
|
||||
# https://github.com/kaltura/nginx-vod-module/issues/468
|
||||
error_page 502 =404 /vod-not-found;
|
||||
}
|
||||
|
||||
location = /vod-not-found {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location /stream/ {
|
||||
|
||||
@@ -28,7 +28,7 @@ Many cheaper or older PTZs may not support this standard. Frigate will report an
|
||||
|
||||
The FeatureList on the [ONVIF Conformant Products Database](https://www.onvif.org/conformant-products/) can provide a starting point to determine a camera's compatibility with Frigate's autotracking. Look to see if a camera lists `PTZRelative`, `PTZRelativePanTilt` and/or `PTZRelativeZoom`. These features are required for autotracking, but some cameras still fail to respond even if they claim support.
|
||||
|
||||
A growing list of cameras and brands that have been reported by users to work with Frigate's autotracking can be found [here](cameras.md).
|
||||
The [CCTV Camera Database](https://www.cctv-database.com/) is useful for researching a specific model.
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -192,7 +192,7 @@ In security and surveillance, it's common to use "spotter" cameras in combinatio
|
||||
|
||||
<FaqItem id="which-ptz-camera-should-i-use-for-autotracking" question="Which PTZ camera should I use for autotracking?">
|
||||
|
||||
See the community-maintained list of [ONVIF PTZ camera recommendations](cameras.md#onvif-ptz-camera-recommendations) for cameras and brands reported to work (and not work) with autotracking. This is not an exhaustive list that is frequently updated, so other cameras not listed may also work well. Frigate's autotracking was developed with a Dahua SD1A404XB-GNR (now sold as the EmpireTech PTZ1A4M-4X-S2), and Dahua / EmpireTech PTZs are the most consistently reported as working well.
|
||||
See [ONVIF PTZ camera recommendations](cameras.md#onvif-ptz-camera-recommendations) for how to check a camera's autotracking support before buying. Frigate's autotracking was developed with a Dahua SD1A404XB-GNR (now sold as the EmpireTech PTZ1A4M-4X-S2), and Dahua / EmpireTech PTZs are the most consistently reported as working well.
|
||||
|
||||
When comparing models:
|
||||
|
||||
@@ -209,7 +209,7 @@ No. Reolink cameras (including the TrackMix series) lack the ONVIF FOV RelativeM
|
||||
|
||||
<FaqItem id="im-seeing-an-error-in-the-logs-that-my-camera-is-still-in-onvif-moving-status-what-does-this-mean" question={"I'm seeing an error in the logs that my camera \"is still in ONVIF 'MOVING' status.\" What does this mean?"}>
|
||||
|
||||
There are two possible known reasons for this (and perhaps others yet unknown): a slow PTZ motor or buggy camera firmware. Frigate uses an ONVIF parameter provided by the camera, `MoveStatus`, to determine when the PTZ's motor is moving or idle. According to some users, Hikvision PTZs (even with the latest firmware), are not updating this value after PTZ movement. Unfortunately there is no workaround to this bug in Hikvision firmware, so autotracking will not function correctly and should be disabled in your config. This may also be the case with other non-Hikvision cameras utilizing Hikvision firmware, such as some Annke models. In rare cases the vendor may provide fixed firmware on request; for example, Annke has supplied firmware that resolves this for the CZ504 (see the [camera recommendations list](cameras.md#onvif-ptz-camera-recommendations)).
|
||||
There are two possible known reasons for this (and perhaps others yet unknown): a slow PTZ motor or buggy camera firmware. Frigate uses an ONVIF parameter provided by the camera, `MoveStatus`, to determine when the PTZ's motor is moving or idle. According to some users, Hikvision PTZs (even with the latest firmware), are not updating this value after PTZ movement. Unfortunately there is no workaround to this bug in Hikvision firmware, so autotracking will not function correctly and should be disabled in your config. This may also be the case with other non-Hikvision cameras utilizing Hikvision firmware, such as some Annke models.
|
||||
|
||||
</FaqItem>
|
||||
|
||||
|
||||
@@ -224,36 +224,9 @@ An ONVIF-capable camera that supports relative movement within the field of view
|
||||
|
||||
## ONVIF PTZ camera recommendations
|
||||
|
||||
This list of working and non-working PTZ cameras is based on user feedback. If you'd like to report specific quirks or issues with a manufacturer or camera that would be helpful for other users, open a pull request to add to this list.
|
||||
Before buying a PTZ camera, check its ONVIF support. The [ONVIF Conformant Products Database](https://www.onvif.org/conformant-products/) is the most reliable source. Look at a camera's FeatureList for `PTZRelative`, `PTZRelativePanTilt` and/or `PTZRelativeZoom`. Autotracking requires these features. If they are missing, autotracking will not work, though basic PTZ in the WebUI might. Some cameras still fail to respond even when they claim support. Avoid cameras with no database entry.
|
||||
|
||||
The FeatureList on the [ONVIF Conformant Products Database](https://www.onvif.org/conformant-products/) can provide a starting point to determine a camera's compatibility with Frigate's autotracking. Look to see if a camera lists `PTZRelative`, `PTZRelativePanTilt` and/or `PTZRelativeZoom`. These features are required for autotracking, but some cameras still fail to respond even if they claim support. If they are missing, autotracking will not work (though basic PTZ in the WebUI might). Avoid cameras with no database entry unless they are confirmed as working below.
|
||||
|
||||
| Brand or specific camera | PTZ Controls | Autotracking | Notes |
|
||||
| ---------------------------- | :----------: | :----------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Amcrest | ✅ | ✅ | ⛔️ Generally, Amcrest should work, but some older models (like the common IP2M-841) don't support autotracking |
|
||||
| Amcrest ASH21 | ✅ | ❌ | ONVIF service port: 80 |
|
||||
| Amcrest IP4M-S2112EW-AI | ✅ | ❌ | FOV relative movement not supported. |
|
||||
| Amcrest IP5M-1190EW | ✅ | ❌ | ONVIF Port: 80. FOV relative movement not supported. |
|
||||
| Annke CZ504 | ✅ | ❌ | |
|
||||
| Axis Q-6155E | ✅ | ❌ | ONVIF service port: 80; Camera does not support MoveStatus. |
|
||||
| Ctronics PTZ | ✅ | ❌ | |
|
||||
| Dahua | ✅ | ✅ | Some low-end Dahuas (lite series, picoo series (commonly), among others) have been reported to not support autotracking. These models usually don't have a four digit model number with chassis prefix and options postfix (e.g. DH-P5AE-PV vs DH-SD49825GB-HNR). |
|
||||
| Dahua DH-SD2A500HB | ✅ | ❌ | |
|
||||
| Dahua DH-SD49825GB-HNR | ✅ | ✅ | |
|
||||
| Dahua DH-P5AE-PV | ❌ | ❌ | |
|
||||
| Foscam | ✅ | ❌ | In general support PTZ, but not relative move. There are no official ONVIF certifications and tests available on the ONVIF Conformant Products Database |
|
||||
| Foscam R5 | ✅ | ❌ | |
|
||||
| Foscam SD4 | ✅ | ❌ | |
|
||||
| Hanwha XNP-6550RH | ✅ | ❌ | |
|
||||
| Hikvision | ✅ | ❌ | Incomplete ONVIF support (MoveStatus won't update even on latest firmware) - reported with HWP-N4215IH-DE and DS-2DE3304W-DE, but likely others |
|
||||
| Hikvision DS-2DE3A404IWG-E/W | ✅ | ✅ | |
|
||||
| Reolink | ✅ | ❌ | |
|
||||
| Speco O8P32X | ✅ | ❌ | |
|
||||
| Sunba 405-D20X | ✅ | ❌ | Incomplete ONVIF support reported on original, and 4k models. All models are suspected incompatible. |
|
||||
| Tapo | ✅ | ❌ | Many models supported, ONVIF Service Port: 2020 |
|
||||
| Uniview IPC672LR-AX4DUPK | ✅ | ❌ | Firmware says FOV relative movement is supported, but camera doesn't actually move when sending ONVIF commands |
|
||||
| Uniview IPC6612SR-X33-VG | ✅ | ✅ | Leave `calibrate_on_startup` as `False`. A user has reported that zooming with `absolute` is working. |
|
||||
| Vikylin PTZ-2804X-I2 | ❌ | ❌ | Incomplete ONVIF support |
|
||||
The [CCTV Camera Database](https://www.cctv-database.com/) is an open database of IP camera specifications and is useful for researching a specific model.
|
||||
|
||||
## Setting up camera groups
|
||||
|
||||
|
||||
@@ -334,7 +334,12 @@ When your browser runs into problems playing back your camera streams, it will l
|
||||
|
||||
- **stalled**
|
||||
- What it means: Playback has stalled because the player has fallen too far behind live (extended buffering or no data arriving).
|
||||
- What to try: This is usually indicative of the browser struggling to decode too many high-resolution streams at once. Try selecting a lower-bandwidth stream (substream), reduce the number of live streams open, improve the network connection, or lower the camera resolution. Also check your camera's keyframe (I-frame) interval: shorter intervals make playback start and recover faster. You can also try increasing the timeout value in <NavPath path="Settings > UI" /> .
|
||||
- What to try:
|
||||
- This is usually indicative of the browser struggling to decode too many high-resolution streams at once.
|
||||
- Try selecting a lower-bandwidth stream (substream), reduce the number of live streams open, improve the network connection, or lower the camera resolution.
|
||||
- Also check your camera's keyframe (I-frame) interval: shorter intervals make playback start and recover faster.
|
||||
- You can also try increasing the timeout value in <NavPath path="Settings > UI" /> .
|
||||
- Also ensure your browser doesn't have JavaScript V8 optimizations disabled ("JavaScript optimisation and security" setting in Chrome-based browsers).
|
||||
|
||||
- Possible console messages from the player code:
|
||||
- `Buffer time (10 seconds) exceeded, browser may not be playing media correctly.`
|
||||
|
||||
@@ -87,7 +87,7 @@ Along with picking a detector for your hardware, you will choose a model's **inp
|
||||
|
||||
:::tip
|
||||
|
||||
The best detection accuracy comes from a model trained on images that look like what Frigate actually sees: security camera footage cropped to regions of interest. You can train or fine-tune your own model on images like this and run it as a custom model (see the per-detector sections below), but [Frigate+](/plus) makes this much easier by handling the training for you on images submitted from your own cameras. For YOLOv9, the `s` (small) variant at `320x320` resolution is a good place to start.
|
||||
The best detection accuracy comes from a model trained on images that look like what Frigate actually sees: security camera footage cropped to regions of interest. You can train or fine-tune your own model on images like this and run it as a custom model (see the per-detector sections below), but [Frigate+](/plus) makes this much easier by handling the training for you on images submitted from your own cameras. For YOLOv9, the `s` (small) variant at `320x320` resolution is a good place to start, and the larger `c` variant is available for more powerful hardware.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
@@ -221,6 +221,8 @@ Any `#` parameter on a bare `rtsp://` source disables the backchannel unless the
|
||||
|
||||
For security reasons, the `echo:`, `expr:`, and `exec:` stream sources are disabled by default in go2rtc. These sources allow arbitrary command execution and can pose security risks if misconfigured.
|
||||
|
||||
go2rtc's `${VAR:default}` variable syntax is also disabled by default in stream sources, since its default can name one of those sources. Use Frigate's [`{FRIGATE_*}` substitution](./config.md#environment-variable-substitution) instead.
|
||||
|
||||
If you attempt to use these sources in your configuration, the streams will be removed and an error message will be printed in the logs.
|
||||
|
||||
To enable these sources, you must set the environment variable `GO2RTC_ALLOW_ARBITRARY_EXEC=true`. This can be done in your Docker Compose file or container environment:
|
||||
|
||||
@@ -9,7 +9,7 @@ import CommunityBadge from '@site/src/components/CommunityBadge';
|
||||
|
||||
Cameras that output H.264 video and AAC audio will offer the most compatibility with all features of Frigate and Home Assistant. It is also helpful if your camera supports multiple substreams to allow different resolutions to be used for detection, streaming, and recordings without re-encoding.
|
||||
|
||||
I recommend Dahua, Hikvision, and Amcrest in that order. Dahua edges out Hikvision because they are easier to find and order, not because they are better cameras. I personally use Dahua cameras because they are easier to purchase directly. In my experience Dahua and Hikvision both have multiple streams with configurable resolutions and frame rates and rock solid streams. They also both have models with large sensors well known for excellent image quality at night. Not all the models are equal. Larger sensors are better than higher resolutions; especially at night. Amcrest is the fallback recommendation because they are rebranded Dahuas. They are rebranding the lower end models with smaller sensors or less configuration options.
|
||||
I recommend Dahua and Hikvision. Dahua edges out Hikvision because they are easier to find and order, not because they are better cameras. I personally use Dahua cameras because they are easier to purchase directly. In my experience Dahua and Hikvision both have multiple streams with configurable resolutions and frame rates and rock solid streams. They also both have models with large sensors well known for excellent image quality at night. Not all the models are equal. Larger sensors are better than higher resolutions; especially at night.
|
||||
|
||||
WiFi cameras are not recommended as [their streams are less reliable and cause connection loss and/or lost video data](https://ipcamtalk.com/threads/camera-conflicts.68142/#post-738821), especially when more than a few WiFi cameras will be used at the same time.
|
||||
|
||||
@@ -17,10 +17,9 @@ Many users have reported various issues with 4K-plus Reolink cameras, it is best
|
||||
|
||||
Here are some of the cameras I recommend:
|
||||
|
||||
- <a href="https://amzn.to/4fwoNWA" target="_blank" rel="nofollow noopener sponsored">Loryta(Dahua) IPC-T549M-ALED-S3</a> (affiliate link)
|
||||
- <a href="https://amzn.to/3YXpcMw" target="_blank" rel="nofollow noopener sponsored">Loryta(Dahua) IPC-T54IR-AS</a> (affiliate link)
|
||||
- <a href="https://amzn.to/3AvBHoY" target="_blank" rel="nofollow noopener sponsored">Amcrest IP5M-T1179EW-AI-V3</a> (affiliate link)
|
||||
- <a href="https://www.bhphotovideo.com/c/product/1705511-REG/hikvision_colorvu_ds_2cd2387g2p_lsu_sl_8mp_network.html" target="_blank" rel="nofollow noopener">HIKVISION DS-2CD2387G2P-LSU/SL ColorVu 8MP Panoramic Turret IP Camera</a> (affiliate link)
|
||||
- <a href="https://link.amazon/B0hnw1JEZ" target="_blank" rel="nofollow noopener sponsored">GemaVision(Dahua) IPC-T549M-ALED-S3</a> (affiliate link)
|
||||
- <a href="https://link.amazon/B06naLGqL" target="_blank" rel="nofollow noopener sponsored">GemaVision(Dahua) IPC-T54IR-AS</a> (affiliate link)
|
||||
- <a href="https://link.amazon/B0iD97zC7" target="_blank" rel="nofollow noopener sponsored">HIKVISION DS-2CD2387G2P-LSU/SL ColorVu 8MP Panoramic Turret IP Camera</a> (affiliate link)
|
||||
|
||||
I may earn a small commission for my endorsement, recommendation, testimonial, or link to any products or services from this website.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ title: Updating
|
||||
|
||||
# Updating Frigate
|
||||
|
||||
The current stable version of Frigate is **0.18.1**. The release notes and any breaking changes for this version can be found on the [Frigate GitHub releases page](https://github.com/blakeblackshear/frigate/releases/tag/v0.18.1).
|
||||
The current stable version of Frigate is **0.18.3**. The release notes and any breaking changes for this version can be found on the [Frigate GitHub releases page](https://github.com/blakeblackshear/frigate/releases/tag/v0.18.3).
|
||||
|
||||
Keeping Frigate up to date ensures you benefit from the latest features, performance improvements, and bug fixes. The update process varies slightly depending on your installation method (Docker, Home Assistant App, etc.). Below are instructions for the most common setups.
|
||||
|
||||
@@ -31,21 +31,21 @@ If you’re running Frigate via Docker (recommended method), follow these steps:
|
||||
|
||||
2. **Update and Pull the Latest Image**:
|
||||
- If using Docker Compose:
|
||||
- Edit your `docker-compose.yml` file to specify the desired version tag (e.g., `0.18.1` instead of `0.17.1`). For example:
|
||||
- Edit your `docker-compose.yml` file to specify the desired version tag (e.g., `0.18.3` instead of `0.17.1`). For example:
|
||||
```yaml
|
||||
services:
|
||||
frigate:
|
||||
image: ghcr.io/blakeblackshear/frigate:0.18.1
|
||||
image: ghcr.io/blakeblackshear/frigate:0.18.3
|
||||
```
|
||||
- Then pull the image:
|
||||
```bash
|
||||
docker pull ghcr.io/blakeblackshear/frigate:0.18.1
|
||||
docker pull ghcr.io/blakeblackshear/frigate:0.18.3
|
||||
```
|
||||
- **Note for `stable` Tag Users**: If your `docker-compose.yml` uses the `stable` tag (e.g., `ghcr.io/blakeblackshear/frigate:stable`), you don’t need to update the tag manually. The `stable` tag always points to the latest stable release after pulling.
|
||||
- If using `docker run`:
|
||||
- Pull the image with the appropriate tag (e.g., `0.18.1`, `0.18.1-tensorrt`, or `stable`):
|
||||
- Pull the image with the appropriate tag (e.g., `0.18.3`, `0.18.3-tensorrt`, or `stable`):
|
||||
```bash
|
||||
docker pull ghcr.io/blakeblackshear/frigate:0.18.1
|
||||
docker pull ghcr.io/blakeblackshear/frigate:0.18.3
|
||||
```
|
||||
|
||||
3. **Start the Container**:
|
||||
@@ -100,7 +100,7 @@ If an update causes issues:
|
||||
1. Stop Frigate.
|
||||
2. Restore your backed-up config file and database.
|
||||
3. Revert to the previous image version:
|
||||
- For Docker: Specify an older tag (e.g., `ghcr.io/blakeblackshear/frigate:0.18.0`) in your `docker run` command.
|
||||
- For Docker: Specify an older tag (e.g., `ghcr.io/blakeblackshear/frigate:0.18.2`) in your `docker run` command.
|
||||
- For Docker Compose: Edit your `docker-compose.yml`, specify the older version tag (e.g., `ghcr.io/blakeblackshear/frigate:0.16.4`), and re-run `docker compose up -d`.
|
||||
- For Home Assistant: Restore from the app/addon backup you took before you updated.
|
||||
4. Verify the old version is running again.
|
||||
|
||||
@@ -59,7 +59,7 @@ You can view all of your submitted images at [https://plus.frigate.video](https:
|
||||
|
||||
Once you have [requested your first model](../plus/first_model.md) and gotten your own model ID, it can be used with a special model path. No other information needs to be configured for Frigate+ models because it fetches the remaining config from Frigate+ automatically.
|
||||
|
||||
You can either choose the new model from the <NavPath path="Settings > System > Detectors and model" /> pane in the Frigate UI (the **Frigate+ Model** tab), or manually set the model at the root level in your config:
|
||||
You can either choose the new model from the <NavPath path="Settings > System > Detectors and model" /> pane in the Frigate UI (the **Frigate+** tab), or manually set the model at the root level in your config:
|
||||
|
||||
```yaml
|
||||
detectors: ...
|
||||
|
||||
@@ -13,52 +13,92 @@ Please use your own knowledge to assess and vet them before you install anything
|
||||
|
||||
:::
|
||||
|
||||
## [Advanced Camera Card (formerly known as Frigate Card](https://card.camera/#/README)
|
||||
## Cameras and Streaming
|
||||
|
||||
The [Advanced Camera Card](https://card.camera/#/README) is a Home Assistant dashboard card with deep Frigate integration.
|
||||
Tools that help get video from your cameras into Frigate, or change how Frigate's video is delivered.
|
||||
|
||||
## [cctvQL](https://github.com/arunrajiah/cctvql)
|
||||
### [frigate-abr](https://github.com/007hacky007/frigate-abr)
|
||||
|
||||
[frigate-abr](https://github.com/007hacky007/frigate-abr) is a drop-in Docker image of Frigate that adds adaptive bitrate (ABR) playback for recordings: a sidecar transcodes footage to lower quality tiers on demand, for reviewing over slow remote connections. Segments are transcoded when played and cached, so no additional stream is recorded. Frigate itself is not modified.
|
||||
|
||||
### [reostream](https://github.com/VoltTech21/reostream)
|
||||
|
||||
[reostream](https://github.com/VoltTech21/reostream) is a proxy for Reolink cameras that pulls video over Reolink's own protocol (the one the Reolink app and NVR use) instead of the camera's RTSP server, and serves it back as RTSP for go2rtc and Frigate. It helps models whose RTSP stream smears, drops frames or loses full resolution, and supports two-way talk.
|
||||
|
||||
### [Scrypted - Frigate bridge plugin](https://github.com/apocaliss92/scrypted-frigate-bridge)
|
||||
|
||||
[Scrypted - Frigate bridge](https://github.com/apocaliss92/scrypted-frigate-bridge) is a plugin that allows you to ingest Frigate detections, motion, videoclips on Scrypted as well as provide templates to export rebroadcast configurations on Frigate.
|
||||
|
||||
### [Strix](https://github.com/eduard256/Strix)
|
||||
|
||||
[Strix](https://github.com/eduard256/Strix) auto-discovers working stream URLs for IP cameras and generates ready-to-use Frigate configs. It tests thousands of URL patterns against your camera and supports cameras without RTSP or ONVIF. 67K+ camera models from 3.6K+ brands.
|
||||
|
||||
## Events and Media
|
||||
|
||||
Tools that enrich, query, or back up the events, snapshots, and reviews Frigate produces.
|
||||
|
||||
### [cctvQL](https://github.com/arunrajiah/cctvql)
|
||||
|
||||
[cctvQL](https://github.com/arunrajiah/cctvql) is a natural language query layer for Frigate and other CCTV systems. It connects to Frigate's REST API and MQTT broker to let you ask conversational questions about cameras and events (e.g. "Was there motion at the front door last night?"), with support for real-time event streaming, anomaly detection, PTZ control, alert rules, and a Home Assistant custom component.
|
||||
|
||||
## [Double Take](https://github.com/skrashevich/double-take)
|
||||
### [Double Take](https://github.com/skrashevich/double-take)
|
||||
|
||||
[Double Take](https://github.com/skrashevich/double-take) provides a unified UI and API for processing and training images for facial recognition.
|
||||
It supports automatically setting the sub labels in Frigate for person objects that are detected and recognized.
|
||||
This is a fork (with fixed errors and new features) of [original Double Take](https://github.com/jakowenko/double-take) project which, unfortunately, isn't being maintained by author.
|
||||
|
||||
## [frigate-abr](https://github.com/007hacky007/frigate-abr)
|
||||
|
||||
[frigate-abr](https://github.com/007hacky007/frigate-abr) is a drop-in Docker image of Frigate that adds adaptive bitrate (ABR) playback for recordings: a sidecar transcodes footage to lower quality tiers on demand, for reviewing over slow remote connections. Segments are transcoded when played and cached, so no additional stream is recorded. Frigate itself is not modified.
|
||||
|
||||
## [Frigate Notify](https://github.com/0x2142/frigate-notify)
|
||||
|
||||
[Frigate Notify](https://github.com/0x2142/frigate-notify) is a simple app designed to send notifications from Frigate to your favorite platforms. Intended to be used with standalone Frigate installations - Home Assistant not required, MQTT is optional but recommended.
|
||||
|
||||
## [Frigate Notify Alert](https://github.com/Sysoev86/frigate-notify-alert)
|
||||
|
||||
[Frigate Notify Alert](https://github.com/Sysoev86/frigate-notify-alert) sends Frigate events to Telegram as a photo + video media group. It supports multiple camera groups (each notifying its own chat), optional zone filtering (notify only when an object enters a chosen zone), and in-chat buttons to pause notifications for a set time. Works with standalone Frigate over MQTT; Home Assistant not required.
|
||||
|
||||
## [Frigate Snap-Sync](https://github.com/thequantumphysicist/frigate-snap-sync/)
|
||||
### [Frigate Snap-Sync](https://github.com/thequantumphysicist/frigate-snap-sync/)
|
||||
|
||||
[Frigate Snap-Sync](https://github.com/thequantumphysicist/frigate-snap-sync/) is a program that works in tandem with Frigate. It responds to Frigate when a snapshot or a review is made (and more can be added), and uploads them to one or more remote server(s) of your choice.
|
||||
|
||||
## [Frigate telegram](https://github.com/OldTyT/frigate-telegram)
|
||||
## Notifications
|
||||
|
||||
Standalone apps that send Frigate events to messaging platforms without requiring Home Assistant. For notifications through Home Assistant, see [Camera AutoNotify](#camera-autonotify).
|
||||
|
||||
### [Frigate Notify](https://github.com/0x2142/frigate-notify)
|
||||
|
||||
[Frigate Notify](https://github.com/0x2142/frigate-notify) is a simple app designed to send notifications from Frigate to your favorite platforms. Intended to be used with standalone Frigate installations - Home Assistant not required, MQTT is optional but recommended.
|
||||
|
||||
### [Frigate Notify Alert](https://github.com/Sysoev86/frigate-notify-alert)
|
||||
|
||||
[Frigate Notify Alert](https://github.com/Sysoev86/frigate-notify-alert) sends Frigate events to Telegram as a photo + video media group. It supports multiple camera groups (each notifying its own chat), optional zone filtering (notify only when an object enters a chosen zone), and in-chat buttons to pause notifications for a set time. Works with standalone Frigate over MQTT; Home Assistant not required.
|
||||
|
||||
### [Frigate telegram](https://github.com/OldTyT/frigate-telegram)
|
||||
|
||||
[Frigate telegram](https://github.com/OldTyT/frigate-telegram) makes it possible to send events from Frigate to Telegram. Events are sent as a message with a text description, video, and thumbnail.
|
||||
|
||||
## [kiosk-monitor](https://github.com/extremeshok/kiosk-monitor)
|
||||
## Clients and Viewers
|
||||
|
||||
Apps and displays for viewing Frigate outside of its built-in web UI.
|
||||
|
||||
### [FrigatePiP](https://github.com/maciejgornicz/frigate-pip)
|
||||
|
||||
[FrigatePiP](https://github.com/maciejgornicz/frigate-pip) pops up a small picture-in-picture window with a camera's live video in a corner of the screen when Frigate detects an object, and closes it when the activity ends. It runs as a Windows tray app and on Linux (desktop windows, a console framebuffer, a terminal or tmux popups), receives events over Frigate's WebSocket or MQTT and plays the go2rtc RTSP stream with hardware decoding and camera audio.
|
||||
|
||||
### [kiosk-monitor](https://github.com/extremeshok/kiosk-monitor)
|
||||
|
||||
[kiosk-monitor](https://github.com/extremeshok/kiosk-monitor) is a Raspberry Pi watchdog that runs Chromium fullscreen on a Frigate dashboard (optionally with VLC on a second monitor for an RTSP camera stream), auto-restarts on frozen screens or unreachable URLs, and ships a Birdseye-aware Chromium helper that auto-sizes the grid to the display.
|
||||
|
||||
## [Periscope](https://github.com/maksz42/periscope)
|
||||
### [Periscope](https://github.com/maksz42/periscope)
|
||||
|
||||
[Periscope](https://github.com/maksz42/periscope) is a lightweight Android app that turns old devices into live viewers for Frigate. It works on Android 2.2 and above, including Android TV. It supports authentication and HTTPS.
|
||||
|
||||
## [Scrypted - Frigate bridge plugin](https://github.com/apocaliss92/scrypted-frigate-bridge)
|
||||
### [yuFriEye](https://apps.apple.com/app/id6832456692)
|
||||
|
||||
[Scrypted - Frigate bridge](https://github.com/apocaliss92/scrypted-frigate-bridge) is a plugin that allows you to ingest Frigate detections, motion, videoclips on Scrypted as well as provide templates to export rebroadcast configurations on Frigate.
|
||||
[yuFriEye](https://apps.apple.com/app/id6832456692) is a free native iOS, iPadOS and macOS client for Frigate. It shows the live camera grid with low-latency go2rtc streams, alerts and detections with clip playback and motion boxes, recordings by day with continuous playback, Frigate and go2rtc logs, and supports multiple servers with local and remote addresses. Works with or without Frigate authentication; no account or data collection.
|
||||
|
||||
## [Strix](https://github.com/eduard256/Strix)
|
||||
## Home Assistant
|
||||
|
||||
[Strix](https://github.com/eduard256/Strix) auto-discovers working stream URLs for IP cameras and generates ready-to-use Frigate configs. It tests thousands of URL patterns against your camera and supports cameras without RTSP or ONVIF. 67K+ camera models from 3.6K+ brands.
|
||||
Cards and Home Assistant Marketplace integrations that build on the [Frigate Home Assistant integration](/integrations/home-assistant).
|
||||
|
||||
### [Advanced Camera Card (formerly known as Frigate Card)](https://card.camera/#/README)
|
||||
|
||||
The [Advanced Camera Card](https://card.camera/#/README) is a Home Assistant dashboard card with deep Frigate integration.
|
||||
|
||||
### [Auto Arm](https://autoarm.rhizomatics.org.uk)
|
||||
|
||||
Home Assistant Marketplace integration to automatically manage alarm state based on time of day, occupancy, sun state, physical buttons etc. Can synchronize Frigate profiles to alarm state, so for example use `disarmed` profile to reduce noisy notifications when occupied during the day.
|
||||
|
||||
### [Camera AutoNotify](https://camera-autonotify.rhizomatics.org.uk)
|
||||
|
||||
Home Assistant Marketplace integration to set up notifications for Frigate cameras without use of blueprints or automations. Triggered by camera events and optionally by GenAI reviews, with option for daily/periodic GenAI Review Report emailed, and alerts if Frigate or any cameras are unavailable. Integration with [Supernotify](https://supernotify.rhizomatics.org.uk/) to auto configure mobile devices and customize notifications for alarm state, occupancy etc.
|
||||
|
||||
@@ -25,6 +25,12 @@ If you have an active Frigate+ subscription, new uploads will be scanned for the
|
||||
|
||||
Suggestions are converted to labels when saving, so you should remove any errant suggestions. There is already some logic designed to avoid duplicate labels, but you may still occasionally see some duplicate suggestions. You should keep the most accurate bounding box and delete any duplicates so that you have just one label per object remaining.
|
||||
|
||||
## Reviewing annotations with Patches
|
||||
|
||||
The Patches tab on the Images page shows a cropped view of every annotation for a label in a grid. Scanning the crops makes it much easier to spot a mislabeled object than paging through full images one at a time. Pick a label to get started, and optionally narrow the results to a single camera. Clicking a patch opens that image in the editor so you can fix the annotation.
|
||||
|
||||
Patches only include annotations from images you have already verified.
|
||||
|
||||
## False positive labels
|
||||
|
||||
False positives will be shown with a red box and the label will have a strike through. These can't be adjusted, but they can be deleted if you accidentally submit a true positive as a false positive from Frigate.
|
||||
@@ -51,3 +57,12 @@ Misidentified objects should have a correct label added. For example, if a perso
|
||||
| `scrollwheel` | Zoom in/out |
|
||||
| `f` | Hide/show all but current box |
|
||||
| `spacebar` | Verify and save |
|
||||
|
||||
## Deleting images
|
||||
|
||||
In most cases, you should keep your existing images. Removing training data usually makes accuracy worse, not better, so you shouldn't delete images just because you think you made some annotation mistakes. Deleting images makes sense when you move to a new location, or significantly upgrade or reposition your cameras.
|
||||
|
||||
- To delete all images for a camera, use the **Delete Images** button for that camera on the Cameras page.
|
||||
- To delete all images in your account, use **Delete All Images** on the Settings page.
|
||||
|
||||
Deletions run in the background, and their progress is shown in the bulk operations panel. Deleted images cannot be recovered and are no longer used to train your models.
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
---
|
||||
id: choosing_a_model
|
||||
title: Choosing a model
|
||||
---
|
||||
|
||||
Frigate+ offers several model types, sizes, and input resolutions. This page compares their accuracy and speed to help you decide which one to request. Make sure the model type you choose is supported by your detector, as shown in the [supported detector types](./index.md#supported-detector-types) table.
|
||||
|
||||
## Recommendations
|
||||
|
||||
- **YOLOv9-s at 320** is the balanced default if your hardware runs it well. It detects about twice as many objects as MobileDet, and 15 more per 100 than YOLO-NAS-s at 320, at the same false alarm rate.
|
||||
- **Moving up a size at 320** helps more than moving to 640 for most cameras. YOLOv9-m at 320 detects more objects than YOLOv9-s at 640 (60% vs 59%) with lower GPU latency.
|
||||
- **640 input** is rarely needed. Frigate doesn't run detection on the full frame. It crops a region around motion, at least 320 pixels wide for any model, and resizes it to the model's input size. Most regions are small, so a 640 model usually receives an upscaled crop and does worse than a 320 model given the same crop at its native size. 640 models detect small objects better only within a large region. See [object size and input resolution](#object-size-and-input-resolution) for details.
|
||||
- **YOLOv9-c** gains little over YOLOv9-m: about 2 points of detection rate at 320 and none at 640, with more latency. On CPU it takes 1.4 to 1.7 times as long as YOLOv9-m.
|
||||
- **YOLOv9-t at 640** is no better than YOLOv9-s at 320 (55% vs 54%) and is slower on both GPU and CPU.
|
||||
- **YOLO-NAS-s** and **MobileDet** are only worth considering on hardware that can't run YOLOv9. Everywhere else, a YOLOv9 model of similar speed is more accurate.
|
||||
|
||||
Results on your own hardware and cameras will differ, so test with the base models before requesting a model.
|
||||
|
||||
### Thresholds
|
||||
|
||||
Each model's threshold for 95% precision is listed in the [accuracy](#accuracy) table. YOLOv9 models reach it at about 0.70 to 0.77. MobileDet (0.82) and YOLO-NAS-s (0.86 to 0.89) need higher thresholds, so with Frigate's default threshold they produce more false positives than the YOLOv9 models. See [object filters](../configuration/object_filters.md#object-scores) for how to adjust thresholds.
|
||||
|
||||
## How these were measured
|
||||
|
||||
The numbers on this page are for the 2026.3 base models.
|
||||
|
||||
- **Images:** 10,947 images from the Frigate+ validation set, from real Frigate cameras. Images that share a source with training images are excluded.
|
||||
- **Processing:** every model runs through Frigate's own detector code and post-processing (Frigate 0.18.2), exactly as deployed.
|
||||
- **Labels:** results cover the 12 most common labels: `car`, `person`, `waste_bin`, `license_plate`, `dog`, `cat`, `face`, `bicycle`, `bird`, `deer`, `bbq_grill`, and `package`.
|
||||
- **Single frames:** each image is scored on its own. In Frigate, an object has to score well across several frames before it becomes a tracked object, so brief one-frame mistakes rarely reach you. Use these numbers to compare models with each other, not as event rates.
|
||||
|
||||
**Detection rate at 95% precision** is the main accuracy number. It's the share of real objects a model detects when its threshold is set so that 95% of its detections are correct (about 1 false detection in 20). Every model is held to the same false alarm rate, so the detection rates compare directly. The threshold that achieves this is shown too, because it differs between models.
|
||||
|
||||
## Accuracy
|
||||
|
||||
| Model | Input | Detection rate at 95% precision | Missed objects per 100 | Threshold for 95% precision | AP50 |
|
||||
| ---------- | ----- | ------------------------------- | ---------------------- | --------------------------- | ---- |
|
||||
| MobileDet | 320 | 24% | 76 | 0.82 | 0.47 |
|
||||
| YOLO-NAS-s | 320 | 39% | 61 | 0.86 | 0.44 |
|
||||
| YOLO-NAS-s | 640 | 48% | 52 | 0.89 | 0.55 |
|
||||
| YOLOv9-t | 320 | 45% | 55 | 0.69 | 0.44 |
|
||||
| YOLOv9-t | 640 | 55% | 45 | 0.70 | 0.54 |
|
||||
| YOLOv9-s | 320 | 54% | 46 | 0.74 | 0.54 |
|
||||
| YOLOv9-s | 640 | 59% | 41 | 0.75 | 0.61 |
|
||||
| YOLOv9-m | 320 | 60% | 40 | 0.75 | 0.58 |
|
||||
| YOLOv9-m | 640 | 64% | 36 | 0.77 | 0.64 |
|
||||
| YOLOv9-c | 320 | 62% | 38 | 0.75 | 0.60 |
|
||||
| YOLOv9-c | 640 | 63% | 37 | 0.77 | 0.64 |
|
||||
|
||||
AP50 is the standard COCO metric (IoU 0.5) averaged over the 12 labels. It summarizes accuracy across every threshold, while the detection rate describes one realistic setting.
|
||||
|
||||
:::note
|
||||
|
||||
These AP50 numbers can't be compared to the COCO results published for YOLOv9, YOLO-NAS, and other models. Those results are measured on the COCO dataset, while these are measured on images from security cameras, with a different set of labels (several, such as `license_plate`, `face`, and `package`, aren't in COCO) and through Frigate's own post-processing. Published COCO results also usually report mAP averaged over IoU 0.5 to 0.95 rather than AP50. Use these numbers only to compare Frigate+ models with each other.
|
||||
|
||||
:::
|
||||
|
||||
### By object size
|
||||
|
||||
AP50 by object size:
|
||||
|
||||
| Model | Input | Small | Medium | Large |
|
||||
| ---------- | ----- | ----- | ------ | ----- |
|
||||
| MobileDet | 320 | 0.23 | 0.62 | 0.71 |
|
||||
| YOLO-NAS-s | 320 | 0.23 | 0.57 | 0.60 |
|
||||
| YOLO-NAS-s | 640 | 0.42 | 0.63 | 0.58 |
|
||||
| YOLOv9-t | 320 | 0.22 | 0.60 | 0.67 |
|
||||
| YOLOv9-t | 640 | 0.42 | 0.63 | 0.57 |
|
||||
| YOLOv9-s | 320 | 0.35 | 0.70 | 0.73 |
|
||||
| YOLOv9-s | 640 | 0.51 | 0.69 | 0.69 |
|
||||
| YOLOv9-m | 320 | 0.40 | 0.73 | 0.74 |
|
||||
| YOLOv9-m | 640 | 0.54 | 0.71 | 0.72 |
|
||||
| YOLOv9-c | 320 | 0.44 | 0.73 | 0.77 |
|
||||
| YOLOv9-c | 640 | 0.54 | 0.71 | 0.74 |
|
||||
|
||||
In these single-image results, 640 input mostly helps small objects, such as distant people, license plates, and faces, and doesn't help medium and large objects. For example, license plate AP50 rises from 0.32 to 0.55 for YOLOv9-s. These numbers overstate the benefit of 640 in Frigate, as explained below.
|
||||
|
||||
#### Object size and input resolution
|
||||
|
||||
Frigate doesn't send the full camera frame to the model. It crops a region around motion or a tracked object, at least 320 pixels wide for any model, and resizes it to the model's input size. Most regions are small, so a 640 model usually receives a crop upscaled from 320 pixels, which adds no detail and performs worse than a 320 model given the same crop at its native size. A 640 model detects small objects better only when the region is large.
|
||||
|
||||
640 input can still help in scenes with large objects in the foreground and small objects in the background at the same time, such as a doorbell camera that sees a person on the porch and another person across the street. The region has to be large enough to fit the nearby person, so the distant person is small within it. Frigate already handles much of this case: when an object is small relative to the region it was detected in, Frigate runs a separate detection on a smaller region around it.
|
||||
|
||||
### By label
|
||||
|
||||
AP50 by label:
|
||||
|
||||
| Label | MobileDet 320 | YOLO-NAS-s 320 | YOLOv9-t 320 | YOLOv9-s 320 | YOLOv9-m 320 | YOLOv9-c 320 | YOLO-NAS-s 640 | YOLOv9-t 640 | YOLOv9-s 640 | YOLOv9-m 640 | YOLOv9-c 640 |
|
||||
| --------------- | ------------- | -------------- | ------------ | ------------ | ------------ | ------------ | -------------- | ------------ | ------------ | ------------ | ------------ |
|
||||
| `car` | 0.73 | 0.72 | 0.70 | 0.77 | 0.81 | 0.82 | 0.82 | 0.79 | 0.83 | 0.85 | 0.84 |
|
||||
| `person` | 0.65 | 0.62 | 0.62 | 0.72 | 0.75 | 0.76 | 0.71 | 0.69 | 0.76 | 0.78 | 0.77 |
|
||||
| `waste_bin` | 0.52 | 0.49 | 0.49 | 0.55 | 0.57 | 0.58 | 0.60 | 0.60 | 0.62 | 0.62 | 0.63 |
|
||||
| `license_plate` | 0.31 | 0.31 | 0.23 | 0.32 | 0.36 | 0.39 | 0.55 | 0.46 | 0.55 | 0.60 | 0.61 |
|
||||
| `dog` | 0.38 | 0.35 | 0.39 | 0.53 | 0.53 | 0.57 | 0.40 | 0.48 | 0.53 | 0.55 | 0.58 |
|
||||
| `cat` | 0.41 | 0.37 | 0.39 | 0.51 | 0.57 | 0.59 | 0.43 | 0.46 | 0.58 | 0.61 | 0.62 |
|
||||
| `face` | 0.39 | 0.41 | 0.23 | 0.33 | 0.42 | 0.45 | 0.60 | 0.43 | 0.57 | 0.63 | 0.63 |
|
||||
| `bicycle` | 0.46 | 0.43 | 0.40 | 0.51 | 0.56 | 0.55 | 0.54 | 0.49 | 0.58 | 0.62 | 0.60 |
|
||||
| `bird` | 0.30 | 0.18 | 0.33 | 0.42 | 0.47 | 0.50 | 0.23 | 0.30 | 0.39 | 0.43 | 0.38 |
|
||||
| `deer` | 0.51 | 0.50 | 0.51 | 0.62 | 0.69 | 0.71 | 0.59 | 0.56 | 0.60 | 0.70 | 0.67 |
|
||||
| `bbq_grill` | 0.68 | 0.60 | 0.69 | 0.77 | 0.78 | 0.81 | 0.74 | 0.74 | 0.81 | 0.83 | 0.84 |
|
||||
| `package` | 0.35 | 0.28 | 0.34 | 0.46 | 0.47 | 0.49 | 0.39 | 0.43 | 0.50 | 0.48 | 0.50 |
|
||||
|
||||
## Speed
|
||||
|
||||
Average time per detection in milliseconds, measured through Frigate's detector code and including post-processing. Lower is better. A blank cell means that combination was not measured.
|
||||
|
||||
| Model | Input | NVIDIA RTX 5060 Ti (ONNX, CUDA) | Intel i9-13900K (OpenVINO, CPU) | Intel i9-13900K (ONNX, CPU) | Intel i9-13900K (TFLite, CPU) |
|
||||
| ---------- | ----- | ------------------------------- | ------------------------------- | --------------------------- | ----------------------------- |
|
||||
| MobileDet | 320 | | | | 8.4 |
|
||||
| YOLO-NAS-s | 320 | 4.9 | 8.4 | 8.9 | |
|
||||
| YOLO-NAS-s | 640 | 7.1 | 29.6 | 28.6 | |
|
||||
| YOLOv9-t | 320 | 2.9 | 4.3 | 6.5 | |
|
||||
| YOLOv9-t | 640 | 5.0 | 12.9 | 17.0 | |
|
||||
| YOLOv9-s | 320 | 3.9 | 9.3 | 11.5 | |
|
||||
| YOLOv9-s | 640 | 6.3 | 33.1 | 32.6 | |
|
||||
| YOLOv9-m | 320 | 5.2 | 23.2 | 19.8 | |
|
||||
| YOLOv9-m | 640 | 10.1 | 88.1 | 69.5 | |
|
||||
| YOLOv9-c | 320 | 5.4 | 38.8 | 27.5 | |
|
||||
| YOLOv9-c | 640 | 11.1 | 147.8 | 99.5 | |
|
||||
|
||||
CPU times vary by about ±15% between runs. Speeds on other hardware, such as Google Coral, Hailo, Intel iGPUs and NPUs, AMD GPUs, and Rockchip NPUs, are not included here. Test the base models on your own hardware to compare speeds.
|
||||
@@ -26,7 +26,9 @@ Yes. Subscriptions to Frigate+ provide access to the infrastructure used to trai
|
||||
### Can I use Frigate+ models commercially?
|
||||
|
||||
A standard subscription covers use on camera systems you own or operate, including for your business. A shop, restaurant, warehouse, or office running Frigate+ at its own locations (including multiple locations) is exactly the kind of use the subscription is for.
|
||||
|
||||
What the standard subscription does not cover is using Frigate+ models to provide a product or service to others. If you're deploying models at your customers' sites, bundling them with hardware you sell, or running them as part of a hosted or managed service, even if your customers never receive the model files themselves, you'll need a commercial license.
|
||||
|
||||
Note that professional installers are fine under standard subscriptions when each customer holds their own Frigate+ subscription. The commercial license is for cases where your license powers your customers' sites.
|
||||
|
||||
### Why can't I submit images to Frigate+?
|
||||
|
||||
@@ -17,7 +17,7 @@ For more detailed recommendations, you can refer to the docs on [annotating](./a
|
||||
|
||||
## Step 2: Submit a model request
|
||||
|
||||
Once you have an initial set of verified images, you can request a model on the Models page. For guidance on choosing a model type, refer to [this part of the documentation](./index.md#available-model-types). If you are unsure which type to request, you can test the base model for each version from the "Base Models" tab. Each model request requires 1 of the 12 trainings that you receive with your annual subscription. This model will support all [label types available](./index.md#available-label-types) even if you do not submit any examples for those labels. Model creation can take up to 36 hours.
|
||||
Once you have an initial set of verified images, you can request a model on the Models page. For guidance on choosing a model type, refer to [available model types](./index.md#available-model-types) and [choosing a model](./choosing_a_model.md). If you are unsure which type to request, you can test the base model for each version from the "Base Models" tab. For most hardware, `yolov9` is recommended; `mobiledet` is a legacy model type and will be removed in 2027. Each model request requires 1 of the 12 trainings that you receive with your annual subscription. This model will support all [label types available](./index.md#available-label-types) even if you do not submit any examples for those labels. Model creation can take up to 36 hours.
|
||||

|
||||
|
||||
## Step 3: Set your model
|
||||
|
||||
+37
-21
@@ -5,25 +5,41 @@ title: Models
|
||||
|
||||
<a href="https://frigate.video/plus" target="_blank" rel="nofollow">Frigate+</a> offers models trained on images submitted by Frigate+ users from their security cameras and is specifically designed for the way Frigate NVR analyzes video footage. These models offer higher accuracy with less resources. The images you upload are used to fine tune a base model trained from images uploaded by all Frigate+ users. This fine tuning process results in a model that is optimized for accuracy in your specific conditions.
|
||||
|
||||
With a subscription, 12 model trainings to fine tune your model per year are included. In addition, you will have access to any base models published while your subscription is active. If you cancel your subscription, you will retain access to any trained and base models in your account. An active subscription is required to submit model requests or purchase additional trainings. New base models are published quarterly with target dates of January 15th, April 15th, July 15th, and October 15th.
|
||||
With a subscription, 12 model trainings to fine tune your model per year are included. In addition, you will have access to any base models published while your subscription is active. If you cancel your subscription, you will retain access to any trained and base models in your account. An active subscription is required to submit model requests or purchase additional trainings. New base models are published twice per year.
|
||||
|
||||
Information on how to integrate Frigate+ with Frigate can be found in the [integration docs](../integrations/plus.md).
|
||||
|
||||
## Available model types
|
||||
|
||||
There are three model types offered in Frigate+, `mobiledet`, `yolonas`, and `yolov9`. All of these models are object detection models and are trained to detect the same set of labels [listed below](#available-label-types).
|
||||
There are three model types offered in Frigate+, `yolov9`, `yolonas`, and `mobiledet` (legacy). All of these models are object detection models and are trained to detect the same set of labels [listed below](#available-label-types).
|
||||
|
||||
Not all model types are supported by all detectors, so it's important to choose a model type to match your detector as shown in the table under [supported detector types](#supported-detector-types). You can test model types for compatibility and speed on your hardware by using the base models.
|
||||
Not all model types are supported by all detectors, so it's important to choose a model type to match your detector as shown in the table under [supported detector types](#supported-detector-types). You can test model types for compatibility and speed on your hardware by using the base models. For accuracy and speed comparisons between model types, sizes, and resolutions, see [choosing a model](./choosing_a_model.md).
|
||||
|
||||
| Model Type | Description |
|
||||
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `mobiledet` | Based on the same architecture as the default model included with Frigate. Runs on Google Coral devices and CPUs. |
|
||||
| `yolonas` | A newer architecture that offers slightly higher accuracy and improved detection of small objects. Runs on Intel, NVidia GPUs, and AMD GPUs. |
|
||||
| `yolov9` | A leading SOTA (state of the art) object detection model with similar performance to yolonas, but on a wider range of hardware options. Runs on most hardware. |
|
||||
| Model Type | Description |
|
||||
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `yolov9` | A leading SOTA (state of the art) object detection model. More accurate than yolonas at similar speeds, and runs on a wider range of hardware. Runs on most hardware. |
|
||||
| `yolonas` | An alternative architecture for hardware that can't run yolov9. Runs on Intel, NVidia GPUs, and AMD GPUs. |
|
||||
| `mobiledet` | Legacy. Based on the same architecture as the default model included with Frigate. Runs on Google Coral devices and CPUs. |
|
||||
|
||||
:::warning
|
||||
|
||||
`mobiledet` is a legacy model type. Base model 2026.3 is the last base model update for `mobiledet`, and it is planned to be removed from Frigate+ in 2027. If you are using `mobiledet` with a Google Coral, request a `yolov9` model with the `edgetpu` variant instead.
|
||||
|
||||
:::
|
||||
|
||||
### YOLOv9 Details
|
||||
|
||||
YOLOv9 models are available in `s`, `t`, `edgetpu` variants. When requesting a `yolov9` model, you will be prompted to choose a variant. If you want the model to be compatible with a Google Coral, you will need to choose the `edgetpu` variant. If you are unsure what variant to choose, you should perform some tests with the base models to find the performance level that suits you. The `s` size is most similar to the current `yolonas` models in terms of inference times and accuracy, and a good place to start is the `320x320` resolution model for `yolov9s`.
|
||||
YOLOv9 models are available in `t`, `s`, `m`, `c`, and `edgetpu` variants. When requesting a `yolov9` model, you will be prompted to choose a variant. If you want the model to be compatible with a Google Coral, you will need to choose the `edgetpu` variant, which requires Frigate 0.17 or later. If you are unsure what variant to choose, you should perform some tests with the base models to find the performance level that suits you. The `s` size has similar inference times to the current `yolonas` models with noticeably higher accuracy, and a good place to start is the `320x320` resolution model for `yolov9s`. The `m` size offers higher accuracy at the cost of slower inference, so it is best suited to more powerful hardware such as GPUs. The `c` size is slower still and offers little accuracy gain over `m`. See [choosing a model](./choosing_a_model.md) for detailed accuracy and speed comparisons.
|
||||
|
||||
| Variant | Size | Parameters | Speed and accuracy | Best suited for |
|
||||
| --------- | ------- | ---------- | ------------------------------------------------------------- | -------------------------------------------------- |
|
||||
| `t` | Tiny | ~2.0M | Fastest inference, lowest accuracy | Low power hardware or a large number of cameras |
|
||||
| `s` | Small | ~7.1M | Balanced. Similar inference times to `yolonas`, more accurate | Most users. Start with `320x320` |
|
||||
| `m` | Medium | ~20.0M | Slower than `s` with higher accuracy | Mid-range GPUs and NPUs |
|
||||
| `c` | Compact | ~25.3M | Similar accuracy to `m`, slowest inference | More powerful hardware such as GPUs |
|
||||
| `edgetpu` | N/A | N/A | Optimized to run on the Coral's Edge TPU | Google Coral devices only (requires Frigate 0.17+) |
|
||||
|
||||
Parameter counts are for the standard YOLOv9 architectures. Actual inference times depend on your hardware and the input resolution you choose, so test with the base models before requesting a model.
|
||||
|
||||
:::info
|
||||
|
||||
@@ -33,7 +49,7 @@ When switching to YOLOv9, you may need to adjust your thresholds for some object
|
||||
|
||||
#### Hailo Support
|
||||
|
||||
If you have a Hailo device, you will need to specify the hardware you have when submitting a model request because they are not cross compatible. Please test using the available base models before submitting your model request.
|
||||
If you have a Hailo device, you will need to specify the hardware you have when submitting a model request because they are not cross compatible. Hailo models are available for the `t`, `s`, `m`, and `c` variants on Hailo8, Hailo8L, and Hailo8R devices. Please test using the available base models before submitting your model request.
|
||||
|
||||
#### Rockchip (RKNN) Support
|
||||
|
||||
@@ -43,15 +59,15 @@ Rockchip models are automatically converted as of 0.17. For 0.16, YOLOv9 onnx mo
|
||||
|
||||
Currently, Frigate+ models support CPU (`cpu`), Google Coral (`edgetpu`), OpenVino (`openvino`), ONNX (`onnx`), Hailo (`hailo8l`), and Rockchip (`rknn`) detectors.
|
||||
|
||||
| Hardware | Recommended Detector Type | Recommended Model Type |
|
||||
| -------------------------------------------------------------------------------- | ------------------------- | ---------------------- |
|
||||
| [CPU](/configuration/object_detectors.md#cpu-detector-not-recommended) | `cpu` | `mobiledet` |
|
||||
| [Coral (all form factors)](/configuration/object_detectors.md#edge-tpu-detector) | `edgetpu` | `yolov9` |
|
||||
| [Intel](/configuration/object_detectors.md#openvino-detector) | `openvino` | `yolov9` |
|
||||
| [NVidia GPU](/configuration/object_detectors#onnx) | `onnx` | `yolov9` |
|
||||
| [AMD ROCm GPU](/configuration/object_detectors#amdrocm-gpu-detector) | `onnx` | `yolov9` |
|
||||
| [Hailo8/Hailo8L/Hailo8R](/configuration/object_detectors#hailo-8) | `hailo8l` | `yolov9` |
|
||||
| [Rockchip NPU](/configuration/object_detectors#rockchip-platform) | `rknn` | `yolov9` |
|
||||
| Hardware | Recommended Detector Type | Recommended Model Type |
|
||||
| -------------------------------------------------------------------------------- | --------------------------- | ---------------------- |
|
||||
| [CPU](/configuration/object_detectors.md#cpu-detector-not-recommended) | `openvino (or alternative)` | `yolov9` |
|
||||
| [Coral (all form factors)](/configuration/object_detectors.md#edge-tpu-detector) | `edgetpu` | `yolov9` |
|
||||
| [Intel](/configuration/object_detectors.md#openvino-detector) | `openvino` | `yolov9` |
|
||||
| [NVidia GPU](/configuration/object_detectors#onnx) | `onnx` | `yolov9` |
|
||||
| [AMD ROCm GPU](/configuration/object_detectors#amdrocm-gpu-detector) | `onnx` | `yolov9` |
|
||||
| [Hailo8/Hailo8L/Hailo8R](/configuration/object_detectors#hailo-8) | `hailo8l` | `yolov9` |
|
||||
| [Rockchip NPU](/configuration/object_detectors#rockchip-platform) | `rknn` | `yolov9` |
|
||||
|
||||
## Improving your model
|
||||
|
||||
@@ -66,7 +82,7 @@ Some users may find that Frigate+ models result in more false positives initiall
|
||||
Frigate+ models support a more relevant set of objects for security cameras. The labels for annotation in Frigate+ are configurable by editing the camera in the Cameras section of Frigate+. Currently, the following objects are supported:
|
||||
|
||||
- **People**: `person`, `face`, `baby`
|
||||
- **Vehicles**: `car`, `motorcycle`, `bicycle`, `boat`, `school_bus`, `garbage truck`, `license_plate`
|
||||
- **Vehicles**: `car`, `motorcycle`, `bicycle`, `boat`, `school_bus`, `garbage_truck`, `license_plate`
|
||||
- **Delivery Logos**: `amazon`, `usps`, `ups`, `fedex`, `dhl`, `an_post`, `purolator`, `postnl`, `nzpost`, `postnord`, `gls`, `dpd`, `canada_post`, `royal_mail`
|
||||
- **Animals**: `dog`, `cat`, `deer`, `horse`, `bird`, `raccoon`, `fox`, `bear`, `cow`, `squirrel`, `goat`, `rabbit`, `skunk`, `kangaroo`, `possum`, `rodent`
|
||||
- **Other**: `package`, `waste_bin`, `bbq_grill`, `robot_lawnmower`, `umbrella`, `baby_stroller`
|
||||
@@ -81,7 +97,7 @@ Where possible, these labels are mapped to existing labels during training. For
|
||||
|
||||
- **Vehicles**: `tractor`, `golf_cart`, `bus`, `airplane`, `helicopter`, `rickshaw`, `scooter`
|
||||
- **Delivery Logos**: `bpost`, `auspost`, `aramex`, `transoflex`, `parcelforce`, `hermes`, `cargus`, `fan_courier`, `sameday`, `la_poste`
|
||||
- **Animals**: `badger`, `chicken`, `duck`, `turkey`, `groundhog`, `boar`, `hedgehog`, `wombat`, `bobcat`, `mustelid`, `mountain_lion`, `crocodile`, `monkey`, `coyote`, `porcupine`, `sheep`, `snake`, `lizard`, `heron`, `elk`, `moose`, `pig`, `donkey`, `civet`
|
||||
- **Animals**: `badger`, `chicken`, `duck`, `turkey`, `groundhog`, `boar`, `hedgehog`, `wombat`, `bobcat`, `mustelid`, `mountain_lion`, `crocodile`, `monkey`, `coyote`, `porcupine`, `sheep`, `snake`, `lizard`, `heron`, `elk`, `moose`, `pig`, `donkey`, `civet`, `chipmunk`
|
||||
- **Other**: `sports_ball`, `drone`, `lawnmower`
|
||||
|
||||
Candidate labels are not available for automatic suggestions.
|
||||
|
||||
@@ -162,7 +162,7 @@ Open one of the tracked objects in Explore → **Tracking Details**. If the dete
|
||||
What helps:
|
||||
|
||||
- **Improve the view**: even a small angle change that gets more of the car visible could lift scores enough to stabilize tracking.
|
||||
- **Use a more accurate model**: switching from `mobiledet` to `yolov9`, or stepping up to a larger variant like `yolov9-s` over `yolov9-t`, can help (at the cost of inference time, and still on the COCO dataset). The biggest gains usually come from fine-tuning a model on images from your own cameras so it learns your specific scene. [Frigate+](https://frigate.video/plus) is a paid option that does this - models are trained on security-camera footage and can be fine-tuned on images you submit from your own setup.
|
||||
- **Use a more accurate model**: switching from `mobiledet` to `yolov9`, or stepping up to a larger variant like `yolov9-s` over `yolov9-t` (or `yolov9-c` on more powerful hardware), can help (at the cost of inference time, and still on the COCO dataset). The biggest gains usually come from fine-tuning a model on images from your own cameras so it learns your specific scene. [Frigate+](https://frigate.video/plus) is a paid option that does this - models are trained on security-camera footage and can be fine-tuned on images you submit from your own setup.
|
||||
- **Don't set `detect -> stationary -> max_frames` for `car`**: it artificially ends tracking and forces re-detection as a new object. See [Stationary Objects](../configuration/stationary_objects.md).
|
||||
- **Restrict alerts to the areas you care about** with `required_zones`. See [Zones](../configuration/zones.md#restricting-alerts-and-detections-to-specific-zones). Make sure those zones use the default `loitering_time: 0` unless you specifically want the review item to stay open until the car leaves.
|
||||
- **Filter impossible locations** with [object filter masks](../configuration/masks.md#object-filter-masks) if cars are being detected on rooftops, treetops, etc.
|
||||
|
||||
@@ -160,6 +160,7 @@ const sidebars: SidebarsConfig = {
|
||||
],
|
||||
"Frigate+": [
|
||||
"plus/index",
|
||||
"plus/choosing_a_model",
|
||||
"plus/annotating",
|
||||
"plus/first_model",
|
||||
"plus/faq",
|
||||
|
||||
Vendored
+4
-1
@@ -5374,6 +5374,10 @@ paths:
|
||||
tags:
|
||||
- Media
|
||||
summary: Mjpeg Feed
|
||||
description: |-
|
||||
**Access:** Authenticated user with access to the referenced camera.
|
||||
|
||||
An MJPEG stream of the camera's latest processed frame, intended for debugging only. Every frame of every open stream is color converted, annotated, resized, and JPEG encoded in Frigate's main process, which adds load to the system and can slow down Frigate's processing. It is strictly not recommended to view this stream continuously, such as on a dashboard. For live viewing, use a go2rtc restream instead. The frame rate and resolution can be raised with the fps and height parameters, for example ?fps=10&height=1080, at the cost of additional load.
|
||||
operationId: mjpeg_feed__camera_name__get
|
||||
parameters:
|
||||
- name: camera_name
|
||||
@@ -5461,7 +5465,6 @@ paths:
|
||||
security:
|
||||
- frigateUserAuth: []
|
||||
x-required-role: camera
|
||||
description: '**Access:** Authenticated user with access to the referenced camera.'
|
||||
/{camera_name}/ptz/info:
|
||||
get:
|
||||
tags:
|
||||
|
||||
+18
-14
@@ -74,6 +74,7 @@ from frigate.util.config import (
|
||||
from frigate.util.schema import get_config_schema
|
||||
from frigate.util.services import (
|
||||
Go2rtcStreamIssue,
|
||||
find_restricted_go2rtc_exec_changes,
|
||||
find_restricted_go2rtc_stream_changes,
|
||||
get_nvidia_driver_info,
|
||||
process_logs,
|
||||
@@ -524,26 +525,26 @@ def config_raw():
|
||||
)
|
||||
|
||||
|
||||
def _go2rtc_streams(raw_config: str) -> Any:
|
||||
"""Load go2rtc.streams with the same loader Frigate and go2rtc startup use.
|
||||
def _go2rtc_config(raw_config: str) -> dict[str, Any]:
|
||||
"""Load the go2rtc section with the same loader Frigate and go2rtc startup use.
|
||||
|
||||
Raises ruamel.yaml.YAMLError when the config cannot be parsed.
|
||||
"""
|
||||
loaded = ruamel.yaml.YAML().load(raw_config)
|
||||
go2rtc = loaded.get("go2rtc") if isinstance(loaded, dict) else None
|
||||
return go2rtc.get("streams") if isinstance(go2rtc, dict) else None
|
||||
return go2rtc if isinstance(go2rtc, dict) else {}
|
||||
|
||||
|
||||
def _restricted_go2rtc_streams_response(
|
||||
def _restricted_go2rtc_response(
|
||||
old_raw_config: str, new_raw_config: str
|
||||
) -> JSONResponse | None:
|
||||
"""Reject config changes that add restricted go2rtc stream sources.
|
||||
"""Reject config changes that add restricted go2rtc sources or options.
|
||||
|
||||
The same sources are rejected by PUT /go2rtc/streams, and go2rtc would
|
||||
otherwise load them from the saved config on the next restart.
|
||||
"""
|
||||
try:
|
||||
new_streams = _go2rtc_streams(new_raw_config)
|
||||
new_go2rtc = _go2rtc_config(new_raw_config)
|
||||
except ruamel.yaml.YAMLError:
|
||||
logger.warning("Rejected config change that could not be parsed")
|
||||
return JSONResponse(
|
||||
@@ -552,16 +553,21 @@ def _restricted_go2rtc_streams_response(
|
||||
)
|
||||
|
||||
try:
|
||||
old_streams = _go2rtc_streams(old_raw_config)
|
||||
old_go2rtc = _go2rtc_config(old_raw_config)
|
||||
except ruamel.yaml.YAMLError:
|
||||
# with no readable saved config, every source is treated as new
|
||||
old_streams = None
|
||||
old_go2rtc = {}
|
||||
|
||||
issues = find_restricted_go2rtc_stream_changes(old_streams, new_streams)
|
||||
if not issues:
|
||||
issues = find_restricted_go2rtc_stream_changes(
|
||||
old_go2rtc.get("streams"), new_go2rtc.get("streams")
|
||||
)
|
||||
exec_keys = find_restricted_go2rtc_exec_changes(old_go2rtc, new_go2rtc)
|
||||
if not issues and not exec_keys:
|
||||
return None
|
||||
|
||||
messages = []
|
||||
if exec_keys:
|
||||
messages.append(f"Restricted go2rtc option: {', '.join(exec_keys)}")
|
||||
for issue, label in (
|
||||
(Go2rtcStreamIssue.restricted, "Restricted go2rtc stream source in"),
|
||||
(Go2rtcStreamIssue.unknown_variable, "Unknown variable in go2rtc stream"),
|
||||
@@ -665,9 +671,7 @@ def config_save(save_option: str, body: Any = Body(media_type="text/plain")):
|
||||
except OSError:
|
||||
old_raw_config = ""
|
||||
|
||||
restricted_response = _restricted_go2rtc_streams_response(
|
||||
old_raw_config, new_config
|
||||
)
|
||||
restricted_response = _restricted_go2rtc_response(old_raw_config, new_config)
|
||||
if restricted_response is not None:
|
||||
return restricted_response
|
||||
|
||||
@@ -983,7 +987,7 @@ def config_set(request: Request, body: AppConfigSetBody):
|
||||
),
|
||||
status_code=400,
|
||||
)
|
||||
restricted_response = _restricted_go2rtc_streams_response(
|
||||
restricted_response = _restricted_go2rtc_response(
|
||||
old_raw_config, new_raw_config
|
||||
)
|
||||
if restricted_response is not None:
|
||||
|
||||
+16
-7
@@ -45,6 +45,7 @@ from frigate.genai.prompts import (
|
||||
)
|
||||
from frigate.genai.utils import build_assistant_message_for_conversation
|
||||
from frigate.jobs.vlm_watch import (
|
||||
VLMWatchJob,
|
||||
get_vlm_watch_job,
|
||||
start_vlm_watch_job,
|
||||
stop_vlm_watch_job,
|
||||
@@ -765,7 +766,7 @@ async def _execute_tool_internal(
|
||||
elif tool_name == "start_camera_watch":
|
||||
return await _execute_start_camera_watch(request, arguments)
|
||||
elif tool_name == "stop_camera_watch":
|
||||
return _execute_stop_camera_watch()
|
||||
return _execute_stop_camera_watch(request)
|
||||
elif tool_name == "get_profile_status":
|
||||
return _execute_get_profile_status(request)
|
||||
elif tool_name == "get_recap":
|
||||
@@ -819,6 +820,7 @@ async def _execute_start_camera_watch(
|
||||
dispatcher=request.app.dispatcher,
|
||||
labels=labels,
|
||||
zones=zones,
|
||||
username=request.headers.get("remote-user", ""),
|
||||
)
|
||||
except RuntimeError as e:
|
||||
logger.exception("Failed to start VLM watch job: %s", e)
|
||||
@@ -834,7 +836,18 @@ async def _execute_start_camera_watch(
|
||||
}
|
||||
|
||||
|
||||
def _execute_stop_camera_watch() -> dict[str, Any]:
|
||||
def _can_cancel_watch_job(request: Request, job: VLMWatchJob) -> bool:
|
||||
"""Admins can cancel any watch job; other users only jobs they started."""
|
||||
role = request.headers.get("remote-role", "viewer")
|
||||
username = request.headers.get("remote-user", "")
|
||||
return role == "admin" or username == job.username
|
||||
|
||||
|
||||
def _execute_stop_camera_watch(request: Request) -> dict[str, Any]:
|
||||
job = get_vlm_watch_job()
|
||||
if job is not None and not _can_cancel_watch_job(request, job):
|
||||
return {"success": False, "message": "Not authorized to cancel this watch job."}
|
||||
|
||||
cancelled = stop_vlm_watch_job()
|
||||
if cancelled:
|
||||
return {"success": True, "message": "Watch job cancelled."}
|
||||
@@ -1548,11 +1561,7 @@ async def cancel_vlm_monitor(request: Request) -> JSONResponse:
|
||||
status_code=404,
|
||||
)
|
||||
|
||||
role = request.headers.get("remote-role", "viewer")
|
||||
username = request.headers.get("remote-user", "")
|
||||
|
||||
# Admin can cancel any job; other users can only cancel jobs they started.
|
||||
if role != "admin" and username != job.username:
|
||||
if not _can_cancel_watch_job(request, job):
|
||||
return JSONResponse(
|
||||
content={
|
||||
"success": False,
|
||||
|
||||
+13
-1
@@ -74,7 +74,19 @@ def _resolve_cache_age(max_cache_age: int) -> int:
|
||||
return max_cache_age.default
|
||||
|
||||
|
||||
@router.get("/{camera_name}", dependencies=[Depends(require_camera_access)])
|
||||
@router.get(
|
||||
"/{camera_name}",
|
||||
dependencies=[Depends(require_camera_access)],
|
||||
description=(
|
||||
"An MJPEG stream of the camera's latest processed frame, intended for debugging only. "
|
||||
"Every frame of every open stream is color converted, annotated, resized, and JPEG "
|
||||
"encoded in Frigate's main process, which adds load to the system and can slow down "
|
||||
"Frigate's processing. It is strictly not recommended to view this stream "
|
||||
"continuously, such as on a dashboard. For live viewing, use a go2rtc restream "
|
||||
"instead. The frame rate and resolution can be raised with the fps and height "
|
||||
"parameters, for example ?fps=10&height=1080, at the cost of additional load."
|
||||
),
|
||||
)
|
||||
async def mjpeg_feed(
|
||||
request: Request,
|
||||
camera_name: str,
|
||||
|
||||
@@ -2,7 +2,7 @@ from enum import Enum
|
||||
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
from frigate.util.config import resolve_ffmpeg_path
|
||||
from frigate.util.config import is_valid_ffmpeg_path, resolve_ffmpeg_path
|
||||
|
||||
from ..base import FrigateBaseModel
|
||||
from ..env import EnvString
|
||||
@@ -87,6 +87,16 @@ class FfmpegConfig(FrigateBaseModel):
|
||||
description="Default GPU index used for hardware acceleration if available.",
|
||||
)
|
||||
|
||||
@field_validator("path")
|
||||
@classmethod
|
||||
def validate_path(cls, v: str) -> str:
|
||||
if not is_valid_ffmpeg_path(v):
|
||||
raise ValueError(
|
||||
"FFmpeg path must be a version alias or an absolute path without "
|
||||
"spaces, quotes or shell characters"
|
||||
)
|
||||
return v
|
||||
|
||||
@property
|
||||
def ffmpeg_path(self) -> str:
|
||||
return resolve_ffmpeg_path(self.path, "ffmpeg")
|
||||
|
||||
@@ -85,6 +85,23 @@ class TestConfigGo2rtcStreamRestrictions(BaseTestHttp):
|
||||
headers={"Content-Type": "text/plain"},
|
||||
)
|
||||
|
||||
def _set_go2rtc(self, go2rtc: dict):
|
||||
with AuthTestClient(self.app) as client:
|
||||
return client.put(
|
||||
"/config/set",
|
||||
json={"config_data": {"go2rtc": go2rtc}, "requires_restart": 1},
|
||||
)
|
||||
|
||||
def _save_go2rtc(self, go2rtc: dict):
|
||||
config = copy.deepcopy(_CONFIG)
|
||||
config["go2rtc"].update(go2rtc)
|
||||
with AuthTestClient(self.app) as client:
|
||||
return client.post(
|
||||
"/config/save?save_option=saveonly",
|
||||
content=_dump(config),
|
||||
headers={"Content-Type": "text/plain"},
|
||||
)
|
||||
|
||||
# --- config/set ---
|
||||
|
||||
def test_set_rejects_injected_ffmpeg_source(self):
|
||||
@@ -215,3 +232,108 @@ class TestConfigGo2rtcStreamRestrictions(BaseTestHttp):
|
||||
resp = self._set_streams({"new_stream": [src]})
|
||||
assert resp.status_code == 200, resp.text
|
||||
assert src in self._read_config()
|
||||
|
||||
# --- go2rtc ffmpeg and ngrok options ---
|
||||
|
||||
def test_save_rejects_ffmpeg_bin_override(self):
|
||||
before = self._read_config()
|
||||
resp = self._save_go2rtc({"ffmpeg": {"bin": "/bin/sh", "global": "-c 'id' x"}})
|
||||
assert resp.status_code == 400
|
||||
assert resp.json()["message"] == (
|
||||
"Restricted go2rtc option: ffmpeg.bin, ffmpeg.global"
|
||||
)
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_set_rejects_ffmpeg_bin_override(self):
|
||||
before = self._read_config()
|
||||
resp = self._set_go2rtc({"ffmpeg": {"bin": "/bin/sh"}})
|
||||
assert resp.status_code == 400
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_save_rejects_ffmpeg_template_override(self):
|
||||
before = self._read_config()
|
||||
resp = self._save_go2rtc({"ffmpeg": {"rtsp": "-i {input} -y /config/x"}})
|
||||
assert resp.status_code == 400
|
||||
assert "ffmpeg.rtsp" in resp.json()["message"]
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_set_rejects_custom_ffmpeg_template(self):
|
||||
# a stream can reference any template key with #video=<name>
|
||||
before = self._read_config()
|
||||
resp = self._set_go2rtc({"ffmpeg": {"evil": "-y /config/x"}})
|
||||
assert resp.status_code == 400
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_save_rejects_ngrok(self):
|
||||
before = self._read_config()
|
||||
resp = self._save_go2rtc({"ngrok": {"command": "/bin/sh -c id"}})
|
||||
assert resp.status_code == 400
|
||||
assert resp.json()["message"] == "Restricted go2rtc option: ngrok.command"
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_set_rejects_ngrok(self):
|
||||
before = self._read_config()
|
||||
resp = self._set_go2rtc({"ngrok": {"command": "/bin/sh -c id"}})
|
||||
assert resp.status_code == 400
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_save_keeps_existing_ffmpeg_template_on_disk(self):
|
||||
go2rtc = {"ffmpeg": {"global": "-vaapi_device /dev/dri/renderD128"}}
|
||||
config = copy.deepcopy(_CONFIG)
|
||||
config["go2rtc"].update(go2rtc)
|
||||
with open(self.config_path, "w") as f:
|
||||
f.write(_dump(config))
|
||||
|
||||
resp = self._save_go2rtc(go2rtc)
|
||||
assert resp.status_code == 200, resp.text
|
||||
|
||||
resp = self._save_go2rtc({"ffmpeg": {"global": "-hide_banner"}})
|
||||
assert resp.status_code == 400
|
||||
|
||||
def test_exec_options_allowed_when_override_set(self):
|
||||
with patch.dict(os.environ, {"GO2RTC_ALLOW_ARBITRARY_EXEC": "true"}):
|
||||
resp = self._save_go2rtc(
|
||||
{
|
||||
"ffmpeg": {"bin": "/usr/bin/ffmpeg", "rtsp": "-i {input}"},
|
||||
"ngrok": {"command": "ngrok tcp 8555"},
|
||||
}
|
||||
)
|
||||
assert resp.status_code == 200, resp.text
|
||||
assert "ngrok tcp 8555" in self._read_config()
|
||||
|
||||
def test_save_rejects_unsafe_ffmpeg_path(self):
|
||||
before = self._read_config()
|
||||
config = copy.deepcopy(_CONFIG)
|
||||
config["ffmpeg"] = {"path": "/bin/sh -c id;#"}
|
||||
with AuthTestClient(self.app) as client:
|
||||
resp = client.post(
|
||||
"/config/save?save_option=saveonly",
|
||||
content=_dump(config),
|
||||
headers={"Content-Type": "text/plain"},
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
assert self._read_config() == before
|
||||
|
||||
# --- go2rtc ${VAR} expansion ---
|
||||
|
||||
def test_set_rejects_var_expansion_source(self):
|
||||
before = self._read_config()
|
||||
resp = self._set_streams({"new_stream": "${NOPE:exec:touch /tmp/pwned}"})
|
||||
assert resp.status_code == 400
|
||||
assert "Restricted go2rtc stream source" in resp.json()["message"]
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_set_rejects_escaped_var_expansion_source(self):
|
||||
before = self._read_config()
|
||||
resp = self._set_streams({"new_stream": "${{NOPE:exec:id}}"})
|
||||
assert resp.status_code == 400
|
||||
assert "Restricted go2rtc stream source" in resp.json()["message"]
|
||||
assert self._read_config() == before
|
||||
|
||||
def test_set_allows_var_expansion_source_when_override_set(self):
|
||||
with patch(
|
||||
"frigate.util.services.is_go2rtc_arbitrary_exec_allowed",
|
||||
return_value=True,
|
||||
):
|
||||
resp = self._set_streams({"new_stream": "${NOPE:exec:id}"})
|
||||
assert resp.status_code == 200, resp.text
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Tests for camera watch ownership in the chat tools."""
|
||||
|
||||
import asyncio
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from frigate.api.chat import _execute_start_camera_watch, _execute_stop_camera_watch
|
||||
from frigate.jobs.vlm_watch import VLMWatchJob
|
||||
|
||||
|
||||
def _request(user: str, role: str) -> SimpleNamespace:
|
||||
return SimpleNamespace(headers={"remote-user": user, "remote-role": role})
|
||||
|
||||
|
||||
class TestStopCameraWatch(unittest.TestCase):
|
||||
def setUp(self):
|
||||
job = VLMWatchJob(camera="front", condition="person", username="alice")
|
||||
patch("frigate.api.chat.get_vlm_watch_job", return_value=job).start()
|
||||
self.stop = patch(
|
||||
"frigate.api.chat.stop_vlm_watch_job", return_value=True
|
||||
).start()
|
||||
self.addCleanup(patch.stopall)
|
||||
|
||||
def test_other_user_cannot_cancel(self):
|
||||
result = _execute_stop_camera_watch(_request("bob", "viewer"))
|
||||
|
||||
self.assertFalse(result["success"])
|
||||
self.stop.assert_not_called()
|
||||
|
||||
def test_creator_can_cancel(self):
|
||||
result = _execute_stop_camera_watch(_request("alice", "viewer"))
|
||||
|
||||
self.assertTrue(result["success"])
|
||||
self.stop.assert_called_once()
|
||||
|
||||
def test_admin_can_cancel(self):
|
||||
result = _execute_stop_camera_watch(_request("bob", "admin"))
|
||||
|
||||
self.assertTrue(result["success"])
|
||||
self.stop.assert_called_once()
|
||||
|
||||
|
||||
class TestStartCameraWatch(unittest.TestCase):
|
||||
@patch("frigate.api.chat.require_camera_access", new_callable=AsyncMock)
|
||||
@patch("frigate.api.chat.start_vlm_watch_job", return_value="job1")
|
||||
def test_records_caller_as_owner(self, start, _access):
|
||||
request = _request("alice", "viewer")
|
||||
request.app = MagicMock()
|
||||
request.app.frigate_config.cameras = {"front": None}
|
||||
request.app.genai_manager.chat_client.supports_vision = True
|
||||
|
||||
asyncio.run(
|
||||
_execute_start_camera_watch(
|
||||
request, {"camera": "front", "condition": "person"}
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(start.call_args.kwargs["username"], "alice")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -11,6 +11,7 @@ from frigate.config import BirdseyeModeEnum, FrigateConfig
|
||||
from frigate.const import MODEL_CACHE_DIR
|
||||
from frigate.detectors import DetectorTypeEnum
|
||||
from frigate.util.builtin import deep_merge
|
||||
from frigate.util.config import resolve_ffmpeg_path
|
||||
|
||||
|
||||
class TestConfig(unittest.TestCase):
|
||||
@@ -1765,5 +1766,54 @@ class TestAttributeFilterDefaults(unittest.TestCase):
|
||||
self.assertEqual(face_filter.min_score, 0.3)
|
||||
|
||||
|
||||
class TestFfmpegPath(unittest.TestCase):
|
||||
# ffmpeg commands are split on spaces, so this would run /bin/sh
|
||||
UNSAFE_PATH = "/bin/sh -c id;#"
|
||||
|
||||
def setUp(self):
|
||||
self.minimal = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"cameras": {
|
||||
"back": {
|
||||
"ffmpeg": {
|
||||
"inputs": [
|
||||
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
||||
]
|
||||
},
|
||||
"detect": {"height": 1080, "width": 1920, "fps": 5},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
def test_custom_path_allowed(self):
|
||||
config = deep_merge(
|
||||
{"ffmpeg": {"path": "/usr/lib/jellyfin-ffmpeg"}}, self.minimal
|
||||
)
|
||||
frigate_config = FrigateConfig(**config)
|
||||
self.assertEqual(
|
||||
frigate_config.cameras["back"].ffmpeg.ffmpeg_path,
|
||||
"/usr/lib/jellyfin-ffmpeg/bin/ffmpeg",
|
||||
)
|
||||
|
||||
def test_unsafe_global_path_rejected(self):
|
||||
for path in (self.UNSAFE_PATH, "/opt/my ffmpeg", "/opt/'x'", "/opt/x\n"):
|
||||
config = deep_merge({"ffmpeg": {"path": path}}, self.minimal)
|
||||
with self.assertRaises(ValidationError, msg=path):
|
||||
FrigateConfig(**config)
|
||||
|
||||
def test_unsafe_camera_path_rejected(self):
|
||||
config = deep_merge(
|
||||
{"cameras": {"back": {"ffmpeg": {"path": self.UNSAFE_PATH}}}},
|
||||
self.minimal,
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
FrigateConfig(**config)
|
||||
|
||||
def test_resolve_falls_back_for_unsafe_path(self):
|
||||
self.assertEqual(
|
||||
resolve_ffmpeg_path(self.UNSAFE_PATH), resolve_ffmpeg_path("default")
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
"""Tests for the go2rtc ffmpeg and ngrok options applied at startup."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from frigate.util.services import (
|
||||
apply_go2rtc_ffmpeg_config,
|
||||
is_restricted_go2rtc_api_source,
|
||||
is_restricted_go2rtc_source,
|
||||
)
|
||||
|
||||
FFMPEG_PATH = "/usr/lib/ffmpeg/7.0/bin/ffmpeg"
|
||||
|
||||
|
||||
class TestApplyGo2rtcFfmpegConfig(unittest.TestCase):
|
||||
def setUp(self):
|
||||
env_patch = patch.dict(os.environ)
|
||||
env_patch.start()
|
||||
self.addCleanup(env_patch.stop)
|
||||
os.environ.pop("GO2RTC_ALLOW_ARBITRARY_EXEC", None)
|
||||
|
||||
def test_sets_bin_when_missing(self):
|
||||
config = {}
|
||||
assert apply_go2rtc_ffmpeg_config(config, FFMPEG_PATH) == []
|
||||
assert config["ffmpeg"] == {"bin": FFMPEG_PATH}
|
||||
|
||||
def test_forces_bin_override(self):
|
||||
config = {"ffmpeg": {"bin": "/bin/sh", "global": "-c 'id' x"}}
|
||||
assert apply_go2rtc_ffmpeg_config(config, FFMPEG_PATH) == ["ffmpeg.bin"]
|
||||
assert config["ffmpeg"]["bin"] == FFMPEG_PATH
|
||||
|
||||
def test_keeps_saved_templates(self):
|
||||
config = {"ffmpeg": {"global": "-vaapi_device /dev/dri/renderD128"}}
|
||||
assert apply_go2rtc_ffmpeg_config(config, FFMPEG_PATH) == []
|
||||
assert config["ffmpeg"]["global"] == "-vaapi_device /dev/dri/renderD128"
|
||||
|
||||
def test_drops_ngrok(self):
|
||||
config = {"ngrok": {"command": "/bin/sh -c id"}}
|
||||
assert apply_go2rtc_ffmpeg_config(config, FFMPEG_PATH) == ["ngrok"]
|
||||
assert "ngrok" not in config
|
||||
|
||||
def test_allows_bin_and_ngrok_when_override_set(self):
|
||||
config = {
|
||||
"ffmpeg": {"bin": "/usr/bin/ffmpeg"},
|
||||
"ngrok": {"command": "ngrok tcp 8555"},
|
||||
}
|
||||
with patch.dict(os.environ, {"GO2RTC_ALLOW_ARBITRARY_EXEC": "true"}):
|
||||
assert apply_go2rtc_ffmpeg_config(config, FFMPEG_PATH) == []
|
||||
assert config["ffmpeg"]["bin"] == "/usr/bin/ffmpeg"
|
||||
assert config["ngrok"] == {"command": "ngrok tcp 8555"}
|
||||
|
||||
|
||||
class TestRestrictedGo2rtcVarExpansion(unittest.TestCase):
|
||||
"""go2rtc expands `${VAR:default}` over the raw config before parsing, and
|
||||
the default can name an exec source, so a `${` source is restricted."""
|
||||
|
||||
def setUp(self):
|
||||
exec_patch = patch(
|
||||
"frigate.util.services.is_go2rtc_arbitrary_exec_allowed",
|
||||
return_value=False,
|
||||
)
|
||||
self.mock_exec_allowed = exec_patch.start()
|
||||
self.addCleanup(exec_patch.stop)
|
||||
|
||||
def test_var_expansion_source_is_restricted(self):
|
||||
for source in (
|
||||
"${NOPE:exec:touch /tmp/x}",
|
||||
"rtsp://host/${CAM}",
|
||||
" ${NOPE:exec:id}",
|
||||
):
|
||||
self.assertTrue(is_restricted_go2rtc_source(source), source)
|
||||
self.assertTrue(is_restricted_go2rtc_api_source(source), source)
|
||||
|
||||
def test_plain_sources_are_not_restricted(self):
|
||||
for source in (
|
||||
"rtsp://user:pass@host/stream",
|
||||
"ffmpeg:front#video=h264#height=720",
|
||||
):
|
||||
self.assertFalse(is_restricted_go2rtc_source(source), source)
|
||||
self.assertFalse(is_restricted_go2rtc_api_source(source), source)
|
||||
|
||||
def test_var_expansion_allowed_when_override_set(self):
|
||||
self.mock_exec_allowed.return_value = True
|
||||
self.assertFalse(is_restricted_go2rtc_source("${NOPE:exec:id}"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+16
-3
@@ -3,6 +3,7 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from typing import Any
|
||||
|
||||
@@ -23,6 +24,15 @@ logger = logging.getLogger(__name__)
|
||||
CURRENT_CONFIG_VERSION = "0.18-0"
|
||||
DEFAULT_CONFIG_FILE = os.path.join(CONFIG_DIR, "config.yml")
|
||||
|
||||
# ffmpeg commands are built as strings and split on whitespace, so a custom path
|
||||
# must stay a single plain token
|
||||
_CUSTOM_FFMPEG_PATH = re.compile(r"/[\w.+@/-]+")
|
||||
|
||||
|
||||
def is_valid_ffmpeg_path(path: str) -> bool:
|
||||
"""Check that a custom ffmpeg path has no whitespace, quotes or shell syntax."""
|
||||
return not path.startswith("/") or _CUSTOM_FFMPEG_PATH.fullmatch(path) is not None
|
||||
|
||||
|
||||
def resolve_ffmpeg_path(path: str, binary: str = "ffmpeg") -> str:
|
||||
"""Resolve an ffmpeg version alias or custom path to a binary path.
|
||||
@@ -30,10 +40,13 @@ def resolve_ffmpeg_path(path: str, binary: str = "ffmpeg") -> str:
|
||||
A bare version alias that is no longer bundled (for example one that was
|
||||
dropped when the default version changed) falls back to the default
|
||||
bundled version so existing configs keep working across an upgrade or a
|
||||
revert. Custom install paths (anything absolute) are used as-is.
|
||||
revert. Custom install paths (anything absolute) are used as-is, unless
|
||||
they fail `is_valid_ffmpeg_path`, which also falls back to the default.
|
||||
"""
|
||||
if path == "default" or (
|
||||
not path.startswith("/") and path not in INCLUDED_FFMPEG_VERSIONS
|
||||
if (
|
||||
path == "default"
|
||||
or not is_valid_ffmpeg_path(path)
|
||||
or (not path.startswith("/") and path not in INCLUDED_FFMPEG_VERSIONS)
|
||||
):
|
||||
version = DEFAULT_FFMPEG_VERSION
|
||||
elif path in INCLUDED_FFMPEG_VERSIONS:
|
||||
|
||||
@@ -980,9 +980,15 @@ def is_go2rtc_arbitrary_exec_allowed() -> bool:
|
||||
|
||||
|
||||
def is_restricted_go2rtc_source(stream_source: str) -> bool:
|
||||
"""Check if a stream source is a restricted type (echo, expr, or exec)
|
||||
and the GO2RTC_ALLOW_ARBITRARY_EXEC override is not set."""
|
||||
if not stream_source.strip().startswith(("echo:", "expr:", "exec:")):
|
||||
"""Check if a stream source is restricted and the
|
||||
GO2RTC_ALLOW_ARBITRARY_EXEC override is not set.
|
||||
|
||||
Restricted sources are the echo, expr and exec schemes, and any source
|
||||
using go2rtc's `${VAR:default}` expansion, which go2rtc runs over the raw
|
||||
config before parsing and whose default can name an exec source.
|
||||
"""
|
||||
source = stream_source.strip()
|
||||
if not source.startswith(("echo:", "expr:", "exec:")) and "${" not in source:
|
||||
return False
|
||||
return not is_go2rtc_arbitrary_exec_allowed()
|
||||
|
||||
@@ -1103,6 +1109,74 @@ def find_restricted_go2rtc_stream_changes(
|
||||
return issues
|
||||
|
||||
|
||||
# go2rtc runs `ffmpeg.bin` and `ngrok.command`, and every other `ffmpeg` key is a
|
||||
# template of ffmpeg arguments that `#video=<name>` and friends can reference
|
||||
_GO2RTC_EXEC_SECTIONS = ("ffmpeg", "ngrok")
|
||||
|
||||
|
||||
def find_restricted_go2rtc_exec_changes(
|
||||
old_go2rtc: dict[str, Any] | None, new_go2rtc: dict[str, Any] | None
|
||||
) -> list[str]:
|
||||
"""Return the go2rtc ffmpeg and ngrok keys added or changed through the API.
|
||||
|
||||
These are only accepted with arbitrary exec enabled. Keys already in the
|
||||
saved config are left alone, the same as stream sources.
|
||||
"""
|
||||
if is_go2rtc_arbitrary_exec_allowed():
|
||||
return []
|
||||
|
||||
old_go2rtc = old_go2rtc if isinstance(old_go2rtc, dict) else {}
|
||||
new_go2rtc = new_go2rtc if isinstance(new_go2rtc, dict) else {}
|
||||
changed: list[str] = []
|
||||
|
||||
for section in _GO2RTC_EXEC_SECTIONS:
|
||||
old = old_go2rtc.get(section)
|
||||
new = new_go2rtc.get(section)
|
||||
|
||||
if not isinstance(new, dict):
|
||||
if new is not None and new != old:
|
||||
changed.append(section)
|
||||
continue
|
||||
|
||||
old = old if isinstance(old, dict) else {}
|
||||
changed.extend(
|
||||
f"{section}.{key}" for key, value in new.items() if old.get(key) != value
|
||||
)
|
||||
|
||||
return changed
|
||||
|
||||
|
||||
def apply_go2rtc_ffmpeg_config(
|
||||
go2rtc_config: dict[str, Any], ffmpeg_path: str
|
||||
) -> list[str]:
|
||||
"""Set go2rtc's ffmpeg binary for startup.
|
||||
|
||||
Unless arbitrary exec is enabled, `ffmpeg.bin` is forced to Frigate's ffmpeg
|
||||
and `ngrok` is removed. Templates in the saved config are kept.
|
||||
|
||||
Returns:
|
||||
The keys that were overridden or removed
|
||||
"""
|
||||
allowed = is_go2rtc_arbitrary_exec_allowed()
|
||||
restricted: list[str] = []
|
||||
|
||||
ffmpeg = go2rtc_config.get("ffmpeg")
|
||||
if not isinstance(ffmpeg, dict):
|
||||
ffmpeg = go2rtc_config["ffmpeg"] = {}
|
||||
|
||||
if ffmpeg.get("bin") is None:
|
||||
ffmpeg["bin"] = ffmpeg_path
|
||||
elif ffmpeg["bin"] != ffmpeg_path and not allowed:
|
||||
restricted.append("ffmpeg.bin")
|
||||
ffmpeg["bin"] = ffmpeg_path
|
||||
|
||||
if "ngrok" in go2rtc_config and not allowed:
|
||||
restricted.append("ngrok")
|
||||
del go2rtc_config["ngrok"]
|
||||
|
||||
return restricted
|
||||
|
||||
|
||||
def ffprobe_stream(ffmpeg, path: str, detailed: bool = False) -> sp.CompletedProcess:
|
||||
"""Run ffprobe on stream."""
|
||||
clean_path = escape_special_characters(path)
|
||||
|
||||
Generated
+14
-32
@@ -1487,19 +1487,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.1.tgz",
|
||||
"integrity": "sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==",
|
||||
"version": "1.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.0.tgz",
|
||||
"integrity": "sha512-iGURLGuKDLakSEl7Pgfv8h7f+XLT+V861Wfhz0zlEl5nyFuKUopdkFBPKqTllTUp06aOwPuH8iuUEb3yp3MpbQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.59.1"
|
||||
"playwright": "1.65.0"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/number": {
|
||||
@@ -11558,50 +11558,32 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.59.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.1.tgz",
|
||||
"integrity": "sha512-C8oWjPR3F81yljW9o5OxcWzfh6avkVwDD2VYdwIGqTkl+OGFISgypqzfu7dOe4QNLL2aqcWBmI3PMtLIK233lw==",
|
||||
"version": "1.65.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.0.tgz",
|
||||
"integrity": "sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.59.1"
|
||||
"playwright-core": "1.65.0"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "2.3.2"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.59.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.1.tgz",
|
||||
"integrity": "sha512-HBV/RJg81z5BiiZ9yPzIiClYV/QMsDCKUyogwH9p3MCP6IYjUFu/MActgYAvK0oWyV9NlwM3GLBjADyWgydVyg==",
|
||||
"version": "1.65.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.0.tgz",
|
||||
"integrity": "sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright/node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
|
||||
@@ -32,8 +32,8 @@ export function GenericVideoPlayer({
|
||||
const checkSourceExists = async (url: string) => {
|
||||
try {
|
||||
const response = await fetch(url, { method: "HEAD" });
|
||||
// nginx vod module returns 502 for non existent media
|
||||
// https://github.com/kaltura/nginx-vod-module/issues/468
|
||||
// missing media is a 404; 502 still covers a failed or
|
||||
// unreachable mapping request, which is equally unplayable
|
||||
setSourceExists(response.status !== 502 && response.status !== 404);
|
||||
} catch (error) {
|
||||
setSourceExists(false);
|
||||
|
||||
Reference in New Issue
Block a user