【发布时间】:2017-02-10 17:00:43
【问题描述】:
我试图在 ubuntu 上使用 Opencv3(安装在 conda env 中)在我的 python 脚本中读取 mp4 文件。但收到以下消息:
Unable to stop the stream: Inappropriate ioctl for device
我发现 Opencv 不支持开箱即用的 mp4。是否可以在我的机器上安装额外的库来制作视频而不重建 Opencv?一些配置可能?
代码来了:
def workOnVideoFile(path) :
print('Reading the video from ' + path )
cap = cv2.VideoCapture(path)
print('Is video opened? ' + str(cap.isOpened()) )
while(cap.isOpened()):
ret, frame = cap.read()
print('Frame has been read ' + str(ret))
workOnFrame(frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
print('Releasing the video' + str(cap))
cap.release()
#img = cv2.imread('car.jpg')
if __name__ == "__main__":
if (os.path.isfile(videoFile)) :
workOnVideoFile(videoFile)
else :
print('File ' + videoFile + ' is not found')
cv2.destroyAllWindows()
【问题讨论】:
-
它对任何 mp4 文件的描述是否有效?请你分享一下失败的小 mp4 文件。
-
任何文件,但由于@Mick 提到的专利,Ubuntu 存在视频问题。
标签: python opencv ubuntu video