Ask Your Question
1

Opening video using Python - cannot play video

asked 2013-08-07 02:44:23 -0600

nico gravatar image

updated 2017-08-22 03:19:25 -0600

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?

edit retag flag offensive close merge delete

Comments

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

aliavci gravatar imagealiavci ( 2014-10-19 23:06:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-11-30 13:28:15 -0600

Do you have the solution?

I have the same problem!!!

Thanks

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-08-07 02:44:23 -0600

Seen: 3,526 times

Last updated: Nov 30 '14