Search code examples
pythonqtvideogstreamerphonon

What is the best way to manage multiplatform video stream using Python?


I have this question in my head for over a year now. And I guess you guys may have the answer.

In some Python GUI app, I need to display a video stream. I need to record some part of this stream to reread it later.

Moreover, I need to make this python application multi platform (OSX, GNU, Windows)

I am open to many solutions :

  • Connect the camera to a stream and read the stream with the python app. (RTP + VLC could do the trick)
  • Use Phonon to read the camera
  • Create an abstract class to define differents reader and use Quicktime, Win32 or GStreamer in function of the OS.

What is your experience, what would you use to do that ?


Solution

  • I've looked into this periodically as well, and it seems the complexity of the underlying task is just too high to have a simple shortcut abstraction library for your topic question. I would suggest using pyopencv for the specific task you articulate, however. It has a class for webcam input/capture which works across platforms and has a reasonable user-base, in python, posting examples. The latest is 2.3.1 and quite recent. You can get a windows version of it, compiled for you, on the unbelievably helpful site (not mine, just saying):

    http://www.lfd.uci.edu/~gohlke/pythonlibs/

    Since you ask for experience with a few libraries, I'd say: gstreamer worked for me on linux but was a huge pain to setup on windows and didn't work for me. This was quite some time ago and perhaps it's working better now. vlc.py is a simple library to test and see whether vlc would work for you. It doesn't work on 64 bit windows platforms at the moment; not sure why, but it seems many have reported similar errors, so it depends on how much cross-platform support you need.