OpenWrt webcam

Install in OpenWrt:
//Go to: services/mpg-streamer
//Set it to: enabled
//That will be all
//Optional: Setup security and other parameters

A still image will be available on:
The stream will be available on:

//If you wanna go further and send a still image directly from the router to some site:

//download it with:

curl -o /www/webcam/images/image.jpg
//upload it to your server with:
curl -F "upimage=@/www/webcam/images/image.jpg"

//to get the code executed each x seconds, set a cron job, or run a command like this:

while true; do date ; curl -o /www/webcam/images/image.jpg ; curl -F "upimage=@/www/webcam/images/image.jpg" ; sleep 10; done

The server PHP code to save the images:

$source = $_FILES["upimage"]["tmp_name"];
$destination = "image.jpg";
echo move_uploaded_file($source, $destination) ? "OK" : "ERROR";

//To see the image you go to url below
//Refresh to get a new one

//Or you can add a simple html/javascript code that does the trick for you:

function refreshIt(element) {
setTimeout(function() {
element.src = element.src.split('?')[0] + '?' + new Date().getTime();
}, 10000); // refresh every 10 seg

<img=”” src=”/image.jpg” name=”myCam” onload=”refreshIt(this)”>



This entry was posted in Linux and tagged , . Bookmark the permalink.

Comments are closed.