开发者

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

开发者 https://www.devze.com 2023-03-29 21:44 出处:网络
I have this question in my head for over a year now. And I guess you guys m开发者_运维百科ay have the answer.

I have this question in my head for over a year now. And I guess you guys m开发者_运维百科ay 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 ?


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.


Unfortunately, this is not easy to do. I've written most of a program that does video recording/playback on the 3 major desktop OS's. The state of video playback/recording in a "out-of-the-box" way is still unsolved for cross-platform, other than HTML embedding. This has a lot to do with the fact that:

  • Codecs are proprietary
  • OS's don't support common codecs
  • ffmpeg and similar projects have licenses that require you to release your source code if you include them in certain ways
  • A lot of the video playback players that exist are each rewritten by hand to handle each frame, buffering, streaming, audio sync'ing, and the like.

So you can go with HTML, or you can suffer through the cross-platform issues with the following coding libaries:

  • Python mplayer
  • Python vlc
  • Python opencv
  • Python pyaudio
  • Python pyside/pyqt phonon or qtmultimedia

Once you get it working on one development machine, expect it to break when it comes to installation on the end-user machine (distribute via: pyinstaller / appdmg / apt / chocolatey / Inno Setup )

On OSX, brew still has a lot of issues with this, but macports works better (I still had to do a lot of patching)

Linux is by far the easiest.

Windows is in-between the to as far as difficulty

I'd be eager to hear how iOS / Android / Windows RT / Kindle are

The problem is not unique, as even Netflix has yet to have a cross-platform video app: https://www.quora.com/Is-Netflix-building-an-app-for-the-Mac-App-Store?share=1

0

精彩评论

暂无评论...
验证码 换一张
取 消