Selaa lähdekoodia

add config for camera live stream

Blake Blackshear 3 vuotta sitten
vanhempi
commit
762afb8f43
4 muutettua tiedostoa jossa 54 lisäystä ja 15 poistoa
  1. 17 7
      docs/docs/configuration/cameras.md
  2. 5 5
      docs/docs/configuration/index.md
  3. 29 0
      frigate/config.py
  4. 3 3
      frigate/output.py

+ 17 - 7
docs/docs/configuration/cameras.md

@@ -240,7 +240,7 @@ timestamp_style:
   # Optional: Line thickness of font (default: shown below)
   thickness: 2
   # Optional: Effect of lettering (default: shown below)
-  #           None (No effect), 
+  #           None (No effect),
   #           "solid" (solid background in inverse color of font)
   #           "shadow" (shadow for font)
   effect: None
@@ -357,9 +357,19 @@ cameras:
 
     # Optional: RTMP re-stream configuration
     rtmp:
-      # Required: Enable the live stream (default: True)
+      # Required: Enable the RTMP stream (default: True)
       enabled: True
 
+    # Optional: Live stream configuration for WebUI
+    live:
+      # Optional: Set the height of the live stream. (default: detect stream height)
+      # This must be less than or equal to the height of the detect stream. Lower resolutions
+      # reduce bandwidth required for viewing the live stream. Width is computed to match known aspect ratio.
+      height: 720
+      # Optional: Set the encode quality of the live stream (default: shown below)
+      # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
+      quality: 8
+
     # Optional: Configuration for the jpg snapshots written to the clips directory for each event
     snapshots:
       # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
@@ -430,16 +440,16 @@ cameras:
     format: "%m/%d/%Y %H:%M:%S"
     # Optional: Color of font
     color:
-        # All Required when color is specified (default: shown below)
-        red: 255
-        green: 255
-        blue: 255
+      # All Required when color is specified (default: shown below)
+      red: 255
+      green: 255
+      blue: 255
     # Optional: Scale factor for font (default: shown below)
     scale: 1.0
     # Optional: Line thickness of font (default: shown below)
     thickness: 2
     # Optional: Effect of lettering (default: shown below)
-    #           None (No effect), 
+    #           None (No effect),
     #           "solid" (solid background in inverse color of font)
     #           "shadow" (shadow for font)
     effect: None

+ 5 - 5
docs/docs/configuration/index.md

@@ -167,14 +167,14 @@ A dynamic combined camera view of all tracked cameras. This is optimized for min
 
 ```yaml
 birdseye:
-  # Optional: Enable birdseye view
+  # Optional: Enable birdseye view (default: shown below)
   enabled: True
-  # Optional: Width of the output resolution
+  # Optional: Width of the output resolution (default: shown below)
   width: 1280
-  # Optional: Height of the output resolution
+  # Optional: Height of the output resolution (default: shown below)
   height: 720
-  # Optional: Encoding quality of the mpeg1 feed. 1 is the highest quality, and 31 is the lowest.
-  # Lower quality feeds utilize less CPU resources.
+  # Optional: Encoding quality of the mpeg1 feed (default: shown below)
+  # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
   quality: 8
   # Optional: Mode of the view. Available options are: objects, motion, and continuous
   #   objects - cameras are included if they have had a tracked object within the last 30 seconds

+ 29 - 0
frigate/config.py

@@ -649,6 +649,10 @@ CAMERAS_SCHEMA = vol.Schema(
                 vol.Optional("rtmp", default={}): {
                     vol.Required("enabled", default=True): bool,
                 },
+                vol.Optional("live", default={}): {
+                    "height": int,
+                    vol.Optional("quality", default=8): vol.Range(min=1, max=31),
+                },
                 vol.Optional("snapshots", default={}): {
                     vol.Optional("enabled", default=False): bool,
                     vol.Optional("clean_copy", default=True): bool,
@@ -827,6 +831,27 @@ class CameraRtmpConfig:
         return dataclasses.asdict(self)
 
 
+@dataclasses.dataclass
+class CameraLiveConfig:
+    height: int
+    width: int
+    quality: int
+
+    @classmethod
+    def build(cls, config, camera_height, camera_width) -> CameraRtmpConfig:
+        if "height" in config and config["height"] <= camera_height:
+            height = config["height"]
+            width = int(height * (camera_width / camera_height))
+        else:
+            height = camera_height
+            width = camera_width
+
+        return CameraLiveConfig(height, width, config["quality"])
+
+    def to_dict(self) -> Dict[str, Any]:
+        return dataclasses.asdict(self)
+
+
 @dataclasses.dataclass(frozen=True)
 class CameraConfig:
     name: str
@@ -839,6 +864,7 @@ class CameraConfig:
     clips: CameraClipsConfig
     record: RecordConfig
     rtmp: CameraRtmpConfig
+    live: CameraLiveConfig
     snapshots: CameraSnapshotsConfig
     mqtt: CameraMqttConfig
     objects: ObjectConfig
@@ -886,6 +912,9 @@ class CameraConfig:
             clips=CameraClipsConfig.build(config["clips"], global_config),
             record=RecordConfig.build(config["record"], global_config["record"]),
             rtmp=CameraRtmpConfig.build(config["rtmp"]),
+            live=CameraLiveConfig.build(
+                config["live"], config["height"], config["width"]
+            ),
             snapshots=CameraSnapshotsConfig.build(config["snapshots"], global_config),
             mqtt=CameraMqttConfig.build(config["mqtt"]),
             objects=ObjectConfig.build(

+ 3 - 3
frigate/output.py

@@ -346,9 +346,9 @@ def output_frames(config: FrigateConfig, video_output_queue):
         converters[camera] = FFMpegConverter(
             cam_config.frame_shape[1],
             cam_config.frame_shape[0],
-            cam_config.frame_shape[1],
-            cam_config.frame_shape[0],
-            8,
+            cam_config.live.width,
+            cam_config.live.height,
+            cam_config.live.quality,
         )
         broadcasters[camera] = BroadcastThread(
             camera, converters[camera], websocket_server