Opencv c++ api. Videowriter accepting already encoded jpegs?


Im using videocapture with V4L backend, fourcc=mjpg and CV_CAP_PROP_CONVERT_RGB=0 to read out mjpeg frames from a camera. This results in a one dimensional array which I assume is the encoded jpeg. I do not wish to convert and show the images. I want to write them to an .avi container.
If I feed them into opencv’s videowriter (FFMPEG backend, fourcc=mjpg) it accepts the frames but the file stays empty. My guess is that it tries to encode the already encoded one dimensional frame resulting in garbage. So the problem is the videowriter configuration I think.
Can opencv read mjpeg from camera and write to file without decoding and encoding in the middle? I know that gstreamer can do it on command line but I want to get in between the read and write of each frame in my application. It will run on an embedded device so redundant conversions need to be avoided.

Kind regards and thanks in advance,


OpenCV is not a media handling library. it uses such libraries and gives you functions that are purely for convenience.

please use something like ffmpeg or gstreamer.