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'獲得的視頻流類型 - 或者只是在視頻源是公開的時候鏈接視頻源。機會是視頻文件中的特定編解碼器和其他選擇會影響您獲取幀。 –