From 43ce2bdbd952dda5572e877e88f09bc6f1119d75 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Mon, 16 Jan 2023 23:33:06 -0300 Subject: [PATCH] Update docs --- .../rootfs/etc/cont-init.d/prepare-go2rtc.sh | 23 +++++++++++-------- docs/docs/configuration/live.md | 17 ++++++++++++-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/docker/rootfs/etc/cont-init.d/prepare-go2rtc.sh b/docker/rootfs/etc/cont-init.d/prepare-go2rtc.sh index ab415ead5..a390d59b6 100755 --- a/docker/rootfs/etc/cont-init.d/prepare-go2rtc.sh +++ b/docker/rootfs/etc/cont-init.d/prepare-go2rtc.sh @@ -4,11 +4,9 @@ set -o errexit -o nounset -o pipefail -if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then - # Running as a Home Assistant add-on, infer the IP address and port - +function get_ip_and_port() { # Example: 192.168.1.10/24 - ip_regex='^([0-9]{1,3}\.{3}[0-9]{1,3})/[0-9]{1,2}$' + local ip_regex='^([0-9]{1,3}\.{3}[0-9]{1,3})/[0-9]{1,2}$' if ip_address=$( curl -fsSL \ -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \ @@ -17,12 +15,13 @@ if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then jq --exit-status --raw-output '.data.ipv4.address[0]' ) && [[ "${ip_address}" =~ ${ip_regex} ]]; then ip_address="${BASH_REMATCH[1]}" - echo "Got IP address from supervisor: ${ip_address}" >&2 + echo "[INFO] Got IP address from supervisor: ${ip_address}" >&2 else - echo "Failed to get IP address from supervisor" >&2 + echo "[WARN] Failed to get IP address from supervisor" >&2 + return 0 fi - port_regex='^([0-9]{1,5})$' + local port_regex='^([0-9]{1,5})$' if webrtc_port=$( curl -fsSL \ -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \ @@ -31,12 +30,18 @@ if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then jq --exit-status --raw-output '.data.network["22/tcp"]' ) && [[ "${webrtc_port}" =~ ${port_regex} ]]; then webrtc_port="${BASH_REMATCH[1]}" - echo "Got WebRTC port from supervisor: ${ip_address}" >&2 + echo "[INFO] Got WebRTC port from supervisor: ${ip_address}" >&2 else - echo "Failed to get WebRTC port from supervisor" >&2 + echo "[WARN] Failed to get WebRTC port from supervisor" >&2 + return 0 fi export FRIGATE_GO2RTC_WEBRTC_CANDIDATE_INTERNAL="${ip_address}:${webrtc_port}" +} + +if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then + # Running as a Home Assistant add-on, infer the IP address and port + get_ip_and_port fi python3 /usr/local/go2rtc/create_config.py > /dev/shm/go2rtc.yaml diff --git a/docs/docs/configuration/live.md b/docs/docs/configuration/live.md index f453a508f..5a317539e 100644 --- a/docs/docs/configuration/live.md +++ b/docs/docs/configuration/live.md @@ -76,11 +76,11 @@ cameras: WebRTC works by creating a TCP or UDP connection on port `8555`. However, it requires additional configuration: - For external access, over the internet, setup your router to forward port `8555` to port `8555` on the Frigate device, for both TCP and UDP. -- For internal/local access, you will need to use a custom go2rtc config: +- For internal/local access, and you are running through docker, you will need to use a custom go2rtc config: 1. Add your internal IP to the list of `candidates`. Here is an example, assuming that `192.168.1.10` is the local IP of the device running Frigate: - ```yaml + ```yaml title="/config/frigate.yaml" go2rtc: streams: test_cam: ... @@ -90,6 +90,19 @@ WebRTC works by creating a TCP or UDP connection on port `8555`. However, it req - stun:8555 ``` +:::tip + +This extra configuration is probably not required if you installed Frigate through the Home Assistant add-on, as Frigate uses the Supervisor's API to get both the local IP of the device and the port that go2rtc's WebRTC interface has been forwarded to. + +However, defining the candidates manually will not hurt even if you are using the Home Assistant add-on. You should do this if the Frigate add-on fails to detect this information. If it's the case, you will see some warnings like the below in the add-on logs page during the initialization: + +```log +[WARN] Failed to get IP address from supervisor +[WARN] Failed to get WebRTC port from supervisor +``` + +::: + :::note If you are having difficulties getting WebRTC to work and you are running Frigate with docker, you may want to try changing the container network mode: