Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

playing video file

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. I tried in flv and mp4 format. Any suggestions?

click to hide/show revision 2
No.2 Revision

playing video file

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?

click to hide/show revision 3
No.3 Revision

playing video file

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