mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-04 10:15:22 +03:00
Migrate birdseye stream definition to S6
This commit is contained in:
parent
c5dd20ae67
commit
6d025f5eaf
@ -5,8 +5,13 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.insert(0, "/opt/frigate/frigate/ffmpeg_presets.py")
|
||||||
|
|
||||||
|
|
||||||
BTBN_PATH = "/usr/lib/btbn-ffmpeg"
|
BTBN_PATH = "/usr/lib/btbn-ffmpeg"
|
||||||
|
BIRDSEYE_PIPE = "/tmp/cache/birdseye"
|
||||||
FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE_")}
|
FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE_")}
|
||||||
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
|
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
|
||||||
|
|
||||||
@ -34,7 +39,9 @@ elif go2rtc_config["log"].get("format") is None:
|
|||||||
if not go2rtc_config.get("webrtc", {}).get("candidates", []):
|
if not go2rtc_config.get("webrtc", {}).get("candidates", []):
|
||||||
default_candidates = []
|
default_candidates = []
|
||||||
# use internal candidate if it was discovered when running through the add-on
|
# use internal candidate if it was discovered when running through the add-on
|
||||||
internal_candidate = os.environ.get("FRIGATE_GO2RTC_WEBRTC_CANDIDATE_INTERNAL", None)
|
internal_candidate = os.environ.get(
|
||||||
|
"FRIGATE_GO2RTC_WEBRTC_CANDIDATE_INTERNAL", None
|
||||||
|
)
|
||||||
if internal_candidate is not None:
|
if internal_candidate is not None:
|
||||||
default_candidates.append(internal_candidate)
|
default_candidates.append(internal_candidate)
|
||||||
# should set default stun server so webrtc can work
|
# should set default stun server so webrtc can work
|
||||||
@ -42,8 +49,11 @@ if not go2rtc_config.get("webrtc", {}).get("candidates", []):
|
|||||||
|
|
||||||
go2rtc_config["webrtc"] = {"candidates": default_candidates}
|
go2rtc_config["webrtc"] = {"candidates": default_candidates}
|
||||||
else:
|
else:
|
||||||
print("[INFO] Not injecting WebRTC candidates into go2rtc config as it has been set manually", file=sys.stderr)
|
print(
|
||||||
|
"[INFO] Not injecting WebRTC candidates into go2rtc config as it has been set manually",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
|
||||||
# sets default RTSP response to be equivalent to ?video=h264,h265&audio=aac
|
# sets default RTSP response to be equivalent to ?video=h264,h265&audio=aac
|
||||||
# this means user does not need to specify audio codec when using restream
|
# this means user does not need to specify audio codec when using restream
|
||||||
# as source for frigate and the integration supports HLS playback
|
# as source for frigate and the integration supports HLS playback
|
||||||
@ -62,14 +72,29 @@ if not os.path.exists(BTBN_PATH):
|
|||||||
go2rtc_config["ffmpeg"][
|
go2rtc_config["ffmpeg"][
|
||||||
"rtsp"
|
"rtsp"
|
||||||
] = "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}"
|
] = "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}"
|
||||||
|
|
||||||
for name in go2rtc_config.get("streams", {}):
|
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):
|
||||||
go2rtc_config["streams"][name] = go2rtc_config["streams"][name].format(**FRIGATE_ENV_VARS)
|
go2rtc_config["streams"][name] = go2rtc_config["streams"][name].format(
|
||||||
|
**FRIGATE_ENV_VARS
|
||||||
|
)
|
||||||
elif isinstance(stream, list):
|
elif isinstance(stream, list):
|
||||||
for i, stream in enumerate(stream):
|
for i, stream in enumerate(stream):
|
||||||
go2rtc_config["streams"][name][i] = stream.format(**FRIGATE_ENV_VARS)
|
go2rtc_config["streams"][name][i] = stream.format(**FRIGATE_ENV_VARS)
|
||||||
|
|
||||||
|
# add birdseye restream stream if enabled
|
||||||
|
if config.get("birdseye", {}).get("restream", False):
|
||||||
|
birdseye = config.get("birdseye")
|
||||||
|
|
||||||
|
input = f"-f rawvideo -pix_fmt yuv420p -video_size {birdseye.get('width', 1280)}x{birdseye.get('height', 720)} -r 10 -i {BIRDSEYE_PIPE}"
|
||||||
|
ffmpeg_cmd = f"exec:{parse_preset_hardware_acceleration_encode(config.get('ffmpeg', {}).get('hwaccel_args'), input, '-rtsp_transport tcp -f rtsp {output}')}"
|
||||||
|
|
||||||
|
if go2rtc_config.get("streams"):
|
||||||
|
go2rtc_config["streams"]["birdseye"] = ffmpeg_cmd
|
||||||
|
else:
|
||||||
|
go2rtc_config["streams"] = {"birdseye": ffmpeg_cmd}
|
||||||
|
|
||||||
|
|
||||||
print(json.dumps(go2rtc_config))
|
print(json.dumps(go2rtc_config))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user