Skip to content

Commit

Permalink
add video quality setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgineer85 committed Oct 28, 2024
1 parent 53944d3 commit 60aaea2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions node/services/backends/cameras/picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from libcamera import Transform, controls
from picamera2 import Picamera2, Preview
from picamera2.encoders import MJPEGEncoder
from picamera2.encoders import MJPEGEncoder, Quality
from picamera2.outputs import FileOutput

from ...config.models import ConfigBackendPicamera2
Expand Down Expand Up @@ -113,7 +113,9 @@ def start_stream(self):
# encoder.frame_skip_count = 2 # every nth frame to save cpu/bandwith on
# low power devices but this can cause issues with timing it seems and permanent non-synchronizity

self._picamera2.start_recording(encoder, FileOutput(self._streaming_output))
logger.info(f"stream quality {Quality[self._config.videostream_quality]=}")

self._picamera2.start_recording(encoder, FileOutput(self._streaming_output), quality=Quality[self._config.videostream_quality])
logger.info("encoding stream started")

def stop_stream(self):
Expand Down
4 changes: 4 additions & 0 deletions node/services/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class ConfigBackendPicamera2(BaseModel):
LIVEVIEW_RESOLUTION_WIDTH: int = Field(default=768)
LIVEVIEW_RESOLUTION_HEIGHT: int = Field(default=432)
original_still_quality: int = Field(default=90)
videostream_quality: Literal["VERY_LOW", "LOW", "MEDIUM", "HIGH", "VERY_HIGH"] = Field(
default="MEDIUM",
description="Lower quality results in less data to be transferred and may reduce load on devices.",
)


class GroupCameraBackend(BaseModel):
Expand Down

0 comments on commit 60aaea2

Please sign in to comment.