这就是我如何在我的 Mac OS Sierra 上启动 Python 3.6 并使用 GStreamer 绑定等运行。
如果您已经安装了 Gstreamer 及其插件,并且需要将其绑定到您的 Python 解释器以进行开发,请从步骤 1 开始。
0a- 从他们的网站安装 gstreamer ...通常然后
0b- brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
1- brew install gst-python --with-python3
但请注意,由于某种原因,“gtk”并未预先捆绑,因此我们进入第 2 步。
2- brew install gtk+3
就是这样,就像 ABC...
一样简单
附件是一个测试 python 代码,以确保您一切正常[可选]
import gi, time, sys
gi.require_version('Gst', '1.0')
gi.require_version('GstBase', '1.0')
gi.require_version('Gtk', '3.0')
from gi.repository import GObject, Gst, GstBase, Gtk, GObject
class Main:
def __init__(self):
Gst.init(None)
self.pipeline = Gst.Pipeline()
self.audiotestsrc = Gst.ElementFactory.make('audiotestsrc', 'audio')
self.pipeline.add(self.audiotestsrc)
self.sink = Gst.ElementFactory.make('autoaudiosink', 'sink')
self.pipeline.add(self.sink)
self.audiotestsrc.link(self.sink)
self.pipeline.set_state(Gst.State.PLAYING)
time.sleep(3)
self.pipeline.set_state(Gst.State.PAUSED)
self.pipeline.set_state(Gst.State.READY)
self.pipeline.set_state(Gst.State.NULL)
sys.exit(0)
start = Main()
Gtk.main()
希望一切顺利,c ya!!