使用 Python 管理多平台视频流的最佳方法是什么?
这个问题我已经在我脑海里思考了一年多了。我想你们可能已经有了答案。
在一些Python GUI应用程序中,我需要显示视频流。 我需要录制该流的某些部分以便稍后重读。
此外,我需要使这个 python 应用程序成为多平台(OSX、GNU、Windows),
我对许多解决方案持开放态度:
- 将相机连接到流并使用 python 应用程序读取流。 (RTP + VLC 可以做到这一点)
- 使用 Phonon 读取相机
- 创建一个抽象类来定义不同的读取器,并在操作系统功能中使用 Quicktime、Win32 或 GStreamer。
你的经验是什么,你会用什么来做到这一点?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也定期对此进行研究,似乎底层任务的复杂性太高,无法为您的主题问题提供一个简单的快捷抽象库。不过,我建议使用 pyopencv 来完成您阐明的特定任务。它有一个用于网络摄像头输入/捕获的类,可以跨平台工作,并且具有合理的用户基础,用Python编写,发布示例。最新的是 2.3.1,而且是最近的版本。您可以在令人难以置信的有用网站(不是我的,只是说)上获得为您编译的 Windows 版本:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
既然你要求提供一些库的经验,我会说:gstreamer 在 Linux 上为我工作,但它是一个设置过程非常痛苦在 Windows 上,对我不起作用。这是很久以前的事了,也许现在效果更好了。 vlc.py 是一个简单的库,用于测试并查看 vlc 是否适合您。目前它不能在 64 位 Windows 平台上运行;不知道为什么,但似乎很多人都报告了类似的错误,所以这取决于您需要多少跨平台支持。
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.
不幸的是,这并不容易做到。我已经编写了在 3 个主要桌面操作系统上进行视频录制/播放的程序的大部分内容。除了 HTML 嵌入之外,跨平台的“开箱即用”方式的视频播放/录制状态仍然没有解决。这与以下事实有很大关系:
因此,您可以使用 HTML,或者您可能会遇到以下编码库的跨平台问题:
一旦您让它在一台开发机器上运行,就可以期待它了在最终用户计算机上进行安装时会出现问题(通过 pyinstaller / appdmg / apt / Chocolatey / Inno Setup 分发)
在 OSX 上,brew 仍然存在很多问题有了这个,但 macports 工作得更好(我仍然需要做很多修补)
Linux 是迄今为止最简单的。
Windows 的难度介于两者之间,
我很想知道 iOS / Android / Windows RT / Kindle 的情况如何。
这个问题并不是唯一的,因为甚至 Netflix 还没有跨平台的视频应用程序:https://www.quora.com/Is-Netflix-building-an-app-for-the-Mac-App-Store?share=1
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:
So you can go with HTML, or you can suffer through the cross-platform issues with the following coding libaries:
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