我有一个 gstreamer 应用程序,我在其中创建带有图像的视频。我需要为预定义的时间创建视频。我想在预定义的时间之后发送 eos。我知道这可以使用 gstClock 中的 new_single_shot_id 来实现。但我找不到任何关于如何使用 new_single_shot_id 创建触发器的示例,该触发器绑定到将 eos 发送到管道的函数。
我的简化管道代码是这样的。
class Main(object):
def __init__(self, location):
self.pipeline = Gst.Pipeline()
self.img = Gst.ElementFactory.make("uridecodebin", "img1")
self.img.set_property("uri", location)
self.pipeline.add(self.img)
self.freeze = Gst.ElementFactory.make("imagefreeze", "freeze")
self.pipeline.add(self.freeze)
self.sink = Gst.ElementFactory.make("autovideosink", "sink0")
self.pipeline.add(self.sink)
self.img.link(self.freeze)
self.freeze.link(self.sink)
self.clock = self.pipeline.get_clock()
#self.trigger = Gst.SystemClock.new_single_shot_id(self.clock, 10)
def send_eos():
#code to send eos
pass
def run(self):
self.pipeline.set_state(Gst.State.PLAYING)
GObject.MainLoop().run()
我是 gstreamer 的新手,没有 c 编程经验。python中的示例将有很大帮助。