tags:

views:

53

answers:

1

ok, I have something like this:

    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()

I want to stop (EOS) the stream in ready state, change the location and so.. help?

self.bus.emit('eos') gives me TypeError: : unknown signal name: eos

A: 

well I solved it somehow:

I added self.bus = self.pipeline.get_bus() self.bus.connect('message::eos', self.on_eos)

    self.loop = gobject.MainLoop()

and three methods:

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')
manson54