How to parse MJPEG HTTP Stream within C++?

馋奶兔 提交于 2019-11-29 14:15:55

For HTTP download, you can use Libcurl library.

AFAIK MJPEG format is not a standardized format. Its actual byte format vary by implementations. But basically just concatenation of jpeg file with delimiters. If you look at bytes with a hex editor you could easily distinguish each jpeg file.

For example, ffmpeg's mjpeg output is structured like below:

0xff 0xd8 // start of jpeg
{ ... }   // jpeg body
0xff 0xd9 // end of jpeg
...
0xff 0xd8 // start of jpeg
{ ... }   // jpeg body
0xff 0xd9 // end of jpeg
...
Federico Ramos

In this page:

http://thistleshrub.net/www/index.php?controller=posts&action=show&id=2012-05-13DisplayingStreamedMJPEGinJava.txt

Parse a MJPEG Stream with Java, I implemented this with flawlessly results in Java.

If you try to use with C++ you find some things missed: socket conection and render canvas, libcurl seems to be a good option to http request, but still missing the canvas, you can use something like GLUT or Qt.

I read in some forums that OpenCV can read input stream of type MJPEG Streamer, but seems they need to be the recent version of OpenCV (compile OpenCV from scratch it's hard).

I hope this help.

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