Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image streaming

Status
Not open for further replies.

hyrogen

Programmer
Jul 10, 2003
60
GB
Hi,

What I want to be able to do is stream an image from one php script into another. Eg. <img src=&quot;getImage.php&quot;>

In getImage.php I have:

header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=file.jpg');

$picturefilename = &quot;image1.jpg&quot;;
$picture = imagecreatefromjpeg($picturefilename);
imagejpeg($picture,&quot;&quot;,80);

But this only produces a broken image.

Any ideas?

Thanks in advance
 
I have just tested your code on my server and it works fine. Are the GD libraries loaded on your server?
 
I keep getting this error:
Warning: Cannot modify header information - headers already sent by.....

Could this be why it isnt working?

Thanks,
 
strange... the code I posted above, is the only code I have in the script
 
Just sorted it.. it was just because there was a space before I started the php <? tag. Thanks for your help.
 
I have a same issue. I have an AXIS 2100 NetCam behind my secured embedded web-server. All the ports on the web-server are closed except for SSL. Thats why I have to use php to retrieve the images and video.

I’m able to retrieve images with no problem.
Code:
<?php
header("Content-type: image/jpeg");

$display_width= "320";
$display_hight= "240";

$camimage_url="[URL unfurl="true"]http://10.1.1.2/axis-cgi/jpg/image.cgi".[/URL]
          "?resolution=".$display_width."x".$display_hight;

$image = imagecreatefromjpeg($camimage_url);
imagejpeg($image);
imagedestroy($image);
?>

The video is where I’m having problems with. The ‘cgi’ for video returns mjpg (Moving JPEG, is not mpeg). If I have the NetCam on the local network, I can view the 'mjpg.cgi' directly on Firefox. Since Firefox supports mjpg directly.

I tried the same code, using video.cgi instead of image.cgi.
Code:
<?php
header("Content-type: image/jpeg");

$display_width= "320";
$display_hight= "240";

$camimage_url="[URL unfurl="true"]http://10.1.1.2/axis-cgi/mjpg/video.cgi".[/URL]
        "?resolution=".$display_width."x".$display_hight;

$image = imagecreatefromjpeg($camimage_url);
imagejpeg($image);
imagedestroy($image);
?>
It will time out when I tied to load this page. It seems it's trying load mjpg image. I guess since is streaming video, it times out.

I’m thinking of opening a socket (fsockopen) and using that socket to retrive the streaming mjpg. I do not know how to get an image from open socket.

Let me know if you guys have any ideas. Here is the spec of the system:
[ul]
[li]233 Cyrix w/ MMX (Pentium)[/li]
[li]Linux Kernel 2.4 [/li]
[li]In-house Embedded Linux built from Redhat 7.2[/li]
[li]PHP 4.3.9[/li]
[li]Apache 1.3.26[/li]
[/ul]
 
a) PHP scripts have timeouts.
b) How would it be possible for PHP to assign streaming video data to a PHP variable?
My take on this:
The camimage_url streams data into the variable until the script times out. It never serves anything to the user.

Firefox sees the moving JPEG, but that's probably by direct request to the source. I believe the difficulty lies in the fact that images are finite chunks of data while streaming video is "streaming". I think you can't assign a stream to variable in PHP.
The only solution I see is to pass just the link to the browser and have some kind of proxy setup with the web server that allows to serve the content.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top