roel018 Posted August 21, 2009 Share Posted August 21, 2009 Hi all, I'm trying to connect to my webcam's cgi file which broadcasts a MJPEG stream. I'm trying to read it using PHP and send it to the browser (in an IMG tag, or any other usuable container). This is some info about CGI file I'm talking about: http://www.canvision.net/support/pt300-cgi/GetData.htm I found this code below which is used to access an IP camera and read the MJPEG stream, however it assumes that you target an IP address directly, but I'm using a source in the form of "http://mywebcamserver.com/GetData.cgi?Status=false" .. Which actually works when I type this in my browser's address bar - it produces a nice JPG stream.. But no luck so far with PHP. One pitfall: I have to bypass Basic Authentication protection since the cgi file is protected this way (I have the login details). I've been searching for a solution for days now. I discussed this issue with member Khaine in this thread, but we got stuck in the end. http://www.phpbuilder.com/board/show...php?t=10367689 Who can help me???? THANKS! <? // Set time limit to indefinite execution set_time_limit(0); // create TCP socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); // connect to the camera's native stream protocol IP:Port socket_connect($sock,"10.0.0.20", 65310); // handshake with the camera socket_write($sock,"START\r\n"); // ignore the handshake response socket_read($sock, 12000); // daemonize this script while (true) { // simulate 4 escape sequences "\0A" with "\r\n" - or chr(0) socket_write($sock,"\r\n\r\n\r\n\r\n"); // read the image from the stream (max 80k) print socket_read($sock, 80000); // limit to ~6 frames per second usleep(166666); } ?> Link to comment https://forums.phpfreaks.com/topic/171279-reading-web-cams-cgi-mjpeg-stream/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.