📝🔧 - Make RTMP config global

Fixes #1671
This commit is contained in:
drinfernoo 2021-08-31 10:17:38 -07:00
parent d74021af47
commit c4a2014097
4 changed files with 98 additions and 4 deletions

View File

@ -215,6 +215,12 @@ Frigate can re-stream your video feed as a RTMP feed for other applications such
Some video feeds are not compatible with RTMP. If you are experiencing issues, check to make sure your camera feed is h264 with AAC audio. If your camera doesn't support a compatible format for RTMP, you can use the ffmpeg args to re-encode it on the fly at the expense of increased CPU utilization. Some video feeds are not compatible with RTMP. If you are experiencing issues, check to make sure your camera feed is h264 with AAC audio. If your camera doesn't support a compatible format for RTMP, you can use the ffmpeg args to re-encode it on the fly at the expense of increased CPU utilization.
```yaml
rtmp:
# Optional: Enable the RTMP stream (default: True)
enabled: True
```
## Timestamp style configuration ## Timestamp style configuration
For the debug view and snapshots it is possible to embed a timestamp in the feed. In some instances the default position obstructs important space, visibility or contrast is too low because of color or the datetime format does not match ones desire. For the debug view and snapshots it is possible to embed a timestamp in the feed. In some instances the default position obstructs important space, visibility or contrast is too low because of color or the datetime format does not match ones desire.
@ -357,7 +363,7 @@ cameras:
# Optional: RTMP re-stream configuration # Optional: RTMP re-stream configuration
rtmp: rtmp:
# Required: Enable the RTMP stream (default: True) # Optional: Enable the RTMP stream (default: True)
enabled: True enabled: True
# Optional: Live stream configuration for WebUI # Optional: Live stream configuration for WebUI

View File

@ -233,3 +233,13 @@ birdseye:
# continuous - all cameras are included always # continuous - all cameras are included always
mode: objects mode: objects
``` ```
### `rtmp`
Can be overridden at the camera level. See the [cameras configuration page](cameras.md) for more information about RTMP streaming.
```yaml
rtmp:
# Optional: Enable the RTMP stream (default: True)
enabled: True
```

View File

@ -432,7 +432,7 @@ class CameraMqttConfig(BaseModel):
) )
class CameraRtmpConfig(BaseModel): class RtmpConfig(BaseModel):
enabled: bool = Field(default=True, title="RTMP restreaming enabled.") enabled: bool = Field(default=True, title="RTMP restreaming enabled.")
@ -454,8 +454,8 @@ class CameraConfig(BaseModel):
record: RecordConfig = Field( record: RecordConfig = Field(
default_factory=RecordConfig, title="Record configuration." default_factory=RecordConfig, title="Record configuration."
) )
rtmp: CameraRtmpConfig = Field( rtmp: RtmpConfig = Field(
default_factory=CameraRtmpConfig, title="RTMP restreaming configuration." default_factory=RtmpConfig, title="RTMP restreaming configuration."
) )
live: CameraLiveConfig = Field( live: CameraLiveConfig = Field(
default_factory=CameraLiveConfig, title="Live playback settings." default_factory=CameraLiveConfig, title="Live playback settings."
@ -656,6 +656,9 @@ class FrigateConfig(BaseModel):
snapshots: SnapshotsConfig = Field( snapshots: SnapshotsConfig = Field(
default_factory=SnapshotsConfig, title="Global snapshots configuration." default_factory=SnapshotsConfig, title="Global snapshots configuration."
) )
rtmp: RtmpConfig = Field(
default_factory=RtmpConfig, title="Global RTMP restreaming configuration."
)
birdseye: BirdseyeConfig = Field( birdseye: BirdseyeConfig = Field(
default_factory=BirdseyeConfig, title="Birdseye configuration." default_factory=BirdseyeConfig, title="Birdseye configuration."
) )
@ -687,6 +690,7 @@ class FrigateConfig(BaseModel):
include={ include={
"record": ..., "record": ...,
"snapshots": ..., "snapshots": ...,
"rtmp": ...,
"objects": ..., "objects": ...,
"motion": ..., "motion": ...,
"detect": ..., "detect": ...,

View File

@ -883,6 +883,80 @@ class TestConfig(unittest.TestCase):
assert runtime_config.cameras["back"].snapshots.bounding_box == False assert runtime_config.cameras["back"].snapshots.bounding_box == False
assert runtime_config.cameras["back"].snapshots.height == 150 assert runtime_config.cameras["back"].snapshots.height == 150
assert runtime_config.cameras["back"].snapshots.enabled assert runtime_config.cameras["back"].snapshots.enabled
def test_global_rtmp(self):
config = {
"mqtt": {"host": "mqtt"},
"rtmp": {"enabled": True},
"cameras": {
"back": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp://10.0.0.1:554/video",
"roles": ["detect"],
},
]
},
}
},
}
frigate_config = FrigateConfig(**config)
assert config == frigate_config.dict(exclude_unset=True)
runtime_config = frigate_config.runtime_config
assert runtime_config.cameras["back"].rtmp.enabled
def test_default_snapshots(self):
config = {
"mqtt": {"host": "mqtt"},
"cameras": {
"back": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp://10.0.0.1:554/video",
"roles": ["detect"],
},
]
}
}
},
}
frigate_config = FrigateConfig(**config)
assert config == frigate_config.dict(exclude_unset=True)
runtime_config = frigate_config.runtime_config
assert runtime_config.cameras["back"].rtmp.enabled
def test_global_snapshots_merge(self):
config = {
"mqtt": {"host": "mqtt"},
"rtmp": {"enabled": False},
"cameras": {
"back": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp://10.0.0.1:554/video",
"roles": ["detect"],
},
]
},
"rtmp": {
"enabled": True,
},
}
},
}
frigate_config = FrigateConfig(**config)
assert config == frigate_config.dict(exclude_unset=True)
runtime_config = frigate_config.runtime_config
assert runtime_config.cameras["back"].rtmp.enabled
if __name__ == "__main__": if __name__ == "__main__":