Home > Archive > PHP Programming > March 2007 > ipcam to stream?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| CptDondo 2007-03-26, 6:59 pm |
| I have an airlink101 ipcam. It "streams" jpeg images to a web browser.
Basically, the camera sends a never-ending http page, and continually
retransmits a jpeg image.
This sort of works, but eventually the browser tries to save the file.
It's also impossible to embed in a page.
What I really want is to grab that stream at the web server level using
something like php, and create a stream similar to a webcam so that I
can show embedded live video on the page.
I have never done anything like this, though, and my google searches
have not revealed anything useful - mostly how-tos on creating
proprietary streams using desktop tools.
I need something that can automagically create a stream that a browser
can understand.
I've tried mplayer/mencoder and motion, but neither will produce a
stream....
The web server is running linux (debian etch), apache2, and php5.
I would appreciate any pointers or guidance.
Thanks,
--Yan
| |
| Erwin Moller 2007-03-27, 7:00 pm |
| CptDondo wrote:
> I have an airlink101 ipcam. It "streams" jpeg images to a web browser.
>
> Basically, the camera sends a never-ending http page, and continually
> retransmits a jpeg image.
Hi,
Really? A never ending http page that refreshes the image all the time?
Do they use some meta-refresh header for that?
They would be better off using JavaScript, and simply replace the image all
the time (better performance).
But I think you can just look at the URL of the image, and my bet is that
that same image changes all the time. Right?
If so: what you need in PHP to get the stream of images is simply
rerequesting the same image all the time and store them on HD or something.
So you need something simple as:
*****************************
// Look up the path in the sourcecode of you page that displays the jpg
$imageSourcePath = "http://localhost/path/to/your/cam/image.jpg";
$saveDir = "/home/Yan/webcam/";
$nrOfPicsToCapture = 1000;
for ($counter=0;$counter<$nrOfPicsToCapture;$counter++){
// make sure nobody caches
$theImg = $imageSourcePath."?rand="+microtime();
// get new picture
$content = file_get_contents($theImg);
// safe it in a file
$fileName = $saveDir."image".$counter.".jpg";
file_put_contents($fileName,$content);
}
*****************************
(not tested of course)
How you make a movie out of the seperate jpg files, I don't know, but I am
sure some software out there can help you with that (try sourceforge eg).
Hope that helps.
Regards,
Erwin Moller
>
> This sort of works, but eventually the browser tries to save the file.
> It's also impossible to embed in a page.
>
> What I really want is to grab that stream at the web server level using
> something like php, and create a stream similar to a webcam so that I
> can show embedded live video on the page.
>
> I have never done anything like this, though, and my google searches
> have not revealed anything useful - mostly how-tos on creating
> proprietary streams using desktop tools.
>
> I need something that can automagically create a stream that a browser
> can understand.
>
> I've tried mplayer/mencoder and motion, but neither will produce a
> stream....
>
> The web server is running linux (debian etch), apache2, and php5.
>
> I would appreciate any pointers or guidance.
>
> Thanks,
>
> --Yan
| |
| CptDondo 2007-03-27, 7:00 pm |
| Erwin Moller wrote:
> CptDondo wrote:
>
>
> Hi,
>
> Really? A never ending http page that refreshes the image all the time?
> Do they use some meta-refresh header for that?
>
> They would be better off using JavaScript, and simply replace the image all
> the time (better performance).
>
> But I think you can just look at the URL of the image, and my bet is that
> that same image changes all the time. Right?
>
> If so: what you need in PHP to get the stream of images is simply
> rerequesting the same image all the time and store them on HD or something.
>
> So you need something simple as:
>
> *****************************
> // Look up the path in the sourcecode of you page that displays the jpg
> $imageSourcePath = "http://localhost/path/to/your/cam/image.jpg";
> $saveDir = "/home/Yan/webcam/";
> $nrOfPicsToCapture = 1000;
>
> for ($counter=0;$counter<$nrOfPicsToCapture;$counter++){
> // make sure nobody caches
> $theImg = $imageSourcePath."?rand="+microtime();
> // get new picture
> $content = file_get_contents($theImg);
> // safe it in a file
> $fileName = $saveDir."image".$counter.".jpg";
> file_put_contents($fileName,$content);
> }
> *****************************
> (not tested of course)
>
> How you make a movie out of the seperate jpg files, I don't know, but I am
> sure some software out there can help you with that (try sourceforge eg).
>
> Hope that helps.
>
> Regards,
> Erwin Moller
>
That was my first cut.... But it takes about 1-2 seconds to refresh,
and the camera frame rate is 10 fps. Here's the description of the
process the camera uses (from
<http://msdn.microsoft.com/coding4fu...rticleid=912407>
):
MotionJPEG over HTTP uses the Content-Type header
"multipart/x-mixed-replace" along with a configurable boundary. This
means that the stream is made up of Multiple Parts (hence multipart) and
each new frame should replace the previous frame (hence
x-mixed-replace). This particular camera sends an HTTP Header like this:
Content-Type: multipart/x-mixed-replace;boundary=--video boundary--
So.. I'm kind of stuck on how to deal with that. I want to take that
stream and display it an an embedded object.
--Yan
| |
| Erwin Moller 2007-03-28, 7:00 pm |
| CptDondo wrote:
> Erwin Moller wrote:
>
> That was my first cut.... But it takes about 1-2 seconds to refresh,
> and the camera frame rate is 10 fps. Here's the description of the
> process the camera uses (from
>
<http://msdn.microsoft.com/coding4fu...rticleid=912407>
> ):
>
> MotionJPEG over HTTP uses the Content-Type header
> "multipart/x-mixed-replace" along with a configurable boundary. This
> means that the stream is made up of Multiple Parts (hence multipart) and
> each new frame should replace the previous frame (hence
> x-mixed-replace). This particular camera sends an HTTP Header like this:
>
> Content-Type: multipart/x-mixed-replace;boundary=--video boundary--
>
> So.. I'm kind of stuck on how to deal with that. I want to take that
> stream and display it an an embedded object.
Yes, I see.
Sorry, I have no clue how to proceed either. I never did that before. :-/
Maybe dig into RFC that describe this type of stream?
Good luck
Regards,
Erwin
>
> --Yan
| |
| Jerry Stuckle 2007-03-28, 7:00 pm |
| CptDondo wrote:
> I have an airlink101 ipcam. It "streams" jpeg images to a web browser.
>
> Basically, the camera sends a never-ending http page, and continually
> retransmits a jpeg image.
>
> This sort of works, but eventually the browser tries to save the file.
> It's also impossible to embed in a page.
>
> What I really want is to grab that stream at the web server level using
> something like php, and create a stream similar to a webcam so that I
> can show embedded live video on the page.
>
> I have never done anything like this, though, and my google searches
> have not revealed anything useful - mostly how-tos on creating
> proprietary streams using desktop tools.
>
> I need something that can automagically create a stream that a browser
> can understand.
>
> I've tried mplayer/mencoder and motion, but neither will produce a
> stream....
>
> The web server is running linux (debian etch), apache2, and php5.
>
> I would appreciate any pointers or guidance.
>
> Thanks,
>
> --Yan
>
Yan,
I've never tried it either, but I've seen it done. It normally requires
more than just dumping the jpeg repeatedly to the browser. HTTP is a
request/response protocol - it's not really designed to have one request
go on for long periods of time.
You could take a look at http://195.196.35.90/view/view.shtml. He's
doing the same thing I think you want to do, using some javascript. It
might give you some ideas.
Unfortunately I don't have the webmaster's email - I bookmarked this a
couple of years ago as a neat site and have since lost contact with him.
You could also try asking over on alt.www.webmasters - some of them
might have some ideas.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
|
|
|
|
|