Why an avi file can not be opened in OpenCV-Python

南楼画角 提交于 2019-12-11 08:00:07

问题


I installed OpenCV vers. 2.4.7.2 on a Windows Vista (32-bit) platform, with no reported errors. Then the following file:

C:\opencv\build\python\2.7\x86\cv2.pyd

was moved to:

C:\python27\Lib\site-packages\

I have been testing openCV with both images and video (*.avi) files. I have no problems (yet) when working with images. However, I have found a problem when trying to open avieo files. First, an example that works fine:

import cv2
path = 'D:/Videos/'
video = 'julius.avi'   # a test avi available from me via email attachment
vid = cv2.VideoCapture(path+video)
result = vid.isOpened()

[result returns True for this avi]

However, if I use

import cv2 
path = 'D:/Videos/'
video = 'toy_plane_liftoff.avi' # http://cinelerra.org/footage/
vid = cv2.VideoCapture(path+video)
result = vid.isOpened()

[result returns False for this avi]

Note, I have tried several other avi files (test avi's downloaded from the web) and most of them will not open. What can be done to open any "good" avi file? By good avi file I mean one that plays with Windows media player and VLC 2.1.2.

来源:https://stackoverflow.com/questions/20703691/why-an-avi-file-can-not-be-opened-in-opencv-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!