self.pipeline = gst.Pipeline()
self.tee = gst.element_factory_make
self.source = gst.element_factory_make('subdevsrc')
self.source.set_property('viewfinder-mode', 1)
self.source.set_property('camera-device', 1)
self.capsfilter = gst.element_factory_make('capsfilter')
caps = 'video/x-raw-yuv, width=640, height=480'
self.capsfilter.set_property('caps', gst.caps_from_string(caps))
self.tee = gst.element_factory_make('tee')
self.queue1 = gst.element_factory_make('queue')
self.queue2 = gst.element_factory_make('queue')
self.encoder = gst.element_factory_make('dsphdmp4venc')
self.muxer = gst.element_factory_make('mp4mux')
self.imagesink = gst.element_factory_make('xvimagesink')
self.filesink = gst.element_factory_make('filesink')
self.filesink.set_property('location', '/dev/null')
self.pipeline.add(self.source, self.capsfilter, self.tee, self.queue1, self.queue2, self.encoder, self.muxer, self.imagesink, self.filesink)
gst.element_link_many(self.source, self.capsfilter, self.tee, self.queue1, self.imagesink)
gst.element_link_many(self.tee, self.queue2, self.encoder, self.muxer, self.filesink)
self.bus = self.pipeline.get_bus()
我想停止(EOS)流处于就绪状态,更改位置等等。 帮助
self.bus.emit( 'EOS') 给我TypeError ::未知信号名称:eos
答案 0 :(得分:0)
我以某种方式解决了它:
我添加了
self.bus = self.pipeline.get_bus()
self.bus.connect('message::eos', self.on_eos)
self.loop = gobject.MainLoop()
和三种方法:
def location(self, filename):
self.ready()
gst.element_unlink_many(self.muxer, self.filesink)
self.filesink.set_state(gst.STATE_NULL)
self.filesink.set_property('location', filename)
self.filesink.set_state(gst.STATE_READY)
gst.element_link_many(self.muxer, self.filesink)
self.run()
if self.pipeline.get_state()[1] != gst.STATE_PLAYING:
self.stop()
def eos(self):
self.bus.add_signal_watch()
self.pipeline.send_event(gst.event_new_eos())
try:
self.loop.run()
except KeyboardInterrupt:
self.on_eos(None,None)
def on_eos(self, bus, msg):
self.loop.quit()
self.bus.remove_signal_watch()
self.location('/dev/null')