【发布时间】:2019-10-22 11:19:08
【问题描述】:
我是 GStreamer 的新手,我创建了一个小示例,我正在录制网络摄像头并使用 appsink 获取示例,但是当我尝试通过将其状态设置为 null 并发送 EOS 事件来停止管道时,我的总线回调永远不会为 EOS 调用函数。
各位,帮帮我
类主要: 关机=假
def __init__(self):
signal.signal(signal.SIGINT, self.keyboardInterruptHandler)
self._pipeline = Gst.parse_launch("avfvideosrc name=avfvideosrc ! x264enc name=x264enc ! appsink name=appsink max-buffers=1 drop=false sync=false emit-signals=true wait-on-eos=false")
bus = self._pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message::eos", self._on_eos_from_sink_pipeline)
bus.connect("message", self.on_status_changed)
appsink = self._pipeline.get_by_name('appsink')
appsink.connect('new-sample', self.on_new_sample)
appsink.connect('eos', self.eos)
#bus.connect('message', self.on_status_changed)
self._pipeline.set_state(Gst.State.PLAYING)
def on_new_sample(self, appsink):
return Gst.FlowReturn.OK
def _on_eos_from_sink_pipeline(self, _bus, _message):
print("Got EOS from sink pipeline")
exit()
def eos(self, sink):
print("SINK EOS")
return True
def on_status_changed(self, bus, message):
print('Status: ', message.type)
print('Object: ', message.src)
print('Parsed Message: ', message.parse_state_changed())
def keyboardInterruptHandler(self,signal, frame):
print("KeyboardInterrupt (ID: {}) has been caught. Cleaning up...".format(signal))
self.shutdown = True
self.stopFetching()
def stopFetching(self):
print("AT THE START OF STOP FETCHING")
self._pipeline.set_state(Gst.State.NULL)
self._pipeline.send_event(Gst.Event.new_eos())
print("AT THE END OF STOP FETCHING")
开始 = Main() gtk.main()
【问题讨论】: