Skip to content

Commit 0b04db8

Browse files
Lower buffer count, changed threshold for using lores stream
1 parent d1bb9a9 commit 0b04db8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/labthings_picamera2/thing.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,14 @@ def start_streaming(self, main_resolution: tuple[int, int] = (820, 616)) -> None
452452
"""
453453
Start the MJPEG stream
454454
455-
Sets the camera resolution to the video/stream resolution, and starts recording
456-
if the stream should be active.
455+
Sets the camera resolutions based on input parameters, and sets the low-res resolution to (320, 240)
456+
((320, 240) is a standard from the Pi Camera manual)
457+
458+
Create two streams, `lores_mjpeg_stream` for autofocus at low-res resolution, and `mjpeg_stream` for preview.
459+
This is the `main_resolution` if this is less than (1280, 960), or the low-res resolution if above.
460+
This allows for high resolution capture without streaming high resolution video.
461+
462+
main_resolution: the resolution for the main configuration. Defaults to (820, 616), 1/4 sensor size
457463
"""
458464
with self.picamera() as picam:
459465
# TODO: Filip: can we use the lores output to keep preview stream going
@@ -468,9 +474,11 @@ def start_streaming(self, main_resolution: tuple[int, int] = (820, 616)) -> None
468474
sensor=self.thing_settings.get("sensor_mode", None),
469475
controls=self.persistent_controls,
470476
)
477+
# Reducing buffer_count from video standard 6 to 4 to save memory
478+
stream_config["buffer_count"] = 4
471479
picam.configure(stream_config)
472480
logging.info("Starting picamera MJPEG stream...")
473-
stream_name='lores' if main_resolution != (820, 616) else 'main'
481+
stream_name='lores' if main_resolution[0] > 1280 else 'main'
474482
picam.start_recording(
475483
MJPEGEncoder(self.mjpeg_bitrate),
476484
PicameraStreamOutput(

0 commit comments

Comments
 (0)