Using PHP to proxy access to streaming source

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colin McKinnon

    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.
  • Simon Stienen

    #2
    Re: Using PHP to proxy access to streaming source

    Colin McKinnon <Colin McKinnon <colin.deleteth is@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_conten ts() 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_conten ts('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 = ImageCreateFrom JPEG('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 = ImageCreateTrue Color($w, $h);
    ImageCopyResamp led($im, $dest, 0, 0, 0, 0, $w, $h, $ow, $oh);
    ImageJPEG($im,$ path.$w.'.jpeg' ,80);
    ImageDestroy($i m);
    }

    ?>

    --
    Simon Stienen <http://dangerouscat.ne t> <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

    Comment

    Working...