psmaaswinkel Posted January 23, 2011 Share Posted January 23, 2011 I am trying to display an image stream from my pond cam... The stream generated by my ip video server is a jpeg stream without boundaries. Causeur of this the normal mime replace isn't working. I need php to read a picture from the stream, and display the picture in the browser while reading the next picture in the background. I've got to the point that I am able to connect to the stream, read the first image, and display it in the browser as can be seen in the link below (cam is only on from 09:00 until 16:00) http://cam.xsiteit.nl/readstream_test.php From this point I need to read the second image and replace the image in the browser with the new one. This process has to continu until the browser is closed. Any help would be great! Regards, Peter Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/ Share on other sites More sharing options...
dragon_sa Posted January 23, 2011 Share Posted January 23, 2011 I assuming refreshing the page will give you the latest image so you could do something like this <meta http-equiv="refresh" content="10"> would reload the page every 10 seconds displaying the new image, not a php answer though Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163906 Share on other sites More sharing options...
psmaaswinkel Posted January 23, 2011 Author Share Posted January 23, 2011 Because I have to open a connection to the video server I can't use a page refresh. I need to process the stream without closing the connection. With a page refresh the connection has to be made for each image, which limits the refresh rate. Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163907 Share on other sites More sharing options...
PaulRyan Posted January 23, 2011 Share Posted January 23, 2011 I would recommend something along the lines of an AJAX call to the request_stream page, that will create a new image. If the new image is created we then just load it into a DIV or whatever. Should be something quite simple to accomplish, I may be able to come up with something for you, if you cannot do it yourself. Regards, PaulRyan. Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163949 Share on other sites More sharing options...
PaulRyan Posted January 23, 2011 Share Posted January 23, 2011 The following works as I have tested it, not sure if it is what you're looking for though. Just change the orginal page "readstream_test.php" so it creates the image, it does not need to output it to the browser (I think). Filename: pond_stream.php <html> <head> <title> My Pond </title> <script type="text/javascript" src="functions.js"></script> </head> <body> <div id="currentImage"> <img src="http://cam.xsiteit.nl/img-0.jpg?<?=time();?>"></div> </div> <div id="nextImage" style="display:none;"> </div> <div id="streamStatus" style="font-family:Verdana; font-size:12px; margin-top:5px; background:#CECECE; padding:5px; width:164px; border:1px solid #999;"> Showing latest image </div> </body> </html> Filename: functions.js function loadStream() { document.getElementById('streamStatus').innerHTML='Generating new image'; var xmlhttp; var thisTime = new Date(); if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { document.getElementById('nextImage').innerHTML='<img src="http://cam.xsiteit.nl/img-0.jpg?'+thisTime.getTime()+'">'; document.getElementById('streamStatus').innerHTML='Loading new image'; setTimeout("document.getElementById('currentImage').innerHTML=document.getElementById('nextImage').innerHTML; document.getElementById('streamStatus').innerHTML='Showing latest image';",1000); setTimeout("loadStream()",2000); } } xmlhttp.open('GET','http://cam.xsiteit.nl/readstream_test.php',true); xmlhttp.send(); } window.onload=loadStream; Tell me how it goes for you Regards, PaulRyan. Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163956 Share on other sites More sharing options...
psmaaswinkel Posted January 23, 2011 Author Share Posted January 23, 2011 Thanks for the help Paul! Your script auto updates the image correct. The only problem with this option is the refresh rate. Because the original script still has to connect with the video server for each image, the refresh rate is limited by this. The stream delivered by the ipsever is a continues stream of jpeg's as can be seen below (this is the raw data i need to process) http://93.125.236.139:81/snapshot.htm To be able to get a higher refresh rate, the original readstream_test.php script has to read a image, and continue to read the next image while proccessing the first image... If you need the readstream_test.php script please let me know... Regards, Peter Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163959 Share on other sites More sharing options...
PaulRyan Posted January 23, 2011 Share Posted January 23, 2011 Know how the "readstream_test.php" works would help, so the source code of that would be nice. I'm not 100% sure on how to do this other than call the url "http://93.125.236.139:81/snapshot.htm" every so often and generate the latest image. I could have a go at it, but I am not promising anything Regards, PaulRyan. Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163965 Share on other sites More sharing options...
psmaaswinkel Posted January 23, 2011 Author Share Posted January 23, 2011 @Paul, You've got a PM And of course I understand that you can't promis anything. But you're help is really appreciated! Regards, Peter Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163970 Share on other sites More sharing options...
psmaaswinkel Posted January 23, 2011 Author Share Posted January 23, 2011 Is it maybe possible with php to buffer the read while proccesing the image, and after that start from the buffer again? Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1163999 Share on other sites More sharing options...
psmaaswinkel Posted January 25, 2011 Author Share Posted January 25, 2011 Is it at all possible to output an image during the loop of a script, and resend it as long as the loop runs? Regards, Link to comment https://forums.phpfreaks.com/topic/225384-display-image-stream/#findComment-1165046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.