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


Python Gst.Pipeline方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def __init__(self):
        """ Initialize app src. """
        self._mainloop = GObject.MainLoop()
        self._pipeline = Gst.Pipeline()

        # Make elements.
        self._src = Gst.ElementFactory.make('appsrc', 'appsrc')
        decode = Gst.ElementFactory.make("decodebin", "decode")
        self._queueaudio = Gst.ElementFactory.make('queue', 'queueaudio')
        audioconvert = Gst.ElementFactory.make('audioconvert', 'audioconvert')
        sink = Gst.ElementFactory.make('alsasink', 'sink')

        self._src.set_property('stream-type', 'stream')

        # Add to pipeline.
        self._pipeline.add(self._src)
        self._pipeline.add(decode)
        self._pipeline.add(self._queueaudio)
        self._pipeline.add(audioconvert)
        self._pipeline.add(sink)

        # Link elements.
        self._src.link(decode)
        self._queueaudio.link(audioconvert)
        audioconvert.link(sink)
        decode.connect('pad-added', self._decode_src_created) 
开发者ID:happyleavesaoc,项目名称:python-snapcast,代码行数:28,代码来源:gstreamer.py

示例2: _create_main_pipeline

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [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: _on_eos

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def _on_eos(self, bus, msg):
        logger.info('%s: Pipeline received eos signal' % self.request_id)
        #self.decodebin.unlink(self.audioconvert)
        self.finish_request()
        if self.eos_handler:
            self.eos_handler[0](self.eos_handler[1]) 
开发者ID:alumae,项目名称:kaldi-gstreamer-server,代码行数:8,代码来源:decoder2.py

示例4: _on_eos

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def _on_eos(self, bus, msg):
        logger.info('%s: Pipeline received eos signal' % self.request_id)
        self.finish_request()
        if self.eos_handler:
            self.eos_handler[0](self.eos_handler[1]) 
开发者ID:alumae,项目名称:kaldi-gstreamer-server,代码行数:7,代码来源:decoder.py

示例5: init_request

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [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

示例6: __del__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def __del__(self):
		self._logger.info('Pipeline destroyed') 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:4,代码来源:base.py

示例7: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def __init__(self):
        self._pipeline = Gst.Pipeline()
        self.uri        = None
        self.filename   = None
        self.samplerate = 44100
        self.listen     = False 
开发者ID:tyiannak,项目名称:pyAudioAnalysis,代码行数:8,代码来源:recordRadio.py

示例8: main

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def main():
    """Change the speed of an audio file without changing its pitch."""

    parser = argparse.ArgumentParser(description=(
        "Change the speed of an audio file without changing its pitch."))
    parser.add_argument(
        '-s', '--speed', metavar="S", type=float, default=1.,
        help="Set the speed ratio (e.g 0.5 to play at half speed)")
    parser.add_argument(
        'input_filename', metavar='INPUT_FILENAME', type=str,
        help="The audio input file")
    parser.add_argument(
        'output_filename', metavar='OUTPUT_FILENAME', type=str,
        help="The audio output file")

    args = parser.parse_args()

    if not os.path.isfile(args.input_filename):
        parser.error(
            'The input file "{}" does not exist.'.format(args.input_filename))

    pipeline = Pipeline()
    pipeline.set_speed(args.speed)
    pipeline.set_src_uri('file:///' + os.path.realpath(args.input_filename))
    pipeline.save(args.output_filename)

    loop = GObject.MainLoop()
    loop.run() 
开发者ID:Muges,项目名称:audiotsm,代码行数:30,代码来源:audiotsmcli_gst.py

示例9: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def __init__(self, device, size, rotation, onFatalError, mainLoop, debugLevel):

		if not Gst.init_check(None):
			raise ImportError

		if debugLevel > 0:
			Gst.debug_set_active(True)
			Gst.debug_set_default_threshold(debugLevel)

		self._onFatalError = onFatalError
		self._mainLop = mainLoop

		self._toreDownAlready = False

		#pipeline control
		self._currentPipelineState = None
		self._pipelineStateCondition = Condition()
		## Make sure attach and detach operation wait for each other to complete ##
		self._photoBinAttachDetachLock = Lock()
		self._localVideoBinAttachDetachLock = Lock()
		###########################################################################

		self._pipeline = Gst.Pipeline()

		self._videoSrcBin = self._getVideoSrcBin(self._pipeline, device, size, rotation)
		self._videoEncBin = self._getVideoEncBin(size, rotation)
		self._photoCaptureBin = PhotoCaptureBin(self._onNoMorePhotos)
		self._localVideoBin = ImgVideoEncBin(size, rotation, self._onStopPhotoSeq)

		self._pipeline.add(self._videoEncBin.bin)
		self._pipeline.add(self._photoCaptureBin.bin)
		self._pipeline.add(self._localVideoBin.bin)

		self._bus = self._pipeline.get_bus()
		self._bus.set_flushing(True)

		self._busListener = BusListener(self._bus)
		self._busListener.addListener(Gst.MessageType.ERROR, self._onBusError)
		self._busListener.addListener(Gst.MessageType.EOS, self._onBusEos)
		self._busListener.addListener(Gst.MessageType.STATE_CHANGED, self._onBusStateChanged)
		self._busListener.addListener(Gst.MessageType.REQUEST_STATE, self._onRequestState)
		self._busListener.start() 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:44,代码来源:base.py

示例10: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import Pipeline [as 别名]
def __init__(self, filename, file=None):
        self._pipeline = Gst.Pipeline()

        if file:
            file.seek(0)
            self._file = tempfile.NamedTemporaryFile(buffering=False)
            self._file.write(file.read())
            filename = self._file.name

        # Create the major parts of the pipeline:
        self.filesrc = Gst.ElementFactory.make("filesrc", None)
        self.decoder = Gst.ElementFactory.make("decodebin", None)
        self.audio_converter = Gst.ElementFactory.make("audioconvert", None)
        self.sink = Gst.ElementFactory.make("appsink", None)
        if not all((self.filesrc, self.decoder, self.audio_converter, self.sink)):
            raise GStreamerDecodeException("Could not initialize GStreamer.")

        # Set callbacks for EOS and errors:
        self._pipeline.bus.add_signal_watch()
        self._pipeline.bus.connect("message::eos", self._message)
        self._pipeline.bus.connect("message::error", self._message)

        # Set the file path to load:
        self.filesrc.set_property("location", filename)

        # Set decoder callback handlers:
        self.decoder.connect("pad-added", self._pad_added)
        self.decoder.connect("no-more-pads", self._no_more_pads)
        self.decoder.connect("unknown-type", self._unknown_type)

        # Set the sink's capabilities and behavior:
        self.sink.set_property('caps', Gst.Caps.from_string('audio/x-raw,format=S16LE'))
        self.sink.set_property('drop', False)
        self.sink.set_property('sync', False)
        self.sink.set_property('max-buffers', 5)
        self.sink.set_property('emit-signals', True)
        # The callback to receive decoded data:
        self.sink.connect("new-sample", self._new_sample)

        # Add all components to the pipeline:
        self._pipeline.add(self.filesrc)
        self._pipeline.add(self.decoder)
        self._pipeline.add(self.audio_converter)
        self._pipeline.add(self.sink)
        # Link together necessary components:
        self.filesrc.link(self.decoder)
        self.audio_converter.link(self.sink)

        # Callback to notify once the sink is ready:
        self.caps_handler = self.sink.get_static_pad("sink").connect("notify::caps", self._notify_caps)

        # Set by callbacks:
        self._pads = False
        self._caps = False
        self._pipeline.set_state(Gst.State.PLAYING)
        self._queue = queue.Queue(5)
        self._finished = Event()
        # Wait until the is_ready event is set by a callback:
        self._is_ready = Event()
        if not self._is_ready.wait(timeout=1):
            raise GStreamerDecodeException('Initialization Error') 
开发者ID:pyglet,项目名称:pyglet,代码行数:63,代码来源:gstreamer.py


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