From 3314d1db5354fb7891de040d704eadda2e097752 Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Fri, 6 Feb 2026 11:18:39 +0000 Subject: [PATCH] LIMS-2057: Allow custom resolutions for webcams --- api/config_sample.php | 7 +++++++ api/src/Page/Image.php | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api/config_sample.php b/api/config_sample.php index 6e4f7a2f0..164e4735b 100644 --- a/api/config_sample.php +++ b/api/config_sample.php @@ -356,6 +356,13 @@ # - These are show on the beamline status and active datacollection lists $webcams = array('i03' => array('1.2.3.4'), ); + # Allow overriding of default resolution (480x270) and fps (5) or any other URL parameters + $webcamParameters = array( + '1.2.3.4' => array( + 'resolution' => '480x360', + 'fps' => 1, + ), + ); # On-axis viewing (OAV) camera addresses # - Shown on beamline status page for staff, for remote debugging diff --git a/api/src/Page/Image.php b/api/src/Page/Image.php index 37729fdc5..84b5bebe3 100644 --- a/api/src/Page/Image.php +++ b/api/src/Page/Image.php @@ -309,7 +309,7 @@ function _forward_oav() { # ------------------------------------------------------------------------ # Forward beamline webcams function _forward_webcam() { - global $webcams; + global $webcams, $webcamParameters; if (!array_key_exists($this->arg('bl'), $webcams)) return; @@ -327,9 +327,18 @@ function _forward_webcam() { while (@ob_end_clean()); header('content-type: multipart/x-mixed-replace; boundary=myboundary'); + + $params = array( + 'fps' => 5, + 'resolution' => '480x270', + ); + if (isset($webcamParameters[$img])) { + $params = array_merge($params, $webcamParameters[$img]); + } + $url = 'http://' . $img . '/axis-cgi/mjpg/video.cgi?' . http_build_query($params); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, 'http://'.$img.'/axis-cgi/mjpg/video.cgi?fps=5&resolution=CIF&resolution=480x270'); + curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); $im = curl_exec($ch);