client: add MJPEG quality control

This commit is contained in:
Brad Stein 2026-01-06 21:36:13 -03:00
parent 6295720b96
commit aba2a689b4

View File

@ -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"
)