From 7b65bcf13cae1b5aa634cf2000e3cfad019322d4 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 29 Jan 2025 07:44:13 -0600 Subject: [PATCH 1/3] Fix interpolation for autotracking cameras (#16211) --- frigate/ptz/onvif.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frigate/ptz/onvif.py b/frigate/ptz/onvif.py index 21c973baa..82529e967 100644 --- a/frigate/ptz/onvif.py +++ b/frigate/ptz/onvif.py @@ -411,19 +411,19 @@ class OnvifController: # The onvif spec says this can report as +INF and -INF, so this may need to be modified pan = numpy.interp( pan, + [-1, 1], [ self.cams[camera_name]["relative_fov_range"]["XRange"]["Min"], self.cams[camera_name]["relative_fov_range"]["XRange"]["Max"], ], - [-1, 1], ) tilt = numpy.interp( tilt, + [-1, 1], [ self.cams[camera_name]["relative_fov_range"]["YRange"]["Min"], self.cams[camera_name]["relative_fov_range"]["YRange"]["Max"], ], - [-1, 1], ) move_request.Speed = { @@ -536,11 +536,11 @@ class OnvifController: # function takes in 0 to 1 for zoom, interpolate to the values of the camera. zoom = numpy.interp( zoom, + [0, 1], [ self.cams[camera_name]["absolute_zoom_range"]["XRange"]["Min"], self.cams[camera_name]["absolute_zoom_range"]["XRange"]["Max"], ], - [0, 1], ) move_request.Speed = {"Zoom": speed} From cea210d8004845d609c549cb65f38c4e874efc0f Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 30 Jan 2025 10:27:38 -0700 Subject: [PATCH 2/3] Fix csrf (#16230) * Fix csrf check * Simplify --- frigate/api/fastapi_app.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frigate/api/fastapi_app.py b/frigate/api/fastapi_app.py index 168404ea6..cf8e98536 100644 --- a/frigate/api/fastapi_app.py +++ b/frigate/api/fastapi_app.py @@ -26,14 +26,13 @@ from frigate.storage import StorageMaintainer logger = logging.getLogger(__name__) -def check_csrf(request: Request): +def check_csrf(request: Request) -> bool: if request.method in ["GET", "HEAD", "OPTIONS", "TRACE"]: - pass + return True if "origin" in request.headers and "x-csrf-token" not in request.headers: - return JSONResponse( - content={"success": False, "message": "Missing CSRF header"}, - status_code=401, - ) + return False + + return True # Used to retrieve the remote-user header: https://starlette-context.readthedocs.io/en/latest/plugins.html#easy-mode @@ -71,7 +70,12 @@ def create_fastapi_app( @app.middleware("http") async def frigate_middleware(request: Request, call_next): # Before request - check_csrf(request) + if not check_csrf(request): + return JSONResponse( + content={"success": False, "message": "Missing CSRF header"}, + status_code=401, + ) + if database.is_closed(): database.connect() From 93d39370b6239ba58560dc49e4087f7e3f171206 Mon Sep 17 00:00:00 2001 From: Ben Clouser Date: Thu, 30 Jan 2025 13:23:38 -0500 Subject: [PATCH 3/3] =?UTF-8?q?update=20docs=20to=20be=20more=20clear=20re?= =?UTF-8?q?garding=20audio=20support=20and=20go2rtc=20requi=E2=80=A6=20(#1?= =?UTF-8?q?6232)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update docs to be more clear regarding audio support and go2rtc requirement Signed-off-by: Ben Clouser * Update docs/docs/troubleshooting/faqs.md * Update docs/docs/troubleshooting/faqs.md * Update docs/docs/troubleshooting/faqs.md * Clarify title * Cleanup --------- Signed-off-by: Ben Clouser Co-authored-by: Nicolas Mowen --- docs/docs/guides/configuring_go2rtc.md | 2 +- docs/docs/troubleshooting/faqs.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/docs/guides/configuring_go2rtc.md b/docs/docs/guides/configuring_go2rtc.md index 8667ead77..1a61fd0c5 100644 --- a/docs/docs/guides/configuring_go2rtc.md +++ b/docs/docs/guides/configuring_go2rtc.md @@ -7,7 +7,7 @@ title: Configuring go2rtc Use of the bundled go2rtc is optional. You can still configure FFmpeg to connect directly to your cameras. However, adding go2rtc to your configuration is required for the following features: -- WebRTC or MSE for live viewing with higher resolutions and frame rates than the jsmpeg stream which is limited to the detect stream +- WebRTC or MSE for live viewing with audio, higher resolutions and frame rates than the jsmpeg stream which is limited to the detect stream and does not support audio - Live stream support for cameras in Home Assistant Integration - RTSP relay for use with other consumers to reduce the number of connections to your camera streams diff --git a/docs/docs/troubleshooting/faqs.md b/docs/docs/troubleshooting/faqs.md index 889db3370..1af1508e4 100644 --- a/docs/docs/troubleshooting/faqs.md +++ b/docs/docs/troubleshooting/faqs.md @@ -17,6 +17,10 @@ ffmpeg: record: preset-record-generic-audio-aac ``` +### How can I get sound in live view? + +Audio is only supported for live view when go2rtc is configured, see [the live docs](../configuration/live.md) for more information. + ### I can't view recordings in the Web UI. Ensure your cameras send h264 encoded video, or [transcode them](/configuration/restream.md).