From 7a881225353a872a314f7b2658c2ff26af457251 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Sat, 2 Sep 2023 08:57:52 -0600 Subject: [PATCH] Exit with better error message when substitution is not correct --- .../rootfs/usr/local/go2rtc/create_config.py | 17 +++++-- docs/docs/configuration/restream.md | 44 +++++++++---------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/docker/main/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.py index aefed5f837..58c9ccdda1 100644 --- a/docker/main/rootfs/usr/local/go2rtc/create_config.py +++ b/docker/main/rootfs/usr/local/go2rtc/create_config.py @@ -100,12 +100,21 @@ stream = go2rtc_config["streams"][name] if isinstance(stream, str): - go2rtc_config["streams"][name] = go2rtc_config["streams"][name].format( - **FRIGATE_ENV_VARS - ) + try: + go2rtc_config["streams"][name] = go2rtc_config["streams"][name].format( + **FRIGATE_ENV_VARS + ) + except KeyError as e: + print("[ERROR] Invalid substitution found, see https://docs.frigate.video/configuration/restream#advanced-restream-configurations for more info.") + sys.exit(e) + elif isinstance(stream, list): for i, stream in enumerate(stream): - go2rtc_config["streams"][name][i] = stream.format(**FRIGATE_ENV_VARS) + try: + go2rtc_config["streams"][name][i] = stream.format(**FRIGATE_ENV_VARS) + except KeyError as e: + print("[ERROR] Invalid substitution found, see https://docs.frigate.video/configuration/restream#advanced-restream-configurations for more info.") + sys.exit(e) # add birdseye restream stream if enabled if config.get("birdseye", {}).get("restream", False): diff --git a/docs/docs/configuration/restream.md b/docs/docs/configuration/restream.md index 7ddcdb4e75..7a931f4759 100644 --- a/docs/docs/configuration/restream.md +++ b/docs/docs/configuration/restream.md @@ -53,31 +53,31 @@ One connection is made to the camera. One for the restream, `detect` and `record ```yaml go2rtc: streams: - rtsp_cam: # <- for RTSP streams + name_your_rtsp_cam: # <- for RTSP streams - rtsp://192.168.1.5:554/live0 # <- stream which supports video & aac audio - - "ffmpeg:rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus) - http_cam: # <- for other streams + - "ffmpeg:name_your_rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus) + name_your_http_cam: # <- for other streams - http://192.168.50.155/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=user&password=password # <- stream which supports video & aac audio - - "ffmpeg:http_cam#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus) + - "ffmpeg:name_your_http_cam#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus) cameras: - rtsp_cam: + name_your_rtsp_cam: ffmpeg: output_args: record: preset-record-generic-audio-copy inputs: - - path: rtsp://127.0.0.1:8554/rtsp_cam # <--- the name here must match the name of the camera in restream + - path: rtsp://127.0.0.1:8554/name_your_rtsp_cam # <--- the name here must match the name of the camera in restream input_args: preset-rtsp-restream roles: - record - detect - audio # <- only necessary if audio detection is enabled - http_cam: + name_your_http_cam: ffmpeg: output_args: record: preset-record-generic-audio-copy inputs: - - path: rtsp://127.0.0.1:8554/http_cam # <--- the name here must match the name of the camera in restream + - path: rtsp://127.0.0.1:8554/name_your_http_cam # <--- the name here must match the name of the camera in restream input_args: preset-rtsp-restream roles: - record @@ -92,44 +92,44 @@ Two connections are made to the camera. One for the sub stream, one for the rest ```yaml go2rtc: streams: - rtsp_cam: + name_your_rtsp_cam: - rtsp://192.168.1.5:554/live0 # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg - - "ffmpeg:rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to opus - rtsp_cam_sub: + - "ffmpeg:name_your_rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to opus + name_your_rtsp_cam_sub: - rtsp://192.168.1.5:554/substream # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg - - "ffmpeg:rtsp_cam_sub#audio=opus" # <- copy of the stream which transcodes audio to opus - http_cam: + - "ffmpeg:name_your_rtsp_cam_sub#audio=opus" # <- copy of the stream which transcodes audio to opus + name_your_http_cam: - http://192.168.50.155/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=user&password=password # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg - - "ffmpeg:http_cam#audio=opus" # <- copy of the stream which transcodes audio to opus - http_cam_sub: + - "ffmpeg:name_your_http_cam#audio=opus" # <- copy of the stream which transcodes audio to opus + name_your_http_cam_sub: - http://192.168.50.155/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=user&password=password # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg - - "ffmpeg:http_cam_sub#audio=opus" # <- copy of the stream which transcodes audio to opus + - "ffmpeg:name_your_http_cam_sub#audio=opus" # <- copy of the stream which transcodes audio to opus cameras: - rtsp_cam: + name_your_rtsp_cam: ffmpeg: output_args: record: preset-record-generic-audio-copy inputs: - - path: rtsp://127.0.0.1:8554/rtsp_cam # <--- the name here must match the name of the camera in restream + - path: rtsp://127.0.0.1:8554/name_your_rtsp_cam # <--- the name here must match the name of the camera in restream input_args: preset-rtsp-restream roles: - record - - path: rtsp://127.0.0.1:8554/rtsp_cam_sub # <--- the name here must match the name of the camera_sub in restream + - path: rtsp://127.0.0.1:8554/name_your_rtsp_cam_sub # <--- the name here must match the name of the camera_sub in restream input_args: preset-rtsp-restream roles: - audio # <- only necessary if audio detection is enabled - detect - http_cam: + name_your_http_cam: ffmpeg: output_args: record: preset-record-generic-audio-copy inputs: - - path: rtsp://127.0.0.1:8554/http_cam # <--- the name here must match the name of the camera in restream + - path: rtsp://127.0.0.1:8554/name_your_http_cam # <--- the name here must match the name of the camera in restream input_args: preset-rtsp-restream roles: - record - - path: rtsp://127.0.0.1:8554/http_cam_sub # <--- the name here must match the name of the camera_sub in restream + - path: rtsp://127.0.0.1:8554/name_your_http_cam_sub # <--- the name here must match the name of the camera_sub in restream input_args: preset-rtsp-restream roles: - audio # <- only necessary if audio detection is enabled