如何在OpenCV大于2gb的情况下编写avi文件?

2024-10-05 11:04:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Python使用OpenCV,但实际上可以切换到C++,所以如果有问题,请考虑它回答问题。在

我正在写.avi文件(将多个avi文件合并为一个)

cv2.VideoWriter([filename, fourcc, fps, frameSize[, isColor]]) 

但是最近发现我不能用它来写大于2GB的.avi文件。它甚至提到:Due to this OpenCV for video containers supports only the avi extension, its first version. A direct limitation of this is that you cannot save a video file larger than 2 GB.

但是现在我没有时间去学习新的库,比如ffmpeg,我需要很快的学习。在

我如何使用C++或Python编写OpenCV,或者至少使用输入部分——使用

来编写这个文件 ^{pr2}$

作为框架


Tags: 文件toforvideofilenamethiscv2opencv
2条回答

你已经回答了你自己的问题,但我担心这不是你想要的答案。在

从你的链接

As you can see things can get really complicated with videos. However, OpenCV is mainly a computer vision library, not a video stream, codec and write one. Therefore, the developers tried to keep this part as simple as possible. Due to this OpenCV for video containers supports only the avi extension, its first version. A direct limitation of this is that you cannot save a video file larger than 2 GB. Furthermore you can only create and expand a single video track inside the container. No audio or other track editing support here. Nevertheless, any video codec present on your system might work. If you encounter some of these limitations you will need to look into more specialized video writing libraries such as FFMpeg or codecs as HuffYUV, CorePNG and LCL.

这一段说的是OpenCV的开发人员做出了一个设计选择,即您不能使用OpenCV编写大于2Gb的视频文件,具体原因是它是一个计算机视觉库,而不是一个视频工具。在

不幸的是,如果你想写大于2Gb的视频,你就需要学会使用FFMPEG或类似的东西(这并不难,而且与OpenCV有很好的绑定)

在opencv3.0中,由于引入了新的文件格式,如.mkv,这些格式确实支持大于2GB的视频文件,因此该限制被删除了。在

Does OpenCV 3.0 Still Has Limits On VideoWriter Size?。在

注意:文档和示例还没有更新,所以这应该被认为是实验性的。在

相关问题 更多 >

    热门问题