mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Fix restream
This commit is contained in:
parent
65b9e12c94
commit
7ff2dae9d5
@ -518,7 +518,7 @@ class RtmpConfig(FrigateBaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class RestreamConfig(FrigateBaseModel):
|
class RestreamConfig(FrigateBaseModel):
|
||||||
enabled: bool = Field(default=True, title="go2rtc restreaming enabled.")
|
enabled: bool = Field(default=True, title="Restreaming enabled.")
|
||||||
|
|
||||||
|
|
||||||
class CameraLiveSourceEnum(str, Enum):
|
class CameraLiveSourceEnum(str, Enum):
|
||||||
@ -555,6 +555,9 @@ class CameraConfig(FrigateBaseModel):
|
|||||||
rtmp: RtmpConfig = Field(
|
rtmp: RtmpConfig = Field(
|
||||||
default_factory=RtmpConfig, title="RTMP restreaming configuration."
|
default_factory=RtmpConfig, title="RTMP restreaming configuration."
|
||||||
)
|
)
|
||||||
|
restream: RestreamConfig = Field(
|
||||||
|
default_factory=RestreamConfig, title="Restreaming configuration."
|
||||||
|
)
|
||||||
live: CameraLiveConfig = Field(
|
live: CameraLiveConfig = Field(
|
||||||
default_factory=CameraLiveConfig, title="Live playback settings."
|
default_factory=CameraLiveConfig, title="Live playback settings."
|
||||||
)
|
)
|
||||||
@ -593,7 +596,7 @@ class CameraConfig(FrigateBaseModel):
|
|||||||
|
|
||||||
# add roles to the input if there is only one
|
# add roles to the input if there is only one
|
||||||
if len(config["ffmpeg"]["inputs"]) == 1:
|
if len(config["ffmpeg"]["inputs"]) == 1:
|
||||||
config["ffmpeg"]["inputs"][0]["roles"] = ["record", "rtmp", "detect"]
|
config["ffmpeg"]["inputs"][0]["roles"] = ["record", "rtmp", "detect", "restream"]
|
||||||
|
|
||||||
super().__init__(**config)
|
super().__init__(**config)
|
||||||
|
|
||||||
@ -780,6 +783,9 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
rtmp: RtmpConfig = Field(
|
rtmp: RtmpConfig = Field(
|
||||||
default_factory=RtmpConfig, title="Global RTMP restreaming configuration."
|
default_factory=RtmpConfig, title="Global RTMP restreaming configuration."
|
||||||
)
|
)
|
||||||
|
restream: RestreamConfig = Field(
|
||||||
|
default_factory=RestreamConfig, title="Global restream configuration."
|
||||||
|
)
|
||||||
birdseye: BirdseyeConfig = Field(
|
birdseye: BirdseyeConfig = Field(
|
||||||
default_factory=BirdseyeConfig, title="Birdseye configuration."
|
default_factory=BirdseyeConfig, title="Birdseye configuration."
|
||||||
)
|
)
|
||||||
@ -905,6 +911,11 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
f"Camera {name} has rtmp enabled, but rtmp is not assigned to an input."
|
f"Camera {name} has rtmp enabled, but rtmp is not assigned to an input."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if camera_config.restream.enabled and not "restream" in assigned_roles:
|
||||||
|
raise ValueError(
|
||||||
|
f"Camera {name} has restream enabled, but restream is not assigned to an input."
|
||||||
|
)
|
||||||
|
|
||||||
# backwards compatibility for retain_days
|
# backwards compatibility for retain_days
|
||||||
if not camera_config.record.retain_days is None:
|
if not camera_config.record.retain_days is None:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
"""Controls go2rtc restream."""
|
"""Controls go2rtc restream."""
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
import requests
|
import requests
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RestreamApi:
|
class RestreamApi:
|
||||||
"""Control go2rtc relay API."""
|
"""Control go2rtc relay API."""
|
||||||
@ -18,10 +21,13 @@ class RestreamApi:
|
|||||||
self.relays: dict[str, str] = {}
|
self.relays: dict[str, str] = {}
|
||||||
|
|
||||||
for cam_name, camera in self.config.cameras.items():
|
for cam_name, camera in self.config.cameras.items():
|
||||||
|
if not camera.restream.enabled:
|
||||||
|
continue
|
||||||
|
|
||||||
for input in camera.ffmpeg.inputs:
|
for input in camera.ffmpeg.inputs:
|
||||||
if "restream" in input.roles:
|
if "restream" in input.roles:
|
||||||
self.relays[cam_name] = input.path
|
self.relays[cam_name] = input.path
|
||||||
|
|
||||||
for name, path in self.relays.items():
|
for name, path in self.relays.items():
|
||||||
params = {"src": urllib.parse.quote_plus(path), "name": name}
|
params = {"src": path, "name": name}
|
||||||
requests.put("http://localhost:1984/api/streams", params=params)
|
requests.put("http://127.0.0.1:1984/api/streams", params=params)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user