Forum Moderators: coopster

Message Too Old, No Replies

Script to recognize a webcam being turned on

and send a graphic to the homepage as visual notification

         

Don_Hoagie

4:13 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



I have a site where the owner is going to be turning on her webcam at random days/times... she wants a "webcam" button to blink or something on the page whenever she is webcasting, so visitors know to go to the webcam page for a live cast. My thinking is that i need a script that will recognize when a webcast has begun, and then have a 2-minute meta refresh tag on the homepage so that if the script sees that the webcast has come on, it will send a new graphic to the page to notify visitors.

So that's my second problem... my first problem is that I don't know crap about PHP or Perl... So reply as you like, whether it's with "cant be done", or "here's a script", or "I can do that for you but it will cost you"...

Frequent

4:22 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



Don,

Any particular reason she can't simply login and ftp a "Live" graphic of some sort over the standard graphic when she's about to go live?

I mean, does it really have to be triggered just by turning on the web cam?

I have no idea... ok, I have a dirty little guess ;)...as to what type of site she may have... so I don't know if there is some physical limitation that prevents sitting in front of the keyboard for a minute or two.

Freq---

Don_Hoagie

5:53 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



That would be a wonderfully simple and effective solution, wouldn't it?

I think your dirty little guess is on the right track, my friend... and so we must consider two things:

A) We can't afford to "kill the buzz" by making her sit down at her PC and login to FTP, grab the graphic, blahblahblah...

B) She's no pinball wizard when it comes to PCs... my guess is she would have to call me for assistance every time she tried to log in to ftp.

That's my reasoning for the server script. I suppose I could take steps to make ftp quicker/easier for her by doing a desktop shortcut to FTP, having the password be stored, and keeping two versions of the graphic on the desktop as well... but I'm confident that even if she could manage to upload the "webcam on" pic, she'd never remember to replace it with the "webcam off" one.

BTW, thanks for the reply Freq... I posted this question in the Multimedia Graphics forum and all I saw were tumbleweeds going across my screen.

Tapolyai

5:59 pm on Dec 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about a small script that checks the latest captured image date/time stamp?

If it is within a preset range (say, 10 minutes of now) then the video is live, otherwise, not.

If using streaming video (real, MS, etc.) then you will need to look at cache files' or similar files' date/time stamp instead.

Don_Hoagie

6:36 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



ah yes... I suppose that's what I've been needing all along, though I hadn't thought to say it that way. Helps to remember how a webcam works.

So... a script that detects a file's timestamp and presents a new image on the page if the timestamp is within such-and-such increment from *right now*.

Any script like that lying around here or on the web? Again i'm PHP/Perl illiterate, so I probably wouldn't know this script if it smacked me in the face.

Thanks for your help

LeChuck

7:15 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



Here ya go:

<?php
$checktime_seconds=30;
$file_info=stat("/path/to/naughty.gif");
$now=date("U");
$last_modified=$file_info["mtime"];
$difference=$now-$last_modified;

if ($difference<$checktime_seconds) {
echo "<img src=live.gif>";
} else {
echo "<img src=offline.gif>";
}
?>

Merry christmas :)

Don_Hoagie

7:51 pm on Dec 23, 2005 (gmt 0)

10+ Year Member



Alrighty... I shall give this a try.

Nice touch on the filename there!

Thanks

jatar_k

9:31 pm on Dec 23, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the other option would be to just have a button she could push when the cam is on and then it could update the "status" to live

wherever the image is shown it could check the status and display the proper image