OpenCV videowrite 不写视频 [英] OpenCV videowrite doesn't write video
问题描述
我使用了 OpenCV 3.0.0
教程中的以下页面:文档中的教程
I used the following page from OpenCV 3.0.0
tutorial: Tutorial in docs
当我尝试使用保存视频的示例时,它不起作用.
When I tried to use the example that saves videos, it doesn't work.
它显示来自网络摄像头的内容,还创建了一个名为output.avi
的文件,但是当我检查ouput.avi
的大小时,它是零字节.
It displays the content from the webcam, and also creates a file called output.avi
, but when I checked the size of ouput.avi
, it was zero bytes.
我也尝试过使用不同的编解码器,例如 YUY2
.
I also tried using different codecs, like YUY2
.
我使用 Python 2.7.8
和 OpenCV 3.0.0
和 Windows 8.1
推荐答案
我遇到了同样的问题,我通过将视频输出分辨率指定为与输入完全相同来解决它:
I had the same problem and i solved it by specifying the video output resolution to exactly the same as input:
cap = cv2.VideoCapture('vtest.avi')
...
out = cv2.VideoWriter('output.avi',fourcc, 20.0,(int(cap.get(3)),int(cap.get(4))))
当然要确保你安装了 ffmpeg 并且可以正常工作.
Of course make sure you got ffmpeg installed and working.
这篇关于OpenCV videowrite 不写视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!