问题描述
我尝试了很多不同的东西,但是当按下 ctrl+c 并正确停止我的管道并获取视频文件时,我无法发送和 eos 消息。为什么我在这里失踪了?
def bus_call(bus,message,loop):
t = message.type
if t == Gst.MessageType.EOS:
logger.info("End-of-stream\n")
loop.quit()
elif t==Gst.MessageType.WARNING:
err,debug = message.parse_warning()
logger.info("Warning: %s: %s\n" % (err,debug))
elif t == Gst.MessageType.ERROR:
err,debug = message.parse_error()
logger.info("Error: %s: %s\n" % (err,debug))
loop.quit()
return True
# Set up pipeline
logger.info("GStreamer initialization")
GObject.threads_init()
Gst.init(None)
logger.info("Creating Pipeline")
pipeline = Gst.Pipeline()
# create and add elements
....
loop = GObject.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message",bus_call,loop)
logger.info("Starting pipeline")
self.gst_pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except KeyboardInterrupt:
pipeline.send_event(Gst.Event.new_eos())
pipeline.set_state(Gst.State.NULL)
@H_404_4@
解决方法
我终于解决了我的问题。答案在此主题 https://github.com/beetbox/audioread/issues/63 中。
所以基本上我将我的 pygobject 版本更新到 3.38.0 并使用新的构造函数 routes: [
{
path: '/page',name: 'some',meta: {
title: 'Best seo title',description: 'Best seo description'
},component: someComponent,},
来避免默认签名问题。
之后,我用信号处理程序替换了 KeyboardInterrupt 异常:
GObject.MainLoop.new(None,False)
这就像一个魅力!