python opencv读取视频帧,OpenCV + python-从视频文件中获取帧

I can't seem to capture frames from a file using OpenCV -- I've compiled from source on Ubuntu with all the necessary prereqs according to: http://opencv.willowgarage.com/wiki/InstallGuide%20%3A%20Debian

#!/usr/bin/env python

import cv

import sys

files = sys.argv[1:]

for f in files:

capture = cv.CaptureFromFile(f)

print capture

print cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH)

print cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT)

for i in xrange(10000):

frame = cv.QueryFrame(capture)

if frame:

print frame

Output:

ubuntu@local:~/opencv$ ./test.py bbb.avi

0.0

0.0

The frames are always None...

I've transcoded a video file to i420 format using:

mencoder $1 -nosound -ovc raw -vf format=i420 -o $2

Any ideas?

解决方案

You don't have the gstreamer-ffmpeg or gsteamer-python or gsteamer-python-devel packages installed. I installed all three of them. and the exact same problem was resolved.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值