playing video file

asked 2014-04-11 19:24:07 -0600

soniak_169 gravatar image

updated 2014-04-11 19:41:20 -0600

Are there any common reasons why a open cv won't recognize a video when I try playing it? I saved the video in my python directory. I've opened images from the same folder and I've connected to my webcam, but the video file won't open. When I run the code, nothing happened. I tried in flv and mp4 format. Any suggestions? Here is the code

import numpy as np

import cv2

cap = cv2.VideoCapture('vid.mp4')

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()

edit retag flag offensive close merge delete