Is there a simple way to stream a not public IP Camera into website with PHP?
I'm trying to embed a non public rtsp camera into a website without thirth part software or pluguins and capable for all browsers and devices, but I'm not able to do it.
I found a workaround that works but it is not elegant. It consists in take continuosly a snapshot of the camera from jpeg url camera acces and copy to a file with a runing php script on server:
<?php
while (True) {
copy('http://192.168.x.x/snap.jpg?JpegSize=M&JpegCam=1', './webcam/frame.jpg'); // local URL from my camera to obtain jpg snapshot
usleep (150000); // microseconds!!
}
?>
Then, on client browser, this served page contain a javascript function that is responsible to refresh this snapshot and produce a webcam efect:
<script>
function reloadWebcam() {
var now = new Date();
document.images['webcam'].src = './webcam/frame.jpg?' + now.getTime();
}
</script>
...
<img name="webcam" align="center" width="640" height="480" scrolling="no">
<script>
setInterval('reloadWebcam()', 300); // 300 miliseconds
</script>
So, it works but I'm looking for:
a) an easy also solution but more elegant than this.
b) an improvement to this solution with a way to avoid subprocess of copy on server and/or avoid javascript refresh in client browser.