Cv :: VideoWriter gives unreadable video

I want to create a video file from a stream of RGB images moving at 52 frames per second. I found the opencv api very usable (cv :: VideoWriter). The problem is that I can only play with produced avi 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) cannot read and play video. When recording, everything looks fine: I get information about the output, frame size, video codec, fps, etc ... without errors.

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 

Since OpenCv only supports AVI as video content, the only thing I can change is the video codec, I tried (FOURCC code) FLV1, DIVX, DIV3, but none of them work correctly.

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

Any suggestion is very welcome.

Thank.

+5
source share
1 answer

If you have a video source for your images, it would be nice 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 the older, simpler FOURCC. Or Microsoft, if you want to run it only on Windows.

+1
source

All Articles