Broadcasting an image to a webpage [SOLVED]
Broadcasting an image to a webpage [SOLVED]
This has been asked before, but I could never find a good answer anywhere on the forum.
I have a few cameras an in addition to motion detect/record mode, I would also like to periodically ftp the image (say every 1 minute) to a server regardless of motion.
I currently have a windows program that does this, but I want to go away from it because it crashes often (windows, not so much the program) and uses lots of resources. I use the image to put it on a simple web page so I can get to it from anywhere (like from my phone.)
One of the cameras can do this on its own (I have a glitch, but that's another post), but the other two can't.
I've got the ZM up and running (ubuntu 9.10, ZM 1.24.x) using the /video.cgi function of each camera (they are IP based).
I have a few cameras an in addition to motion detect/record mode, I would also like to periodically ftp the image (say every 1 minute) to a server regardless of motion.
I currently have a windows program that does this, but I want to go away from it because it crashes often (windows, not so much the program) and uses lots of resources. I use the image to put it on a simple web page so I can get to it from anywhere (like from my phone.)
One of the cameras can do this on its own (I have a glitch, but that's another post), but the other two can't.
I've got the ZM up and running (ubuntu 9.10, ZM 1.24.x) using the /video.cgi function of each camera (they are IP based).
Last edited by gazoo on Sat Jan 02, 2010 1:16 am, edited 1 time in total.
what if on the server that needs the image set up a cron job to wget the image from the zm server
http://serverip/zm/cgi-bin/nph-zms?mode ... uffer=1000
http://serverip/zm/cgi-bin/nph-zms?mode ... uffer=1000
That sounds like a great idea. It's a home ISP account, and I'm not sure of it's PHP capabilities. Although, I have no idea how to that on the server side and don't even know if it's a PHP issue. It would stand to reason that they have some basic server side capabilities, but you never know - they could have done without..
I still think it might be easier to do it from my machine. I don't know how to automate or script ftp uploads though. If it were a file manipulation (cp, move, etc.) I could do it, the FTP is what is throwing me off..
I still think it might be easier to do it from my machine. I don't know how to automate or script ftp uploads though. If it were a file manipulation (cp, move, etc.) I could do it, the FTP is what is throwing me off..
I just found a simple bash script for FTP'ing stuff..real easy, should have just looked before I leaped. Now how do I pull a JPEG image off my monitors at any given time..that wget command? Will I be getting off of ZM or some raw part of the cameras? Will it have the timestamps?
So I figured I'll run CRON every minute on that script and the script will FTP my web server, pull an image off each camera, and PUT the JPEG into the directory.
So I figured I'll run CRON every minute on that script and the script will FTP my web server, pull an image off each camera, and PUT the JPEG into the directory.
ok take a look at http://www.adminschoice.com/docs/crontab.htm#Commands
and the comand you want to run is
wget http://serverip/zm/cgi-bin/nph-zms?mode ... uffer=1000 -O /savelocation
and the comand you want to run is
wget http://serverip/zm/cgi-bin/nph-zms?mode ... uffer=1000 -O /savelocation
So this wget command will save the it locally?kingofkya wrote:ok take a look at http://www.adminschoice.com/docs/crontab.htm#Commands
and the comand you want to run is
wget http://serverip/zm/cgi-bin/nph-zms?mode ... uffer=1000 -O /savelocation
I was trying to save a jpeg on the zoneminder computer, and then ftp it over to another location..If I'm reading your response correctly, you are trying to save it off at the webserver, right?
Ok I played around with this command: http://192.168.1.235/cgi-bin/nph-zms?mo ... &monitor=1
I put this into a browser and I got a single JPG image. However, when I do it with wget I get unusable stuff, NOT an image. How do I get this saved off in a script using wget for example?
What gives? And it isn't renaming the file with the -O filename
I put this into a browser and I got a single JPG image. However, when I do it with wget I get unusable stuff, NOT an image. How do I get this saved off in a script using wget for example?
What gives? And it isn't renaming the file with the -O filename
Ok, I figured this out, mostly. I really wish this board was more interactive, but maybe there's just not a lot of people out there who need help on ZM.
Anyhow, hopefully this will help someone out in the future.
This is the command to get a single picture downloaded:
THE QUOTES WAS WHAT WAS MISSING! Damn quotes..
Now comes the cool part. I haven't done this yet, but I'm pretty sure it will work.
You have to write a script to pull down the stuff, and then FTP it. You set this script up to run on a CRONTAB every number of minutes/hours/whatever you want. Here's an EXAMPLE, I haven't done it yet so I don't know if this exact thing will work:
I hope this works. It will be a while before I get a chance to vet this out. Also, this has NO error handling so maybe that must be taken care of too. This will pretty much suffice for me though..
This will pretty much upload a current image on an ftp server to be displayed on an HTML site every x time interval (crontab must be set to call the script though.)
Anyhow, hopefully this will help someone out in the future.
This is the command to get a single picture downloaded:
Replace monitor=1 with whatever number monitor.wget -O picture.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"
THE QUOTES WAS WHAT WAS MISSING! Damn quotes..
Now comes the cool part. I haven't done this yet, but I'm pretty sure it will work.
You have to write a script to pull down the stuff, and then FTP it. You set this script up to run on a CRONTAB every number of minutes/hours/whatever you want. Here's an EXAMPLE, I haven't done it yet so I don't know if this exact thing will work:
Got the FTP info from here: http://www.linuxforums.org/forum/linux- ... cript.html#!/bin/bash
#change directory to where you want to store your image
cd ~/imagestorage
#get image
wget -O picture.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"
#store FTP server variables here
HOST='www.*.com'
USER='*************'
PASSWD='*********'
#start FTP
ftp -n -v $HOST << EOT
ascii
user $USER $PASSWD
prompt
cd /{wherever you need to change to}
bin
put picture.jpg
bye
EOT
I hope this works. It will be a while before I get a chance to vet this out. Also, this has NO error handling so maybe that must be taken care of too. This will pretty much suffice for me though..
This will pretty much upload a current image on an ftp server to be displayed on an HTML site every x time interval (crontab must be set to call the script though.)
- henriquejf
- Posts: 77
- Joined: Tue Feb 10, 2009 12:01 pm
- Location: Brazil