Mjpeg is short for Motion JPEG. Its principle is to break down the video camera filmed the video jpg into a separate data sheets sent to the client. When the client continuously display the image to form a corresponding image.
Most low-end webcams are supported MJPG agreement, the more advanced camera support H.264.
MJPG advantage is simple, the client is simple and not a mosaic situation. Disadvantage is that relatively large total bandwidth, because it is a frame by frame to transfer the image.
MJPG can be transmitted in a variety of transport protocols such as TCP / UDP, HTTP the most commonly used in the transmission. Most of the camera is using HTTP + MJPG transfer form. We will use the follow-up analysis.
A. Mjpg Analysis
-------------------------------------------------- ---------
mjpg the mime type in http is the "x-mixed-replace". but mjpg
The first is to send a GET from the client to take a special file (different cameras have different definitions)
If ipcam return 200, that the request has been received, and the boundary specified in the returned string header, which is the boundary in the context type specified in sub-attributes.
Then start sending JPG ipcam data, the first is to send the type and length.
Content-Type = image / jpeg and Content-Length with the length of the subsequent point.
When a map has been sent after the string to the end of the border.
By Original LIVECAM Motion JPEG, for example, is the process of its mjpg
Where the boundary string is ThisRandomString.
GET / xxx.jpg HTTP/1.1
HTTP/1.0 200 OK Server: Digital Video Technology PUSH1 Expires: 0 Pragma: no-cache
Content-Type: multipart / x-mixed-replace; boundary = ThisRandomString
- ThisRandomString
Content-Type: image / jpeg
Content-Length: 6280
... (Jpeg data)
- ThisRandomString
II. Mjpg-streamer of the protocol specification
-------------------------------------------------- ----------
In this monitoring project, we use the mjpg-streamer, mjpg-streamer is used to enable streaming mjpg open source project, we analyze the content of the agreement it.
The first is to send GET /? Action = stream \ n \ n
200 that join a successful server response. And to indicate a multipart / x-mixed-replace the mjpg data, the boundary string is boundarydonotcross
HTTP/1.0 200 OK
Connection: close
Server: MJPG-Streamer/0.2
Cache-Control: no-store, no-cache, must-revalidate, pre-check = 0, post-check = 0, max-age = 0
Pragma: no-cache
Expires: Mon, 3 Jan 2000 12:34:56 GMT
Content-Type: multipart / x-mixed-replace; boundary = boundarydonotcross
- Boundarydonotcross
Take over the development of data to send JPG
Content-Type: image / jpeg
Content-Length: 19454
" onmouseout="this.style.backgroundColor='#fff'"><Middle complete 19454 bytes is a JPG image>
- Boundarydonotcross
When the continuous transmission of this data, the client can display video
No comments:
Post a Comment