PHP代理在网站中显示axis摄像头

PHP代理在网站中显示axis摄像头,php,webcam,Php,Webcam,我有一个axiscam,最多有20个并发连接。 我想在我的网站中嵌入MJPG流。到目前为止,我得到了以下php脚本: header('content-type: multipart/x-mixed-replace; boundary=--myboundary'); while (@ob_end_clean()); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://WEBCAM/axis-cgi/mjpg/video.cgi?

我有一个axiscam,最多有20个并发连接。 我想在我的网站中嵌入MJPG流。到目前为止,我得到了以下php脚本:

header('content-type: multipart/x-mixed-replace; boundary=--myboundary');
while (@ob_end_clean());
$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://WEBCAM/axis-cgi/mjpg/video.cgi?resolution=320x240');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY | CURLAUTH_ANYSAFE );
    $im = curl_exec($ch);
echo $im;
curl_close($ch);
?>
以及相应的HTML:

<script type="text/javascript">
$(function() {
    var timeout = 2000;
    var refreshInterval = setInterval(function() {
        var random = Math.floor(Math.random() * Math.pow(2, 31));
        $('img#camera').attr('src', '/webcam/webcam.php?r=' + random); //send a random var to avoid cache
    }, timeout);
 })
 </script>
 </head>
<body>
<img height="240" width="320" id="camera" src="">
</body>
</html>

$(函数(){
var超时=2000;
var refreshInterval=setInterval(函数(){
var random=Math.floor(Math.random()*Math.pow(2,31));
$('img#camera').attr('src','/webcam/webcam.php?r='+random);//发送随机变量以避免缓存
},超时);
})
我想我对curl一般缺乏了解,但我的猜测是,一旦请求页面,运行curl的web服务器就会向网络摄像头发出请求。如果我在多台计算机上的多个浏览器中打开HTML,我会得到一个超时。所以我的目标是只打开一个网络摄像头连接,然后从我的网络服务器上获取图像。
现在的问题是,不知何故,我仍然超出了此解决方案的最大连接数。

我认为您应该创建一个php脚本,该脚本将访问摄像头并在服务器上保存/覆盖文件,稍后创建cron作业,比如说每5秒访问一次该脚本。 当您这样做时,请使用此保存的文件在服务器上显示它,因为您的脚本此时正在为每个用户创建与相机的新连接