Update docs

This commit is contained in:
Felipe Santos 2023-01-16 23:33:06 -03:00
parent fc43109f3a
commit 43ce2bdbd9
2 changed files with 29 additions and 11 deletions

View File

@ -4,11 +4,9 @@
set -o errexit -o nounset -o pipefail set -o errexit -o nounset -o pipefail
if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then function get_ip_and_port() {
# Running as a Home Assistant add-on, infer the IP address and port
# Example: 192.168.1.10/24 # 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=$( if ip_address=$(
curl -fsSL \ curl -fsSL \
-H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \ -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \
@ -17,12 +15,13 @@ if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then
jq --exit-status --raw-output '.data.ipv4.address[0]' jq --exit-status --raw-output '.data.ipv4.address[0]'
) && [[ "${ip_address}" =~ ${ip_regex} ]]; then ) && [[ "${ip_address}" =~ ${ip_regex} ]]; then
ip_address="${BASH_REMATCH[1]}" 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 else
echo "Failed to get IP address from supervisor" >&2 echo "[WARN] Failed to get IP address from supervisor" >&2
return 0
fi fi
port_regex='^([0-9]{1,5})$' local port_regex='^([0-9]{1,5})$'
if webrtc_port=$( if webrtc_port=$(
curl -fsSL \ curl -fsSL \
-H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \ -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \
@ -31,12 +30,18 @@ if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then
jq --exit-status --raw-output '.data.network["22/tcp"]' jq --exit-status --raw-output '.data.network["22/tcp"]'
) && [[ "${webrtc_port}" =~ ${port_regex} ]]; then ) && [[ "${webrtc_port}" =~ ${port_regex} ]]; then
webrtc_port="${BASH_REMATCH[1]}" 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 else
echo "Failed to get WebRTC port from supervisor" >&2 echo "[WARN] Failed to get WebRTC port from supervisor" >&2
return 0
fi fi
export FRIGATE_GO2RTC_WEBRTC_CANDIDATE_INTERNAL="${ip_address}:${webrtc_port}" 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 fi
python3 /usr/local/go2rtc/create_config.py > /dev/shm/go2rtc.yaml python3 /usr/local/go2rtc/create_config.py > /dev/shm/go2rtc.yaml

View File

@ -76,11 +76,11 @@ cameras:
WebRTC works by creating a TCP or UDP connection on port `8555`. However, it requires additional configuration: 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 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: 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: go2rtc:
streams: streams:
test_cam: ... test_cam: ...
@ -90,6 +90,19 @@ WebRTC works by creating a TCP or UDP connection on port `8555`. However, it req
- stun:8555 - 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 :::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: 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: