如何向总线发送EOS消息

发布于 2024-09-14 09:25:15 字数 1369 浏览 4 评论 0原文

好的,我有这样的事情:

    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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱的十字路口 2024-09-21 09:25:15

好吧,我以某种方式解决了它:

我添加了

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

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')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文