[ACCEPTED]-HttpWebResponse with MJPEG and multipart/x-mixed-replace; boundary=--myboundary response content type from security camera not working-mjpeg

Accepted answer
Score: 17

Well, if you want your client to see the 27 mjpeg stream, you need to send the whole 26 http response. HTTP client like browser 25 or media player like VLC need a mjpeg stream 24 that looks like :

HTTP/1.1 200 OK
Content-Type: multipart/x-mixed-replace; boundary=myboundary

--myboundary
Content-Type: image/jpeg
Content-length: 12345

[image 1 encoded jpeg data]


--myboundary
Content-Type: image/jpeg
Content-length: 45678

[image 2 encoded jpeg data]

...

NOTE: As Ergousha said 23 in an answer, you must have an empty line 22 after the Content-length field.

By the 21 way, why not redirect your client directly 20 to the mjpeg stream ?

You can use http://ipcam/mjpg/video.mjpg AXIS IP 19 cameras for example.

If you just need the 18 image through HTTP, you have to set the 17 correct header and the MIME content-type 16 image/jpeg. To decode the image, you have 15 to get the byte data and you will get jpeg 14 encoding. Then you will have to decode jpeg 13 to get an image in a specific format (something 12 like yuv420p I think). I've check on my 11 ip camera, and its stream is not base64 10 encoded I think.

Precise your needs, I will 9 try to help more.

my2c

EDIT:

Well, I suppose 8 you do something like :

client    : connect to proxy, 
            get example.com/camera1.mjpg,
            while not the end
                recv


yourproxy : wait connection
            connect to camera,
            get 10.0.0.123/camera1.mjpg
            while not the end
                recv buffer
                copy buffer
                send buffer to client

That to say that 7 you must send the correct header to your 6 client. To be sure use a tool like wireshark 5 to spy on the packet and be sure that after 4 your client has issued a HTTP GET you send 3 to him the correct MJPEG stream (like the 2 one I describe at the beginning of my post 1 ...)

m2c

Score: 7

Good explaination about how mjpeg stream 4 looks like. I would like to add a tip that; there 3 are always 2 new line character before the 2 actual data. If you make it one line, it 1 doesnt work.

        string header =
            "--myboundary\r\n" +
            "Content-Type:image/jpeg\r\n" +
            "Content-Length:" + length.ToString() + "\r\n\r\n";
Score: 1

What is the encoding of the image data? Is 4 it Base64?

Basically you will have to parse 3 out the image data from the response, Base64 2 decode it into bytes, and then send the 1 image to the client.

More Related questions