client: allow webcam resolution overrides
This commit is contained in:
parent
368319af63
commit
49fdd9c3de
@ -7,6 +7,13 @@ use gstreamer as gst;
|
||||
use gstreamer_app as gst_app;
|
||||
use lesavka_common::lesavka::VideoPacket;
|
||||
|
||||
fn env_u32(name: &str, default: u32) -> u32 {
|
||||
std::env::var(name)
|
||||
.ok()
|
||||
.and_then(|v| v.parse::<u32>().ok())
|
||||
.unwrap_or(default)
|
||||
}
|
||||
|
||||
pub struct CameraCapture {
|
||||
#[allow(dead_code)] // kept alive to hold PLAYING state
|
||||
pipeline: gst::Pipeline,
|
||||
@ -28,23 +35,30 @@ impl CameraCapture {
|
||||
// (NVIDIA → VA-API → software x264).
|
||||
let (enc, kf_prop, kf_val) = Self::choose_encoder();
|
||||
tracing::info!("📸 using encoder element: {enc}");
|
||||
let width = env_u32("LESAVKA_CAM_WIDTH", 1280);
|
||||
let height = env_u32("LESAVKA_CAM_HEIGHT", 720);
|
||||
let fps = env_u32("LESAVKA_CAM_FPS", 30).max(1);
|
||||
let have_nvvidconv = gst::ElementFactory::find("nvvidconv").is_some();
|
||||
let (src_caps, preenc) = match enc {
|
||||
// ───────────────────────────────────────────────────────────────────
|
||||
// Jetson (has nvvidconv) Desktop (falls back to videoconvert)
|
||||
// ───────────────────────────────────────────────────────────────────
|
||||
"nvh264enc" if have_nvvidconv =>
|
||||
("video/x-raw(memory:NVMM),format=NV12,width=1280,height=720",
|
||||
"nvvidconv !"),
|
||||
(format!(
|
||||
"video/x-raw(memory:NVMM),format=NV12,width={width},height={height},framerate={fps}/1"
|
||||
), "nvvidconv !"),
|
||||
"nvh264enc" /* else */ =>
|
||||
("video/x-raw,format=NV12,width=1280,height=720",
|
||||
"videoconvert !"),
|
||||
(format!(
|
||||
"video/x-raw,format=NV12,width={width},height={height},framerate={fps}/1"
|
||||
), "videoconvert !"),
|
||||
"vaapih264enc" =>
|
||||
("video/x-raw,format=NV12,width=1280,height=720",
|
||||
"videoconvert !"),
|
||||
(format!(
|
||||
"video/x-raw,format=NV12,width={width},height={height},framerate={fps}/1"
|
||||
), "videoconvert !"),
|
||||
_ =>
|
||||
("video/x-raw,width=1280,height=720",
|
||||
"videoconvert !"),
|
||||
(format!(
|
||||
"video/x-raw,width={width},height={height},framerate={fps}/1"
|
||||
), "videoconvert !"),
|
||||
};
|
||||
|
||||
// let desc = format!(
|
||||
@ -65,7 +79,7 @@ impl CameraCapture {
|
||||
queue max-size-buffers=30 leaky=downstream ! \
|
||||
appsink name=asink emit-signals=true max-buffers=60 drop=true"
|
||||
);
|
||||
tracing::info!(%enc, ?desc, "📸 using encoder element");
|
||||
tracing::info!(%enc, width, height, fps, ?desc, "📸 using encoder element");
|
||||
|
||||
let pipeline: gst::Pipeline = gst::parse::launch(&desc)
|
||||
.context("gst parse_launch(cam)")?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user