blakeblackshear.frigate/frigate/restream.py
Nicolas Mowen 19afb035ff
Rewrite restream (#5106)
* Tear out restream config

* Rework birdseye restream

* Create go2rtc config handler

* Fix bug

* Write start script

* Rework style

* Fix python run syntax

* Output as json instead of yaml

* Put old live config back and fix birdseye references

* Fix camera webUI

* Add frigate env var subsitutions

* Fix webui checks

* Check keys

* Remove unused prest

* Fix tests

* Update restream docs

* Update restream docs

* Update live docs

* Update camera specific recommendation

* Update more docs

* add links for the docs

Co-authored-by: Felipe Santos <felipecassiors@gmail.com>

* Update note about supported audio codecs

* Move restream to go2rtc

* Docs fixes

* Add verification of stream name

* Ensure that webUI uses camera name

* Update docs to reflect new live stream name

* Fix check

* Formatting

* Remove audio from detect

Co-authored-by: Felipe Santos <felipecassiors@gmail.com>

* Fix docs

* Don't handle env variable substitution

* Add go2rtc version

* Clarify docs

Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
2023-01-16 17:50:35 -06:00

34 lines
1.1 KiB
Python

"""Controls go2rtc restream."""
import logging
import requests
from frigate.config import FrigateConfig
from frigate.const import BIRDSEYE_PIPE
from frigate.ffmpeg_presets import (
parse_preset_hardware_acceleration_encode,
)
logger = logging.getLogger(__name__)
class RestreamApi:
"""Control go2rtc relay API."""
def __init__(self, config: FrigateConfig) -> None:
self.config: FrigateConfig = config
def add_cameras(self) -> None:
"""Add cameras to go2rtc."""
self.relays: dict[str, str] = {}
if self.config.birdseye.restream:
self.relays[
"birdseye"
] = f"exec:{parse_preset_hardware_acceleration_encode(self.config.ffmpeg.hwaccel_args, f'-f rawvideo -pix_fmt yuv420p -video_size {self.config.birdseye.width}x{self.config.birdseye.height} -r 10 -i {BIRDSEYE_PIPE}', '-rtsp_transport tcp -f rtsp {output}')}"
for name, path in self.relays.items():
params = {"src": path, "name": name}
requests.put("http://127.0.0.1:1984/api/streams", params=params)