简体   繁体   English

无法在OpenCV(Python)中打开视频

[英]Cannot open video in OpenCV (Python)

I am trying to open video in openCV but it is not working i found solutions by adding full path ie "D:/Folder1/Folder2/1.avi", converting video to .avi instead of mp4, copy the dll file from open cv to python folder after changing it is name by opencv version and windows 64 bit ffmpeg opencv_ffmpeg320_64.dll my opencv version 3.2.0 windows 64 python2.7 and Anaconda2 我正在尝试在openCV中打开视频,但无法正常工作,我通过添加完整路径找到了解决方案,例如“ D:/Folder1/Folder2/1.avi”,将视频转换为.avi而不是mp4,从打开的cv复制dll文件更改为python文件夹后,将其命名为opencv版本和Windows 64位ffmpeg opencv_ffmpeg320_64.dll我的opencv版本3.2.0 Windows 64 python2.7和Anaconda2

I am beginner in Python and unfortunately nothing of the above solved my problem. 我是Python的初学者,很不幸,以上方法都无法解决我的问题。

below my code snippet: 在我的代码段下面:

import numpy as np
import cv2

cap = cv2.VideoCapture('1.avi')
if cap.isOpened():
    print "opend"
else:
    print "not opend"

while(cap.isOpened()):
    ret, frame = cap.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

OpenCV is trying to find the codec needed to open that video but is not finding it, so you need to install it. OpenCV试图找到打开该视频所需的编解码器,但找不到它,因此您需要安装它。 Try to download a codec package from the internet and then try again. 尝试从Internet下载编解码器程序包,然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM