cv::VideoWriter 产生不可读的视频

发布于 2024-12-28 16:54:22 字数 620 浏览 1 评论 0原文

我想用 52fps 的 RGB 图像流生成一个视频文件。我发现 opencv api 使用起来非常方便(cv::VideoWriter)。问题是我只能用VLC播放生成的avi;它播放视频但大喊:

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

任何其他视频播放器(在同一台计算机上)都无法读取和播放该视频。 录制时一切看起来都正常:我得到有关输出、帧大小、视频编解码器、fps 等的信息......没有错误。

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 

由于 OpenCv 仅支持 avi 作为视频容器,我唯一可以更改的是视频编解码器,我尝试了(FOURCC 代码)FLV1、DIVX、DIV3,但它们都无法正常工作。

我想在不同计算机上使用任何视频播放器播放此视频。我怎样才能让它发挥作用? VideoWriter 是正确的选择吗?

任何建议都非常受欢迎。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽你眉间 2025-01-04 16:54:23

如果您的图像有视频源,最好使用相同的编解码器进行输出:

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

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

或者,您可以尝试更旧、更简单的 FOURCC。或者是 Microsoft 特定的,如果您只想在 Windows 上运行它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文