1
我想从文件中读取 好像视频视频读取视频被打开,但我不能读框架:与OpenCV的Python的
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.0.0'
>>>
>>> video = cv2.VideoCapture('action-recognition-train/0000.avi')
>>> video.isOpened()
True
>>> nFrames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
>>> print "frame number: %s" %nFrames
frame number: 166
>>> fps = video.get(cv2.CAP_PROP_FPS)
>>> print "FPS value: %s" %fps
FPS value: 25.0
>>> height = video.get(cv2.CAP_PROP_FRAME_HEIGHT)
>>> width = video.get(cv2.CAP_PROP_FRAME_WIDTH)
>>> print "video size:", height, 'x', width
video size: 240.0 x 320.0
>>> video.read()
(False, None)
从网络摄像阅读与cv2.VideoCapture( 0)是好的
视频文件的内部可能非常复杂 - 知道这是一个AVI文件只会缩小一点。我不认识CV2的问题(我的视频体验是与其他工具)。但是,为了帮助别人回答,可能会显示从'ffprobe'或'mediainfo'获得的视频流类型 - 或者只是在视频源是公开的时候链接视频源。机会是视频文件中的特定编解码器和其他选择会影响您获取帧。 –