当前位置: 首页>>代码示例>>Python>>正文


Python Gst.caps_from_string方法代码示例

本文整理汇总了Python中gi.repository.Gst.caps_from_string方法的典型用法代码示例。如果您正苦于以下问题:Python Gst.caps_from_string方法的具体用法?Python Gst.caps_from_string怎么用?Python Gst.caps_from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gst的用法示例。


在下文中一共展示了Gst.caps_from_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _gst_init

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import caps_from_string [as 别名]
def _gst_init(self):
        # self._appsink will receive the buffers so we can upload them to GPU
        self._appsink = Gst.ElementFactory.make('appsink', '')
        self._appsink.props.caps = Gst.caps_from_string(
            'video/x-raw,format=RGB')

        self._appsink.props.async = True
        self._appsink.props.drop = True
        self._appsink.props.qos = True
        self._appsink.props.emit_signals = True
        self._appsink.connect('new-sample', partial(
            _gst_new_buffer, ref(self)))

        # playbin, takes care of all, loading, playing, etc.
        self._playbin = Gst.ElementFactory.make('playbin', 'playbin')
        self._playbin.props.video_sink = self._appsink

        # gstreamer bus, to attach and listen to gst messages
        self._bus = self._playbin.get_bus()
        self._bus.add_signal_watch()
        self._bus.connect('message', _on_gst_message)
        self._bus.connect('message::eos', partial(
            _on_gst_eos, ref(self))) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:25,代码来源:video_gi.py

示例2: _create_main_pipeline

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import caps_from_string [as 别名]
def _create_main_pipeline(self, device, size, fps, sync):
        self.pipeline = Gst.Pipeline()

        self.source = Gst.ElementFactory.make('v4l2src', 'source')
        self.source.set_property('device', device)
        self.source.set_property('do-timestamp', 'true')
        # run 'v4l2-ctl --list-ctrls' for full list of controls
        struct, _ = Gst.structure_from_string('name,\
                                               white_balance_temperature_auto=(bool){0},\
                                               backlight_compensation=(int){0},\
                                               exposure_auto=0,\
                                               focus_auto=(bool){0}')
        self.source.set_property('extra-controls', struct)

        caps = Gst.caps_from_string('video/x-raw,format=(string){BGR},width=%d,height=%d,framerate=%d/1'%(size[1], size[0], fps))
        self.sink = Gst.ElementFactory.make('appsink', 'sink')
        self.sink.set_property('emit-signals', True)
        self.sink.set_property('sync', sync)
        self.sink.set_property('drop', True)
        self.sink.set_property('max-buffers', 1)
        self.sink.set_property('caps', caps)
        self.sink.emit('pull-preroll')

        self.pipeline.add(self.source)
        self.pipeline.add(self.sink)

        Gst.Element.link(self.source, self.sink) 
开发者ID:alexlee-gk,项目名称:visual_dynamics,代码行数:29,代码来源:video.py

示例3: init_request

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import caps_from_string [as 别名]
def init_request(self, id, caps_str):
        self.request_id = id
        logger.info("%s: Initializing request" % (self.request_id))
        if caps_str and len(caps_str) > 0:
            logger.info("%s: Setting caps to %s" % (self.request_id, caps_str))
            caps = Gst.caps_from_string(caps_str)
            self.appsrc.set_property("caps", caps)
        else:
            #caps = Gst.caps_from_string("")
            self.appsrc.set_property("caps", None)
            #self.pipeline.set_state(Gst.State.READY)
            pass
        #self.appsrc.set_state(Gst.State.PAUSED)

        if self.outdir:
            self.pipeline.set_state(Gst.State.PAUSED)
            self.filesink.set_state(Gst.State.NULL)
            self.filesink.set_property('location', "%s/%s.raw" % (self.outdir, id))
            self.filesink.set_state(Gst.State.PLAYING)

        #self.filesink.set_state(Gst.State.PLAYING)        
        #self.decodebin.set_state(Gst.State.PLAYING)
        self.pipeline.set_state(Gst.State.PLAYING)
        self.filesink.set_state(Gst.State.PLAYING)
        # push empty buffer (to avoid hang on client diconnect)
        #buf = Gst.Buffer.new_allocate(None, 0, None)
        #self.appsrc.emit("push-buffer", buf)

        # reset adaptation state
        self.set_adaptation_state("") 
开发者ID:alumae,项目名称:kaldi-gstreamer-server,代码行数:32,代码来源:decoder2.py

示例4: init_request

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import caps_from_string [as 别名]
def init_request(self, id, caps_str):
        self.request_id = id
        if caps_str and len(caps_str) > 0:
            logger.info("%s: Setting caps to %s" % (self.request_id, caps_str))
            caps = Gst.caps_from_string(caps_str)
            self.appsrc.set_property("caps", caps)
        else:
            #caps = Gst.caps_from_string(None)
            self.appsrc.set_property("caps", None)
            #self.pipeline.set_state(Gst.State.READY)
            pass
        #self.appsrc.set_state(Gst.State.PAUSED)

        if self.outdir:
            self.pipeline.set_state(Gst.State.PAUSED)
            self.filesink.set_state(Gst.State.NULL)
            self.filesink.set_property('location', "%s/%s.raw" % (self.outdir, id))
            self.filesink.set_state(Gst.State.PLAYING)

        #self.filesink.set_state(Gst.State.PLAYING)
        #self.decodebin.set_state(Gst.State.PLAYING)
        self.pipeline.set_state(Gst.State.PLAYING)
        self.filesink.set_state(Gst.State.PLAYING)
        # push empty buffer (to avoid hang on client diconnect)
        buf = Gst.Buffer.new_allocate(None, 0, None)
        self.appsrc.emit("push-buffer", buf)
        logger.info('%s: Pipeline initialized' % (self.request_id)) 
开发者ID:alumae,项目名称:kaldi-gstreamer-server,代码行数:29,代码来源:decoder.py


注:本文中的gi.repository.Gst.caps_from_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。