我在 OSX 12.0.1 Monterey 上安装了 gstreamer。我刚刚在运行 python 3.9 的虚拟环境中安装了 python 绑定:
pip3 install pycairo PyGObject
我可以毫无问题gi地导入。gi.repository.Gst然而,似乎几乎所有 gstreamer 插件都丢失了。这是我的测试脚本:
import gi
gi.require_versions({'Gst': '1.0'})
from gi.repository import Gst, GLib
Gst.init(None)
Gst.debug_set_active(True)
Gst.debug_set_default_threshold(5)
if not Gst.init_check()[0]:
print("gstreamer initialization failed")
class Main:
def __init__(self):
self.pipeline = Gst.parse_launch('playbin uri=https://gstreamer.freedesktop.org/data/media/small/sintel.mkv')
self.pipeline.set_state(Gst.State.PLAYING)
self.main_loop = GLib.MainLoop.new(None, False)
GLib.MainLoop.run(self.main_loop)
self.bus = self.pipeline.get_bus()
self.msg = self.bus.timed_pop_filtered(
Gst.CLOCK_TIME_NONE,
Gst.MessageType.ERROR | Gst.MessageType.EOS
)
if self.msg is not None:
self.msg.unref()
self.bus.unref()
self.pipeline.set_state(Gst.State.NULL)
self.pipeline.unref()
Main()
Run Code Online (Sandbox Code Playgroud)
它失败了:
0:00:00.006178000 92472 0x7fbd7d049210 INFO …Run Code Online (Sandbox Code Playgroud)