views:

564

answers:

3

Hi,

I'm looking for a Python framework that will enable me to play video as well as draw on that video (for labeling purposes).

I've tried Pyglet, but this doesn't seem to work particularly well - when drawing on an existing video, there is flicker (even with double buffering and all of that good stuff), and there doesn't seem to be a way to get the frame index in the video during the per-frame callback (only elapsed time since the last frame).

+2  A: 

Qt (PyQt) has Phonon, which might help out. PyQt is available as GPL or payware. (Qt has LGPL too, but the PyQt wrappers don't)

Marcus Lindblom
Qt is probably where I should have started, but it still doesn't have the functionality I'm looking for. In Qt parlance I would need a signal generated when the frame changed. (For GIFs I'd be set but Phonon doesn't have the same functionality as QMovie).
Justin Scheiner
+2  A: 

Try the Python bindings for GStreamer.

Jeffrey Finkelstein
+1  A: 

Try a Python wrapper for OpenCV such as ctypes-opencv. The C API reference is here, and the wrapper is very close (see docstrings for any changes).

I have used it to draw on video without any flicker, so you should have no problems with that.

A rough outline of calls you need:

  • Load video with cvCreateFileCapture, load font with cvFont.
  • Grab frame with cvQueryFrame, increment your frame counter.
  • Draw on the frame with cvPutText, cvEllipse, etc etc.
  • Display to user with cvShowImage.
Kiv