Opening video using Python - cannot play video
I am trying to do some simple video processing using OpenCV and Python (v2.7.3, running under FC18 64bit) but it looks like I am stuck at the very beginning... opening the video
I am using this very simple code:
import cv2
import cv2.cv as cv
filename = "/home/nico/Documents/test.avi"
vidFile = cv2.VideoCapture(filename)
nFrames = int(vidFile.get(cv.CV_CAP_PROP_FRAME_COUNT))
fps = vidFile.get(cv.CV_CAP_PROP_FPS)
print("Num. frames = ",nFrames)
print("Frame rate = ", fps, " fps")
This results in:
warning: GStreamer: Error opening bin
(/builddir/build/BUILD/opencv-2.4.5/modules/highgui/src/cap_gstreamer.cpp:354)
('Num. Frames = ', 0)
('Frame Rate = ', 0.0, ' fps')
The file exists, it is readable and works perfectly under various video players.
GStreamer seems to be properly installed (packages gstreamer, gstreamer-plugins-*, gstreamer-python) and up-to-date
If I convert the file into ogg and try to open it with the same code I get a different error
warning: GStreamer: unable to query position of stream (/builddir/build/BUILD/opencv-2.4.5/modules/highgui/src/cap_gstreamer.cpp:660)
Any idea how to resolve this problem?
EDIT: after some Googling and looking at the cap_gstreamer.cpp file I finally realised I was misinterpreting the error. OpenCV finds GStreamer allright, but it seems it cannot create a GstBin object. The error comes from a call to gst_parse_bin_from_description. Anyone has any idea of why that is and what can I do about it?
Is your PC x86 or x64? Try adding the following for x64 in your PATH variable in the Environmental Variables of the computer: ...\opencv\build\x64\vc10\bin in other words: Add the bin path of your OpenCV to the PATH