Search code examples
c++copencvffmpegmjpeg

Capturing video from a MJPEG stream using C++


I would like to capture a MJPEG stream using C++. Which options do I have? I have tried OpenCV with FFMPEG support but icvCreateFileCapture_FFMPEG_p is always returning null (after a few seconds of timeout). May I program a HTTP client by myself?

Regards,


Solution

  • M-JPEG is easy to capture. You send one HTTP request to the server and read back infinite response in multipart/x-mixed-replace format (Content-Type). Then you split it into frames, which are self-contained JPEG files... Subheaders might or moight not contain additional information such as timestamps.

    You might find this relevant and useful as well: How to parse MJPEG HTTP Stream within C++?