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

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

问题描述

我刚刚开始使用opencv编程python. 我使用了来自opencv 3.0.0教程的以下页面

I just started programming python with opencv. I used the following page from opencv 3.0.0 tutorial

阅读本教程文档

当我尝试使用保存视频的示例时,它不起作用. 它显示网络摄像头中的内容,并创建一个名为output.avi的文件,但是当我检查ouput.avi的大小时,它为零字节. 我还尝试使用其他编解码器,例如YUY2

When I tried to use the example that saves videos, it doesn't work. 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. I also tried using different codecs, like YUY2

我使用python 2.7.8和opencv 3.0.0 和Windows 8.1

I use python 2.7.8 and opencv 3.0.0 and 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.

这篇关于python opencv videowrite不写视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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