Stream images from the webcam every minute with GNU / Linux

Published by TheJoe on

Estimated reading time: 2 minutes


This article was published more than a year ago, there may have been developments.
Please take this into account.

Recently I was asked how he could do to organize a stream webcam that may control the Weather Conditions of a given area. The images of the stream must then be placed on a dedicated page of a site. Unfortunately, (or fortunately) I had to run into a big problem that at first seemed insurmountable: la webcam is locally attached, the server that hosts the site è remote.

This small detail was going to make me give up, when I remembered the existence of “Curlftpfs” (where there we have already discussed) to mount the remote FTP seen by the system as if it were a local. A real godsend.

The rest was easy. The software used is “Curlftpfs“, “Crontab“, “Streamer“. For simplicity, I organized the stream so that the image was overwritten by the new one every minute. In this way save resources the server, though not be able to keep a historical record movements in front of the webcam. I repeat that it is a webcam placed for meteorological purposes, surely this procedure is not useful for the remote control.

Below I list the most important passages.

The three programs exist in repositories of major distributions, each uses its package manager to install.


First you need to test the’effectiveness of “Streamer“. Run the command:

streamer-o / home / user / images / image.jpeg

and we check that the directory “/home/user/images/” both the file was created “image.jpeg“. If all goes well the program has created its first photo.

Look here:  Weather with Google API and PHP


At this point we montare l’FTP remoto with “Curlftpfs“:

curlftpfs -o user="user:pwd" / mnt / /

If everything runs smoothly going in the directory “/mnt / /” we should see the files on the server (there is obviously a slight delay in response, remember that we are always operating in remote).

At this point suggest, to order more than anything else, of create a directory local and a remote call “webcam“.


Here comes into play “Crontab“. It must do load “take a picture” and move in the directory “/mnt / /every minute. Open the file “/etc / crontab“:

[user@localhost:~]$ sudo nano / etc / crontab

and add the following lines after the last command you have entered in the file:

* *   * * *   joe     streamer -o /home/user/Immagini/webcam/w_image.jpeg
* *   * * *   joe     cp /home/user/Immagini/webcam/w_image.jpeg /mnt/

The asterisks at the beginning of the line are very important, in practice they say in “Cron” to start the program specified every minute.

We pretty much finished. We can do testing the operation of the procedure (just wait a minute) making sure that the image is actually loaded, and include it in the page.

Council also set a refresh automatico every minute on the landing page of photos. In this way the beholder stream will not have to recharge every time the page. To refresh in php include the following lines just after the tag “<html>”:

header("Refresh: 60;");

And this is a screenshot of the result, a powder’ Spartan but functional:


I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.


TheJoe · 4 January 2012 at 12:02 PM

Everything depends on the level of access you have to the remote server, libraries and programs installed.

Meanwhile, try to tell me how you configure your network. Images are “taken” via webcam from your local PC if I understand it, will then be saved to a local directory and then transferred to the remote server (what you see by typing “http://*.*.*.*:445/snapshot.cgi”.

I understand it, or the ip you type is your local (or the global one that refers to your pc)?

Last thing: I assume that on the computer that “snaps” the photo has been installed in any linux distribution.

Claudio · 4 January 2012 at 11:16 AM

Hello I have two simple webcam and I should do the same thing only I can do it just the web side can you tell me how I can get the same result??

Let me explain

the cam i can see from http://*.*.*.*:445/snapshot.cgi that returns the’ I should add this picture to date now and logo.
And’ can do the web side in the sense that the cam is installed and accessible via an IP the site is hosted on a remote server that is fished in the details of http://*.*.*.*:445/snapshot.cgi

Thank you very much


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.