Christopher Stanton wrote:
On Tuesday 11 November 2003 14:48, Andrew Gaffney wrote:

Christopher Stanton wrote:

RedHat Linux 9
Perl v5.8.0 built for i386-linux-thread-multi

I am trying to parse a mjpeg stream out of an html response. The http
server is using server push to push the stream of jpegs to the client. I
have written a test client and am able to receive the stream but am
having trouble figuring out what Perl libraries I need to use to separate
and save the individual jpegs as actual jpegs and not MIME encoded data.

The Content Type is "multipart/x-mixed-replace; boundary=--myboundary".
"--myboundry" is the flag used to delimit the individual data fields.

This is a stream of JPEGs so, the server will continue streaming as long
as the connection is open. I am using the Net::HTTP library since I have
to parse as it arrives rather than wait for the whole page to be
downloaded (since it can't be).

The stream's format:
#------------------------------------------------------------------------
--------- HTTP/1.0 200 OK
Connection: Close
Server: Camd
Content-Type: multipart/x-mixed-replace; boundary=--myboundary

--myboundary
Content-Type: image/jpeg

<SOME JPEG IMAGE>

--myboundary
Content-Type: image/jpeg

<SOME JPEG IMAGE>

--myboundary
Content-Type: image/jpeg

<SOME JPEG IMAGE>

--myboundary
.
.
.
#------------------------------------------------------------------------
---------

I am able to break all of the pieces out of the original stream and am
currently just saving them to a file:
chunk-1.mime
#------------------------------------------------------------------------
---------

Content-Type: image/jpeg

<SOME JPEG IMAGE>

#------------------------------------------------------------------------
---------

Can anyone point me in the direction of the libraries or tools I need to
use to export the encoded <SOME JPEG IMAGE> to a raw JPEG so I can save
it to a file?

Can't you just strip out "Content-Type: image/jpeg\n\n"?


I was under the impression that the image was mime encoded. The chunk is being striped down to:
#------------------------------------------------------------------------


Content-Type: image/jpeg^M
^M
<SOME JPEG IMAGE>^M
^M
#------------------------------------------------------------------------

^M => \r\n

I have tried stripping the leading "\n", "Content-Type: image/jpeg\r\n", "\r\n" line, "\r\n" after the image data, and the trailing "\r\n" line but the resulting file does not seem to be a valid jpeg image.

This looks promising.


http://www.perldoc.com/perl5.6/lib/MIME/Base64.html

--
Andrew Gaffney


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to