Exit with better error message when substitution is not correct

This commit is contained in:
Nick Mowen 2023-09-02 08:57:52 -06:00
parent 374fe77250
commit d66a305996
2 changed files with 35 additions and 26 deletions

View File

@ -100,12 +100,21 @@ for name in go2rtc_config.get("streams", {}):
stream = go2rtc_config["streams"][name] stream = go2rtc_config["streams"][name]
if isinstance(stream, str): if isinstance(stream, str):
try:
go2rtc_config["streams"][name] = go2rtc_config["streams"][name].format( go2rtc_config["streams"][name] = go2rtc_config["streams"][name].format(
**FRIGATE_ENV_VARS **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): elif isinstance(stream, list):
for i, stream in enumerate(stream): for i, stream in enumerate(stream):
try:
go2rtc_config["streams"][name][i] = stream.format(**FRIGATE_ENV_VARS) 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 # add birdseye restream stream if enabled
if config.get("birdseye", {}).get("restream", False): if config.get("birdseye", {}).get("restream", False):

View File

@ -53,31 +53,31 @@ One connection is made to the camera. One for the restream, `detect` and `record
```yaml ```yaml
go2rtc: go2rtc:
streams: 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 - 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) - "ffmpeg:name_your_rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)
http_cam: # <- for other streams 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 - 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: cameras:
rtsp_cam: name_your_rtsp_cam:
ffmpeg: ffmpeg:
output_args: output_args:
record: preset-record-generic-audio-copy record: preset-record-generic-audio-copy
inputs: 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 input_args: preset-rtsp-restream
roles: roles:
- record - record
- detect - detect
- audio # <- only necessary if audio detection is enabled - audio # <- only necessary if audio detection is enabled
http_cam: name_your_http_cam:
ffmpeg: ffmpeg:
output_args: output_args:
record: preset-record-generic-audio-copy record: preset-record-generic-audio-copy
inputs: 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 input_args: preset-rtsp-restream
roles: roles:
- record - record
@ -92,44 +92,44 @@ Two connections are made to the camera. One for the sub stream, one for the rest
```yaml ```yaml
go2rtc: go2rtc:
streams: 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 - 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 - "ffmpeg:name_your_rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to opus
rtsp_cam_sub: 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 - 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 - "ffmpeg:name_your_rtsp_cam_sub#audio=opus" # <- copy of the stream which transcodes audio to opus
http_cam: 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 - 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 - "ffmpeg:name_your_http_cam#audio=opus" # <- copy of the stream which transcodes audio to opus
http_cam_sub: 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 - 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: cameras:
rtsp_cam: name_your_rtsp_cam:
ffmpeg: ffmpeg:
output_args: output_args:
record: preset-record-generic-audio-copy record: preset-record-generic-audio-copy
inputs: 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 input_args: preset-rtsp-restream
roles: roles:
- record - 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 input_args: preset-rtsp-restream
roles: roles:
- audio # <- only necessary if audio detection is enabled - audio # <- only necessary if audio detection is enabled
- detect - detect
http_cam: name_your_http_cam:
ffmpeg: ffmpeg:
output_args: output_args:
record: preset-record-generic-audio-copy record: preset-record-generic-audio-copy
inputs: 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 input_args: preset-rtsp-restream
roles: roles:
- record - 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 input_args: preset-rtsp-restream
roles: roles:
- audio # <- only necessary if audio detection is enabled - audio # <- only necessary if audio detection is enabled