I don't remember very well, but I think that one disadvantage of pyglet
could be that it does not allow to seek precisely to a frame number, but it
does seeking with time or something like this, that happens to be not very
precise. For my application I need to retrieve a frame in the sequence with
precision ...
By the way, there is also ffms, based in ffmpegsource, and also does the
job. This for python 2.7, for 2.6 there is pyffmpeg.
2012/7/12 Brian Holt
I've been using Pyglet to do the same job... Here is a gist: gist.github.com/3097115
If its useful, I could put in a PR.
Brian
On 12 July 2012 10:31, Otto Fajardo
wrote: Hi Tony,
thanks very much for your reply! I solved the problem and found a couple of things that can be useful for other users:
1- I am using Windows XP.
2- I didn't manage to property install gstreamer. I fail to import critical modules. No idea why.
3- Opencv works! The interesting thing is that it needs pygtk module to be installed.
In the past I already tried opencv for this purpose and failed. While trying to install gstreamer I install pygtk, and now it works fine, both using scikits and opencv itself!!! Windows binaries for both opencv and pygtk can be obtained from Christoph Gohlke webpage, so it's quite easy to install. I think you could mention this in your webpage, could be useful for future users.
4- I found something I think is a but, and I have a suggestion:
* Bug: the method duration is not working well, it gives strange results to me. The problem is in video.py line 107. I replace this line by return cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FRAME_COUNT)/cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FPS) and now works fine.
* Suggestion: implement a method to directly obtain fps from the video. It's quite easy, will be 2 minutes: I added two funtions in video.py, one in classs CvVideo: def fps(self):
return cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FPS)
and another in class Video:
def fps(self):
return self.video.fps()
I think this is useful.
Cheers!
2012/7/12 Tony Yu
Hi Otto,
See response below.
On Wed, Jul 11, 2012 at 5:14 AM, Otto
wrote: Hi, I would like to try the Video function in skimage.io. I installed gstreamer, toghether with gstreamer sdk providing the python bindings. So, when I say import pygst from python console, it does not complain. However, trying to use the Video function like this:
myvideo = skio.Video(source=source,backend='gstreamer')
gives this error message:
<snip>
raise ImportError("GStreamer Python bindings 0.10+ required") ImportError: GStreamer Python bindings 0.10+ required
So: how to install properly these python bindings for gstreamer???
What system are you running and how did you install GStreamer?
I don't actually have GStreamer installed, so my usefulness here is limited. Looking at the code though, I'm not sure it's actually failing on the version check (which I think raises an Assertion error, but the caught exception is an ImportError).
Could you try running the following imports:
import gst import gobject from gst.extend.discoverer import Discoverer
By the way: Is this module appropiate to open a video file, let's say an avi file, that is compressed using for example with XViD, and then retrieve single frames as numpy arrays?
thanks!
If GStreamer can read it, then the video plugin should be able to as well. Yes, you can access a frame with the video's `get` method (which returns a numpy array).
You can also use the video functionality by using OpenCV as a backend (but that could be difficult to install, depending on your system).
Cheers, -Tony
participants (1)
-
Otto Fajardo