Accessing Webcam with PHP

Hey,

Is it technically possible to access (view the current webcam) using PHP? For example I have a website that has about 23.431 visitors per week, and people are uploading their images with description onto a directory, and it’s being inserted into a MySQL-DB-Table. I’d also like to implement more features, - and the one is viewing your own webcam, taking a shot, and upload the file onto a directory, also onto my MySQL-DB. If it doesn’t work with PHP, I know it does with Perl, but since my Webspace provider does not support Perl, (cgi), I have to live with PHP.

Anyone ever deal with such implementations?

Regards and Thanks,

Phyxas

i wouldn’t think so because that would be controlling hardware. If it was possible, then I would believe it could be done with a language other than PHP even though php is a powerful language.
But, I am interested in learning if it is possible.

Good luck!

I actually know a website that has such function. http://knugle.de/?upload. And I don’t see any /cgi/ folder.

I’m pretty sure they’re using flash for that. team1504 is right, php can’t access the client’s hardware (and thank heavens for that, think about the security implications!) and thus can’t use/control the client’s webcam. If the client gives permission flash can though :slight_smile:

Ok. Good to know. Btw, that seems to be their source code:


<object width="470" height="320" type="application/x-shockwave-flash" id="recorder" name="recorder" data="http://knugle.de/functions/libs/upload/webcam.swf">
<param name="align" value="middle">
<param name="bgcolor" value="#CECBFF">
<param name="allowScriptAccess" value="always">
<param name="wmode" value="window">
<param name="swliveconnect" value="true">
<param name="allowNetworking" value="external">
<param name="flashvars" value="serverURL=rtmp://knugle.de/functions/libs/upload/stream0.6489458125154817&amp;imgURL=http://knugle.de/functions/libs/upload/serverside.php?cookie=&amp;localXML=http://knugle.de/functions/libs/upload/config.xml&amp;cookie=&amp;openw=selfnavigate">
</object>

Since I’m totally the complete noob in flash, does anyone know a bit of it? Couldn’t find anything by googling.

Yup, that’s a flash alright. Since they called in “webcam.swf” it could be anything. Maybe the wrote it themselves?

I know the webmaster of this site, and I also know that we’ve had personal problems in the past, since he decided to move on with his web “projects”, and stealing several of mine images after not working with him. He’s not the type of guy who actually knows about Flash, he mainly does mostly PHP, and only some HTML / CSS.

You don’t have to have a thorough knowledge of flash to employ it … just saying :slight_smile:

I’ve noticed - if anyone is interested in something simple, here’s a tutorial from Adobe: http://www.adobe.com/devnet/flash/articles/webcam_motion.html

PHP code runs server side.
The Web Cam is client side.

This means that you need something client side, to send the data to the server for processing.
You can use flash for this, and chances are you will need some kind of flash server (red5, macromedia/adobe media server or whatever it’s called now)

If you’re only capturing a still image you won’t need anything on the server other than php
You can capture to a bitmap within flash, then encode to a jpeg using the jpeg encoder from this library. This data can be sent to a php script which will save an image.

Thanks for the tip, EastCoast. If you’re willing, may you describe on what you actually need for running the encoder, (the JPGEncoder.as) file, which is located here?

Probably a bit too long to go over all the necessary steps, but you’d put a video oject in a movieclip, attach your webcam to it, and capture the movieclip to a bitmapData.

Then (having included the jpegencoder script) encode it to a byteArray

var myEncoder:JPGEncoder = new JPGEncoder(myQuality_integer);
myByteArray = myEncoder.encode(myBitmapData);

Then you’d send the byteArray to the server via a normal URLRequest with the byteArray as POST data, and save that data as a file.