What format is this JPEG stream from my cheap Chinese IP webcam?

左心房为你撑大大i 提交于 2020-01-03 18:37:59

问题


I've got a cheap Chinese IP webcam that has a web interface showing live video. The video appears to be a sequence of jpeg images fed into the browser. If I point wget at the URL http://my-ip-camera/video.cgi I receive a big chunk of streamed data in the following format:

--ipcamera
Content-Type: image/jpeg
Content-Length: 46056

JFIF header data
... lots of data ...

this pattern repeats for every "frame".

Is this some "standard" streaming format I can play/transcode with something, or is it some made up collection of JPEGs forced into my browser that just renders them as quick as it can?

I tried using VLC but it couldn't process the URL.

The software in my IP cam is pretty terrible, so I want to capture this stream and process it on my Linux machine instead. Is there some collection of ffmpeg/mplayer tools I can use to do this?


回答1:


Looks like MIME multipart with "ipcamera" as boundary.

http://en.wikipedia.org/wiki/MIME#Multipart_messages

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="frontier"

This is a message with multiple parts in MIME format.
--frontier
Content-Type: text/plain

This is the body of the message.
--frontier
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==

Can you post the very beginning of data?

There are a lot of libraries to work with MIME multipart. I think, you should find JS library to parse MIME-multipart and pass it into dynamic DOM of browser. Or you can use perl or other scripting with MIME support and get jpegs from this stream.

UPDATE:

actually, this is the "M-JPEG over HTTP" http://en.wikipedia.org/wiki/Motion_JPEG#M-JPEG_over_HTTP

The server software mentioned above streams the sequence of JPEGs over HTTP. A special mime-type content type multipart/x-mixed-replace;boundary= informs the browser to expect several parts as answer separated by a special boundary. This boundary is defined within the MIME-type. For M-JPEG streams the JPEG data is sent to the client with a correct HTTP-header. The TCP connection is not closed as long as the client wants to receive new frames and the server wants to provide new frames. Two basic implementations of such a server are test-server "cambozola" and webcam server "MJPG-Streamer".

Here is an example of this format generation http://nakkaya.com/2011/03/23/streaming-opencv-video-over-the-network-using-mjpeg/ - it is exaclty what you have.

Here is a python client: http://code.google.com/p/python-mjpeg-over-http-client/




回答2:


Sounds like Motion JPEG, or at least some variant thereof.



来源:https://stackoverflow.com/questions/7294660/what-format-is-this-jpeg-stream-from-my-cheap-chinese-ip-webcam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!