1 Star 0 Fork 0

zhangpengju / python-gst-tutorial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
basic-tutorial-2-ex-vertigo.py 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
Gregor Kralik 提交于 2015-10-21 23:12 . add links to SDK documentation
#!/usr/bin/env python3
# http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+2%3A+GStreamer+concepts
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib, GObject
# initialize GStreamer
Gst.init(None)
# create the elements
source = Gst.ElementFactory.make("videotestsrc", "source")
filter_vertigo = Gst.ElementFactory.make("vertigotv", "vertigo-filter")
videoconvert = Gst.ElementFactory.make("videoconvert", "video-convert")
sink = Gst.ElementFactory.make("autovideosink", "sink")
# create the empty pipeline
pipeline = Gst.Pipeline.new("test-pipeline")
if not pipeline or not source or not filter_vertigo or not videoconvert or not sink:
print("ERROR: Not all elements could be created")
sys.exit(1)
# build the pipeline
pipeline.add(source, filter_vertigo, videoconvert, sink)
if not source.link(filter_vertigo):
print("ERROR: Could not link source to filter-vertigo")
sys.exit(1)
if not filter_vertigo.link(videoconvert):
print("ERROR: Could not link filter-vertigo to videoconvert")
sys.exit(1)
if not videoconvert.link(sink):
print("ERROR: Could not link videoconvert to sink")
sys.exit(1)
# modify the source's properties
source.set_property("pattern", 0)
# start playing
ret = pipeline.set_state(Gst.State.PLAYING)
if ret == Gst.StateChangeReturn.FAILURE:
print("ERROR: Unable to set the pipeline to the playing state")
# wait for EOS or error
bus = pipeline.get_bus()
msg = bus.timed_pop_filtered(
Gst.CLOCK_TIME_NONE,
Gst.MessageType.ERROR | Gst.MessageType.EOS
)
if msg:
t = msg.type
if t == Gst.MessageType.ERROR:
err, dbg = msg.parse_error()
print("ERROR:", msg.src.get_name(), ":", err.message)
if dbg:
print("debugging info:", dbg)
elif t == Gst.MessageType.EOS:
print("End-Of-Stream reached")
else:
# this should not happen. we only asked for ERROR and EOS
print("ERROR: Unexpected message received.")
pipeline.set_state(Gst.State.NULL)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zhangpengju/python-gst-tutorial.git
git@gitee.com:zhangpengju/python-gst-tutorial.git
zhangpengju
python-gst-tutorial
python-gst-tutorial
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891