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


Python Gst.init方法代码示例

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


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

示例1: main

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def main():

    global args
    args = argparser.parse_args()

    bluez = Bluez()

    adapt = bluez.getAdapter(args.adapter)

    if not adapt:
        print("Adapter " + args.adapter + " not found")
        return

    adapt.powerSet(True)
    adapt.discoverableSet(True)
    adapt.mediaEndpointRegisterSBC()
    if args.aac_enabled:
        adapt.mediaEndpointRegisterAAC()


    Gst.init(None)
    GObject.threads_init()
    mainloop = GObject.MainLoop()
    mainloop.run()
    return 
开发者ID:gmsoft-tuxicoman,项目名称:bt-audio,代码行数:27,代码来源:bt-audio.py

示例2: gCamera

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def gCamera():
    print "gstWebCam"
    bridge = CvBridge()
    video ="video4"
    pub = rospy.Publisher('stream', Image, queue_size=10)
    rospy.init_node('GstWebCam',anonymous=True)
    Gst.init(None)
    pipe = Gst.parse_launch("""v4l2src device=/dev/"""+video+""" ! video/x-raw, width=640, height=480,format=(string)BGR ! appsink sync=false max-buffers=2 drop=true name=sink emit-signals=true""")
    sink = pipe.get_by_name('sink')
    pipe.set_state(Gst.State.PLAYING)
    while not rospy.is_shutdown():
        sample = sink.emit('pull-sample')    
        img = gst_to_opencv(sample.get_buffer())
        try:
            pub.publish(bridge.cv2_to_imgmsg(img, "bgr8"))
        except CvBridgeError as e:
            print(e) 
开发者ID:DJTobias,项目名称:Cherry-Autonomous-Racecar,代码行数:19,代码来源:gCamera.py

示例3: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def __init__(self):
        GLib.threads_init()
        Gst.init(None)

        self.options = Options()

        year  = datetime.datetime.now().year
        month = datetime.datetime.now().month
        day   = datetime.datetime.now().day
        self.date = date(year, month, day)

        self._shrouk = None
        self._fajr = None
        self._zuhr = None
        self._asr = None
        self._maghrib = None
        self._isha = None
        self._nextprayer = ""
        self._tnprayer = 0
        self.dec = 0 
开发者ID:Jessewb786,项目名称:Silaty,代码行数:22,代码来源:prayertime.py

示例4: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def __init__(self, verbose=False):
        if not GI_GSTREAMER_INSTALLED:
            raise ValueError('pygobject library was not found')
        if not PIL_INSTALLED:
            raise ValueError('python-imaging library was not found')
        self.verbose = verbose
        Gst.init(None) 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:9,代码来源:video_maker.py

示例5: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def __init__(self):

        # init GStreamer
        Gst.init(None) 
开发者ID:encarsia,项目名称:gpt,代码行数:6,代码来源:modules.py

示例6: setup_config

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def setup_config(args):
    if ('c' in args and args['c'] is not None):
        brave.config.init(args['c'][0])
    else:
        brave.config.init() 
开发者ID:bbc,项目名称:brave,代码行数:7,代码来源:brave.py

示例7: start_brave

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def start_brave():
    session = brave.session.init()

    def start_rest_api_in_separate_thread():
        try:
            brave.api.RestApi(session)
        except Exception as e:
            print('Cannot start Rest API:', e)
            run_on_master_thread_when_idle(session.end)

    threading.Thread(target=start_rest_api_in_separate_thread, name='api-thread', daemon=True).start()

    def keyboard_exit(signal, frame):
        print("Received keyboard interrupt to exit, so tidying up...")
        session.end()

    signal.signal(signal.SIGINT, keyboard_exit)
    session.start() 
开发者ID:bbc,项目名称:brave,代码行数:20,代码来源:brave.py

示例8: init

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def init():
    Gst.init(None)
    global singleton
    singleton = Session()
    return singleton 
开发者ID:bbc,项目名称:brave,代码行数:7,代码来源:session.py

示例9: assert_valid_output_file

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def assert_valid_output_file(output_video_location):
    '''
    Given a file, validates it is a video (mp4) file
    '''
    import gi
    gi.require_version('Gst', '1.0')
    from gi.repository import Gst, GLib

    Gst.init(None)
    mainloop = GLib.MainLoop()

    # We create a pipeline so that we can read the file and check it:
    pipeline = Gst.ElementFactory.make("playbin")
    pipeline.set_property('uri','file://'+output_video_location)
    playsink = pipeline.get_by_name('playsink')
    playsink.set_property('video-sink', Gst.ElementFactory.make('fakesink'))
    pipeline.set_state(Gst.State.PAUSED)

    def after_a_second():
        assert pipeline.get_state(0).state == Gst.State.PAUSED
        element = pipeline.get_by_name('inputselector1')
        caps = element.get_static_pad('src').get_current_caps()
        assert caps.to_string() == 'audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)48000, channels=(int)2, channel-mask=(bitmask)0x0000000000000003'

        element = pipeline.get_by_name('inputselector0')
        caps = element.get_static_pad('src').get_current_caps()
        assert caps.to_string() == 'video/x-raw, format=(string)NV12, width=(int)640, height=(int)360, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1'

        pipeline.set_state(Gst.State.NULL)
        mainloop.quit()

    GLib.timeout_add(1000, after_a_second)
    mainloop.run() 
开发者ID:bbc,项目名称:brave,代码行数:35,代码来源:test_file_output.py

示例10: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def __init__(self, identifier, config, model_manager, request, finished_callback):
        # TODO: refactor as abstract interface
        # pylint: disable=super-init-not-called
        self.config = config
        self.identifier = identifier
        self.pipeline = None
        self.template = config['template']
        self.models = model_manager.models
        self.model_manager = model_manager
        self.request = request
        self.state = Pipeline.State.QUEUED
        self.frame_count = 0
        self.start_time = None
        self.stop_time = None
        self.avg_fps = 0
        self._gst_launch_string = None
        self.latency_times = dict()
        self.sum_pipeline_latency = 0
        self.count_pipeline_latency = 0
        self._real_base = None
        self._stream_base = None
        self._year_base = None
        self._month_base = None
        self._day_base = None
        self._dir_name = None
        self._bus_connection_id = None
        self._create_delete_lock = Lock()
        self._finished_callback = finished_callback
        if (not GStreamerPipeline._mainloop):
            GStreamerPipeline._mainloop_thread = Thread(
                target=GStreamerPipeline.gobject_mainloop)
            GStreamerPipeline._mainloop_thread.start() 
开发者ID:intel,项目名称:video-analytics-serving,代码行数:34,代码来源:gstreamer_pipeline.py

示例11: main

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def main():
    if dbus.SessionBus().request_name(
        'es.atareao.PomodoroIndicator') !=\
            dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        print("application already running")
        exit(0)
    GObject.threads_init()
    Gst.init(None)
    Gst.init_check(None)
    Notify.init('pomodoro-indicator')
    Pomodoro_Indicator()
    Gtk.main() 
开发者ID:atareao,项目名称:pomodoro-indicator,代码行数:14,代码来源:pomodoro_indicator.py

示例12: __init__

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def __init__(self):
        Gst.init(None)
        self._glib_loop = GLibMainLoopThread() 
开发者ID:pyglet,项目名称:pyglet,代码行数:5,代码来源:gstreamer.py

示例13: _playsoundNix

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def _playsoundNix(sound, block=True):
    """Play a sound using GStreamer.

    Inspired by this:
    https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html
    """
    if not block:
        raise NotImplementedError(
            "block=False cannot be used on this platform yet")

    # pathname2url escapes non-URL-safe characters
    import os
    try:
        from urllib.request import pathname2url
    except ImportError:
        # python 2
        from urllib import pathname2url

    import gi
    gi.require_version('Gst', '1.0')
    from gi.repository import Gst

    Gst.init(None)

    playbin = Gst.ElementFactory.make('playbin', 'playbin')
    if sound.startswith(('http://', 'https://')):
        playbin.props.uri = sound
    else:
        playbin.props.uri = 'file://' + pathname2url(os.path.abspath(sound))

    set_result = playbin.set_state(Gst.State.PLAYING)
    if set_result != Gst.StateChangeReturn.ASYNC:
        raise PlaysoundException(
            "playbin.set_state returned " + repr(set_result))

    # FIXME: use some other bus method than poll() with block=False
    # https://lazka.github.io/pgi-docs/#Gst-1.0/classes/Bus.html
    bus = playbin.get_bus()
    bus.poll(Gst.MessageType.EOS, Gst.CLOCK_TIME_NONE)
    playbin.set_state(Gst.State.NULL) 
开发者ID:pnprog,项目名称:goreviewpartner,代码行数:42,代码来源:playsound.py

示例14: setup_backend

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def setup_backend(cls, gst_opts = []):
        """ Prepare/check the Gst backend.

        Returns:
            `str`: the version of Gst used by the backend
        """
        Gst.init(gst_opts)

        return Gst.version_string() 
开发者ID:Cimbali,项目名称:pympress,代码行数:11,代码来源:gst_backend.py

示例15: notify

# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import init [as 别名]
def notify(self, title, message, play_audio = False, current_prayer = ''):
        Notify.init("Silaty")
        notif = Notify.Notification.new(title, message)
        icon = GdkPixbuf.Pixbuf.new_from_file(os.path.dirname(os.path.realpath(__file__)) + "/icons/hicolor/128x128/apps/silaty.svg")
        notif.set_icon_from_pixbuf(icon)

        if play_audio:
            if current_prayer == 'Fajr':
                uri = "file://" + os.path.dirname(os.path.realpath(__file__)) + "/audio/Fajr/" + self.options.fajr_adhan + ".ogg"
                self.fajrplayer = Gst.ElementFactory.make("playbin", "player")
                fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
                self.fajrplayer.set_property('uri', uri)
                self.fajrplayer.set_property("video-sink", fakesink)
                self.fajrplayer.set_state(Gst.State.PLAYING)
            else:
                uri = "file://" + os.path.dirname(os.path.realpath(__file__)) + "/audio/Normal/" + self.options.normal_adhan + ".ogg"
                self.normalplayer = Gst.ElementFactory.make("playbin", "player")
                fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
                self.normalplayer.set_property('uri', uri)
                self.normalplayer.set_property("video-sink", fakesink)
                self.normalplayer.set_state(Gst.State.PLAYING)

        notif.set_app_name('Silaty')
        notif.show() 
开发者ID:Jessewb786,项目名称:Silaty,代码行数:26,代码来源:prayertime.py


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