Connecting Tech Pros Worldwide Help | Site Map

Using PHP to proxy access to streaming source

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 08:41 AM
Colin McKinnon
Guest
 
Posts: n/a
Default Using PHP to proxy access to streaming source

Hi all,

Anybody tried this? Know of any published work on the topic? More
specifically, I am have a webcam (hardware device which connects directly
to the network) which will be behind a public webserver (LAMP). The
webserver will serve up predominantly static content. I want it to mediate
access to the camera for security reasons (camera control is exposed via
HTTP, also provides different URLs for different protocols / resolutions)
to manage bandwidth more cleverly.


TIA,

C.

  #2  
Old July 17th, 2005, 08:46 AM
Simon Stienen
Guest
 
Posts: n/a
Default Re: Using PHP to proxy access to streaming source

Colin McKinnon <Colin McKinnon <colin.deletethis@andthis.mms3.com>> wrote:[color=blue]
> Anybody tried this? Know of any published work on the topic? More
> specifically, I am have a webcam (hardware device which connects directly
> to the network) which will be behind a public webserver (LAMP). The
> webserver will serve up predominantly static content. I want it to mediate
> access to the camera for security reasons (camera control is exposed via
> HTTP, also provides different URLs for different protocols / resolutions)
> to manage bandwidth more cleverly.[/color]
I hope I got this right: The webcam capture is an image, obtainable through
HTTP? If so, you could grab the image using file_get_contents() and then
open and resize it using the gd library <http://www.php.net/gd>. Either on
demand on the server or invoked as a cronjob every x minutes.
I understand "different protocols" as "HTTP, FTP, maybe some more", so you
would need the image as file(s) on the hard disk. Since you can't check for
requests to the image via FTP (as long as you don't use special software) I
would suggest using the cronjob and a command line script (untested!):
(You need PHP as binary to do so!)

<?php
set_time_limit(0); // could take some time ;)
// getting the original image
$image = file_get_contents('http://webcamserver/path/to/webcamshot.jpg');
fwrite($f = fopen('original.jpg', 'w'), $image);
fclose($f); unset($image);

// the width of the resized images
// (height will be calculated)
$resolutions = array(
400,
320,
240,
160,
80 // no comma here!
);

// opening the original image
$orig = ImageCreateFromJPEG('original.jpg');
$ow = ImageSX($orig);
$oh = ImageSY($orig);
$ratio= ((float) $oh) / ((float) $ow);
$path = 'path/to/public/images/';

foreach ($resolutions as $w) {
$h = round($ratio * $w);
$im = ImageCreateTrueColor($w, $h);
ImageCopyResampled($im, $dest, 0, 0, 0, 0, $w, $h, $ow, $oh);
ImageJPEG($im,$path.$w.'.jpeg',80);
ImageDestroy($im);
}

?>

--
Simon Stienen <http://dangerouscat.net> <http://slashlife.de>
»What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.