Ask Your Question

tjmonsi's profile - activity

2017-11-09 20:00:21 -0600 received badge  Famous Question (source)
2015-09-09 23:36:56 -0600 received badge  Notable Question (source)
2014-11-04 10:47:50 -0600 received badge  Popular Question (source)
2013-01-09 18:15:16 -0600 received badge  Student (source)
2012-12-12 00:45:55 -0600 asked a question Cannot open ".mp4" video files using OpenCV 2.4.3, Python 2.7 in Windows 7 machine

Hi

I am currently working on a project that involves reading mp4 video files. The problem I encountered is that it using Python 2.7 (32 bit), OpenCV 2.4.3 (cv2.pyd) in a Windows 7 machine.

The code snippet is as follows:

try:
        video = cv2.VideoCapture("video.mp4")
except:
        print "Could not open video file"
        raise
print video.grab()

"video.grab()" always returns false: meaning it doesn't read the file "video.mp4" But when we try this:

try:
        video = cv2.VideoCapture("video.avi")
except:
        print "Could not open video file"
        raise
print video.grab()

"video.grab()" returns true: meaning it is able to read ".avi" files.

Another is we have tried this same snippet on Linux and Mac and it seems to work fine, meaning it is able to read both mp4 files and avi files.

This problem is similar to blimp555's problem and slychief's problem. Both still don't have a clear and workable answer.

I would appreciate any help or workaround aside from just using Linux or Mac for programming this as I need this to work on all three systems.