OpenCV videowrite 不写视频 [英] OpenCV videowrite doesn't write video

查看:88
本文介绍了OpenCV videowrite 不写视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 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.8OpenCV 3.0.0Windows 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆