这个简单的Gstreamer应用程序使用python失败
import pgi
pgi.require_version('Gst', '1.0')
from pgi.repository import Gst, GLib
import traceback
Gst.init([])
pipeline = Gst.Pipeline()
src = Gst.ElementFactory.make('videotestsrc', 'src')
sink = Gst.ElementFactory.make('autovideosink', 'sink')
pipeline.add(src)
pipeline.add(sink)
src.link(sink)
src.set_property("pattern", 0)
pipeline.set_state(Gst.State.PLAYING)使用
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/Documents/mythic-projects/OKR_2019Q2/gstreamer_pipeline.py in <module>
12 pipeline.add(sink)
13 src.link(sink)
---> 14 src.set_property("pattern", 0)
15
16 pipeline.set_state(Gst.State.PLAYING)
~/Documents/mythic-projects/OKR_2019Q2/venv/lib/python3.6/site-packages/pgi/obj.py in set_property(self, name, value)
73
74 if not hasattr(self.props, name):
---> 75 raise TypeError("Unknown property: %r" % name)
76 setattr(self.props, name, value)
77
TypeError: Unknown property: 'pattern'我可以确认命令行操作工作正常:
gst-launch-1.0 videotestsrc pattern=snow ! autovideosink但是API似乎与文档和教程不同。对于任何.set_property()操作都是如此。
例如http://lifestyletransfer.com/how-to-launch-gstreamer-pipeline-in-python/
我正在Mac上运行,python3.6,我安装了gstreamer,如这里所概述的:Installing Gstreamer-1.0 on Mac OS X Mavericks (我也尝试从.dmg安装,但结果是一样的)
发布于 2019-04-19 06:06:29
本教程使用的是import gi而不是import pgi。这可能会有所改变。
PGI页面https://github.com/pygobject/pgi说它是没有维护的,人们也应该使用PyGObject。
https://stackoverflow.com/questions/55753897
复制相似问题