From aba2a689b4be354953bdf88093c4b323bccc9ce5 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Tue, 6 Jan 2026 21:36:13 -0300 Subject: [PATCH] client: add MJPEG quality control --- client/src/input/camera.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/input/camera.rs b/client/src/input/camera.rs index 88b80a0..e779c31 100644 --- a/client/src/input/camera.rs +++ b/client/src/input/camera.rs @@ -40,6 +40,7 @@ impl CameraCapture { .ok() .map(|v| matches!(v.to_ascii_lowercase().as_str(), "mjpeg" | "mjpg" | "jpeg")) .unwrap_or(false); + let jpeg_quality = env_u32("LESAVKA_CAM_JPEG_QUALITY", 85).clamp(1, 100); let (enc, kf_prop, kf_val) = if use_mjpg_source && !output_mjpeg { ("x264enc", "key-int-max", "30") } else { @@ -49,7 +50,9 @@ impl CameraCapture { tracing::info!("📸 using MJPG source with software encode"); } if output_mjpeg { - tracing::info!("📸 outputting MJPEG frames for UVC"); + tracing::info!( + "📸 outputting MJPEG frames for UVC (quality={jpeg_quality})" + ); } else { tracing::info!("📸 using encoder element: {enc}"); } @@ -94,7 +97,7 @@ impl CameraCapture { if use_mjpg_source { format!( "v4l2src device={dev} do-timestamp=true ! \ - image/jpeg,width={width},height={height} ! \ + image/jpeg,width={width},height={height},framerate={fps}/1 ! \ queue max-size-buffers=30 leaky=downstream ! \ appsink name=asink emit-signals=true max-buffers=60 drop=true" ) @@ -102,7 +105,7 @@ impl CameraCapture { format!( "v4l2src device={dev} do-timestamp=true ! \ video/x-raw,width={width},height={height},framerate={fps}/1 ! \ - videoconvert ! jpegenc ! \ + videoconvert ! jpegenc quality={jpeg_quality} ! \ queue max-size-buffers=30 leaky=downstream ! \ appsink name=asink emit-signals=true max-buffers=60 drop=true" )