mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 09:45:22 +03:00
Create go2rtc config handler
This commit is contained in:
parent
226b7e9efd
commit
c4564599c2
31
docker/rootfs/usr/local/go2rtc/create_config.py
Normal file
31
docker/rootfs/usr/local/go2rtc/create_config.py
Normal file
@ -0,0 +1,31 @@
|
||||
"""Creates a go2rtc config file."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import yaml
|
||||
|
||||
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
|
||||
|
||||
# Check if we can use .yaml instead of .yml
|
||||
config_file_yaml = config_file.replace(".yml", ".yaml")
|
||||
if os.path.isfile(config_file_yaml):
|
||||
config_file = config_file_yaml
|
||||
|
||||
with open(config_file) as f:
|
||||
raw_config = f.read()
|
||||
|
||||
if config_file.endswith((".yaml", ".yml")):
|
||||
config = yaml.safe_load(raw_config)
|
||||
elif config_file.endswith(".json"):
|
||||
config = json.loads(raw_config)
|
||||
|
||||
go2rtc_config: dict[str, any] = config["restream"]
|
||||
|
||||
if not go2rtc_config.get("log", {}).get("format"):
|
||||
go2rtc_config["log"] = {"format": "text"}
|
||||
|
||||
if not go2rtc_config.get("webrtc", {}).get("candidates", []):
|
||||
go2rtc_config["webrtc"] = {"candidates", ["stun:8555"]}
|
||||
|
||||
with open('/usr/local/go2rtc/bin/config.yaml', 'w') as yaml_file:
|
||||
yaml.dump(go2rtc_config, yaml_file)
|
||||
@ -1,6 +0,0 @@
|
||||
log:
|
||||
format: text
|
||||
|
||||
webrtc:
|
||||
candidates:
|
||||
- stun:8555
|
||||
Loading…
Reference in New Issue
Block a user