Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cv::VideoWriter yields unreadable video

Tags:

c++

opencv

video

I want to produce a video file out of a stream of RGB images flowing at 52fps. I found the opencv api pretty handy to use (cv::VideoWriter). The problem is that I can play the produced avi only with VLC; which plays the video but yells:

[0x28307b0] xcb_xv generic error: no available XVideo adaptor

Any other video player (on the same computer) is not able to read and play the video. While recording everything looks ok: I get information about the output, about the size of the frame, the video codec, the fps, etc...no error.

Output #0, avi, to '01-23-12_15-24-51.avi':
Stream #0.0: Video: flv, yuv420p, 500x242, q=2-31, 7744 kb/s, 90k tbn, 52tbc 

As OpenCv only supports avi as video container, the only thing I could change is the video codec, I tried (FOURCC code) FLV1, DIVX, DIV3 but none of them works correctly.

I would like to play this video with any video player on different computers. How can I make it work? is VideoWriter the right choice?

Any suggestion is very welcome.

Thanks.

like image 986
sciarp Avatar asked Nov 13 '22 11:11

sciarp


1 Answers

If you have a video source for your images, it would be a good idea to use the same codec for output:

int videoType = (int)cap.get(CV_CAP_PROP_FORMAT);

VideoWriter vout;
vout.open(videofile + "_out.avi", videoType, 30, imgSize);

Or, you can try an older, simpler FOURCC. Or a Microsoft-specific, if you want to run it only on Windows.

like image 152
Sam Avatar answered Dec 28 '22 03:12

Sam