From ad9092d0da551b9396068556e59cd0486e5720fa Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 22 Apr 2026 10:19:30 -0500 Subject: [PATCH] Tweaks (#22965) * use ffmpeg to probe rtsp urls instead of cv2 cv2 is faster (no subprocess launch) and will continue to be used for recording segments * tweak faq * change unsaved color to orange avoids confusion with validation errors (red) * don't use any variant of orange as a profile color avoids confusion with unsaved changes * more unsaved color tweaks --- docs/docs/troubleshooting/faqs.md | 30 +++++++------------ frigate/util/services.py | 18 +++++++---- .../CameraReviewClassification.tsx | 4 +-- .../config-form/sections/BaseSection.tsx | 4 +-- .../theme/fields/KnownPlatesField.tsx | 2 +- .../theme/fields/ReplaceRulesField.tsx | 2 +- .../theme/templates/FieldTemplate.tsx | 6 ++-- .../theme/templates/ObjectFieldTemplate.tsx | 2 +- web/src/pages/Settings.tsx | 4 +-- web/src/utils/profileColors.ts | 20 ++++++------- .../settings/Go2RtcStreamsSettingsView.tsx | 4 ++- web/src/views/settings/SingleSectionPage.tsx | 4 +-- web/tailwind.config.cjs | 1 + 13 files changed, 51 insertions(+), 50 deletions(-) diff --git a/docs/docs/troubleshooting/faqs.md b/docs/docs/troubleshooting/faqs.md index 6cd67ba88..e11ae6315 100644 --- a/docs/docs/troubleshooting/faqs.md +++ b/docs/docs/troubleshooting/faqs.md @@ -111,26 +111,16 @@ TCP ensures that all data packets arrive in the correct order. This is crucial f You can still configure Frigate to use UDP by using ffmpeg input args or the preset `preset-rtsp-udp`. See the [ffmpeg presets](/configuration/ffmpeg_presets) documentation. -### Frigate hangs on startup with a "probing detect stream" message in the logs +### Frigate is slow to start up with a "probing detect stream" message in the logs -On startup, Frigate probes each camera's detect stream with OpenCV to auto-detect its resolution. OpenCV's FFmpeg backend may attempt RTSP over UDP during this probe regardless of the `-rtsp_transport tcp` in your `input_args` or preset. For cameras that do not respond to UDP (common on some Reolink models and others behind firewalls that block UDP), the probe can hang indefinitely and block Frigate from finishing startup, or it can return zeroed-out dimensions that show up as width `0` and height `0` in Camera Probe Info under System Metrics. +When `detect.width` and `detect.height` are not set, Frigate probes each camera's detect stream on startup (and when saving the config) to auto-detect its resolution. For RTSP streams Frigate probes with ffprobe and automatically retries over TCP if UDP doesn't respond, with a 5 second timeout per attempt. A camera that cannot be reached over either transport will add up to ~10 seconds to startup before Frigate falls through with default dimensions, which may show up as width `0` and height `0` in Camera Probe Info under System Metrics. -There are two ways to avoid this: +To skip the probe entirely and make startup instant, set `detect.width` and `detect.height` explicitly in your camera config: -1. Set `detect.width` and `detect.height` explicitly in your camera config. When both are set, Frigate skips the auto-detect probe entirely: - - ```yaml - cameras: - my_camera: - detect: - width: 1280 - height: 720 - ``` - -2. Force OpenCV's FFmpeg backend to use TCP for RTSP by setting the environment variable on your Frigate container: - - ``` - OPENCV_FFMPEG_CAPTURE_OPTIONS=rtsp_transport;tcp - ``` - - This is a process-wide setting and applies to all cameras. If you have any cameras that require `preset-rtsp-udp`, use option 1 instead. +```yaml +cameras: + my_camera: + detect: + width: 1280 + height: 720 +``` diff --git a/frigate/util/services.py b/frigate/util/services.py index c20ab2765..15c439d48 100644 --- a/frigate/util/services.py +++ b/frigate/util/services.py @@ -877,15 +877,23 @@ async def get_video_properties( cap.release() return valid, width, height, fourcc, duration - # try cv2 first - has_video, width, height, fourcc, duration = probe_with_cv2(url) + is_rtsp = url.startswith("rtsp://") - # fallback to ffprobe if needed - if not has_video or (get_duration and duration < 0): + if is_rtsp: + # skip cv2 for RTSP: its FFmpeg backend has a hardcoded ~30s internal + # timeout that cannot be shortened per-call, and ffprobe bounded by + # -rw_timeout handles RTSP probing reliably has_video, width, height, fourcc, duration = await probe_with_ffprobe(url) + else: + # try cv2 first for local files, HTTP, RTMP + has_video, width, height, fourcc, duration = probe_with_cv2(url) + + # fallback to ffprobe if needed + if not has_video or (get_duration and duration < 0): + has_video, width, height, fourcc, duration = await probe_with_ffprobe(url) # last resort for RTSP: try TCP transport, since default UDP may be blocked - if (not has_video or (get_duration and duration < 0)) and url.startswith("rtsp://"): + if (not has_video or (get_duration and duration < 0)) and is_rtsp: has_video, width, height, fourcc, duration = await probe_with_ffprobe( url, rtsp_transport="tcp" ) diff --git a/web/src/components/config-form/sectionExtras/CameraReviewClassification.tsx b/web/src/components/config-form/sectionExtras/CameraReviewClassification.tsx index ffe9b19b2..86f363aec 100644 --- a/web/src/components/config-form/sectionExtras/CameraReviewClassification.tsx +++ b/web/src/components/config-form/sectionExtras/CameraReviewClassification.tsx @@ -218,7 +218,7 @@ export default function CameraReviewClassification({