Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoCapture().read() return False, None for .avi except tree.avi

import numpy as np
import cv2
import sys
fn = sys.argv[1]
cam = cv2.VideoCapture(fn)
ret, img = cam.read()
while ret:
  cv2.imshow('detection', img)
  if (0xFF & cv2.waitKey(5) == 27) or img.size == 0:
    break
  ret, img = cam.read()

I tried running the above code for a sample .avi file in opencv/samples/c/ called tree.avi and the above code displays that sample video. But when I try the same script for any other .avi files no video is displayed. I tried:

print cv2.VideoCapture('myFile.avi').read()

which returned "False None". I have also tried the video.py sample script in /opencv/samples/python2. video.py displays the tree.avi file, but not my own .avi files. I am using python2.7.3 and OpenCV-2.4.6 on windows.

I don't think this is an encoding issue because I have been able to view my .avi files using Windows Media Player. Any help would appreciated. Thank you.

VideoCapture().read() return False, None for .avi except tree.avi

import numpy as np
import cv2
import sys
fn = sys.argv[1]
cam = cv2.VideoCapture(fn)
ret, img = cam.read()
while ret:
  cv2.imshow('detection', img)
  if (0xFF & cv2.waitKey(5) == 27) or img.size == 0:
    break
  ret, img = cam.read()

I tried running the above code for a sample .avi file in opencv/samples/c/ called tree.avi and the above code displays that sample video. But when I try the same script for any other .avi files no video is displayed. I tried:

print cv2.VideoCapture('myFile.avi').read()

which returned "False None". I have also tried the video.py sample script in /opencv/samples/python2. video.py displays the tree.avi file, but not my own .avi files. I am using python2.7.3 and OpenCV-2.4.6 on windows.

I don't think this is an encoding issue because I have been able to view my .avi files using Windows Media Player. Any help would appreciated. Thank you.

click to hide/show revision 3
retagged

VideoCapture().read() return False, None for .avi except tree.avi

import numpy as np
import cv2
import sys
fn = sys.argv[1]
cam = cv2.VideoCapture(fn)
ret, img = cam.read()
while ret:
  cv2.imshow('detection', img)
  if (0xFF & cv2.waitKey(5) == 27) or img.size == 0:
    break
  ret, img = cam.read()

I tried running the above code for a sample .avi file in opencv/samples/c/ called tree.avi and the above code displays that sample video. But when I try the same script for any other .avi files no video is displayed. I tried:

print cv2.VideoCapture('myFile.avi').read()

which returned "False None". I have also tried the video.py sample script in /opencv/samples/python2. video.py displays the tree.avi file, but not my own .avi files. I am using python2.7.3 and OpenCV-2.4.6 on windows.

I don't think this is an encoding issue because I have been able to view my .avi files using Windows Media Player. Any help would appreciated. Thank you.