使用 Python 管理多平台视频流的最佳方法是什么?

发布于 2024-11-30 21:00:11 字数 363 浏览 0 评论 0原文

这个问题我已经在我脑海里思考了一年多了。我想你们可能已经有了答案。

在一些Python GUI应用程序中,我需要显示视频流。 我需要录制该流的某些部分以便稍后重读。

此外,我需要使这个 python 应用程序成为多平台(OSX、GNU、Windows),

我对许多解决方案持开放态度:

  • 将相机连接到流并使用 python 应用程序读取流。 (RTP + VLC 可以做到这一点)
  • 使用 Phonon 读取相机
  • 创建一个抽象类来定义不同的读取器,并在操作系统功能中使用 Quicktime、Win32 或 GS​​treamer。

你的经验是什么,你会用什么来做到这一点?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╭⌒浅淡时光〆 2024-12-07 21:00:11

我也定期对此进行研究,似乎底层任务的复杂性太高,无法为您的主题问题提供一个简单的快捷抽象库。不过,我建议使用 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.

美男兮 2024-12-07 21:00:11

不幸的是,这并不容易做到。我已经编写了在 3 个主要桌面操作系统上进行视频录制/播放的程序的大部分内容。除了 HTML 嵌入之外,跨平台的“开箱即用”方式的视频播放/录制状态仍然没有解决。这与以下事实有很大关系:

  • 编解码器是专有
  • 操作系统,不支持通用编解码器
  • ffmpeg 和类似项目具有许可证,如果您以某些方式包含它们,则要求您发布源代码
  • 许多视频播放播放器存在的每个都手动重写以处理每个帧、缓冲、流式传输、音频同步等。

因此,您可以使用 HTML,或者您可能会遇到以下编码库的跨平台问题:

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

一旦您让它在一台开发机器上运行,就可以期待它了在最终用户计算机上进行安装时会出现问题(通过 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:

  • 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文