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


Python pygst.require函数代码示例

本文整理汇总了Python中pygst.require函数的典型用法代码示例。如果您正苦于以下问题:Python require函数的具体用法?Python require怎么用?Python require使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: cal2

def cal2(m=list()):
    # m=islem_yapan(veri)

    for i in m:
        s = i + ".mp3"

        import pygst

        pygst.require("0.10")

        import gst

        player = gst.Pipeline("player")
        source = gst.element_factory_make("filesrc", "file-source")
        decoder = gst.element_factory_make(
            "mad", "decoder"
        )  # mp3 formatı için decoder "mad", örneğin flac için "flacdec"...

        conv = gst.element_factory_make("audioconvert", "converter")
        sink = gst.element_factory_make(
            "autoaudiosink", "audio-output"
        )  # autoaudiosink yerine sistemin kullandığı ses aygıtı, örneğin "alsasink", "alsa-output" yazılabilir

        player.add(source, decoder, conv, sink)

        gst.element_link_many(source, decoder, conv, sink)

        player.get_by_name("file-source").set_property("location", s)  # aynı dizinde değilse tam yol yazılmalı
        player.set_state(gst.STATE_PLAYING)

        time.sleep(0.35)
        player.set_state(gst.STATE_NULL)
开发者ID:slymnkbdyi,项目名称:m2ses,代码行数:32,代码来源:m2ses.py

示例2: encode

    def encode(self):
        import pygst
        pygst.require('0.10')
        import gst

        self.encoder = gst.Pipeline('encoder')

        decodebin = gst.element_factory_make('uridecodebin', 'uridecodebin')
        uri = yield self.song.get_uri()
        decodebin.set_property('uri', uri)
        decodebin.connect('pad-added', self.on_new_pad)

        audioconvert = gst.element_factory_make('audioconvert', 'audioconvert')

        lame = gst.element_factory_make('lamemp3enc', 'lame')
        lame.set_property('quality', 1)

        sink = gst.element_factory_make('appsink', 'appsink')
        sink.set_property('emit-signals', True)
        sink.connect('new-buffer', self.data_ready)

        self.encoder.add(decodebin, audioconvert, lame, sink)
        gst.element_link_many(audioconvert, lame, sink)

        self.encoder.set_state(gst.STATE_PAUSED)

        bus = self.encoder.get_bus()
        bus.add_signal_watch()
        bus.connect('message', self.on_message)

        result = yield self.done
        defer.returnValue(result)
开发者ID:armooo,项目名称:jukebox,代码行数:32,代码来源:encoders.py

示例3: _check_libs

def _check_libs():
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk
        import gnome
        import gnome.ui
        gnome.ui.authentication_manager_init()
        import gconf
        import gobject
        gobject.threads_init()
        import gnomevfs
    except ImportError:
        print '%s needs pygtk and gnome-python >= 2.12!' % NAME
        sys.exit(1)

    try:
        import pygst
        pygst.require('0.10')
        import gst
    except ImportError:
        print '%s needs python-gstreamer 0.10!' % NAME
        sys.exit(1)

    print '  using Gstreamer version: %s' % (
            '.'.join([str(s) for s in gst.gst_version]))
开发者ID:BackupTheBerlios,项目名称:soundconverter-svn,代码行数:26,代码来源:soundconverter.py

示例4: checkTicket349

def checkTicket349():
    result = messages.Result()
    import pygst

    pygst.require("0.10")
    import gst

    if get_gst_version(gst) < (0, 10, 4, 1):
        major, minor, micro, nano = get_gst_version(gst)
        m = messages.Error(
            T_(N_("Version %d.%d.%d of the GStreamer library is too old.\n"), major, minor, micro), mid="ticket-349"
        )
        m.add(T_(N_("The '%s' component needs a newer version of '%s'.\n"), "looper", "gstreamer"))
        m.add(T_(N_("Please upgrade '%s' to version %s or later."), "gstreamer", "0.10.5"))
        result.add(m)

    if get_pygst_version(gst) < (0, 10, 3, 1):
        major, minor, micro, nano = get_pygst_version(gst)
        m = messages.Error(
            T_(N_("Version %d.%d.%d of the gst-python library is too old.\n"), major, minor, micro), mid="ticket-349"
        )
        m.add(T_(N_("The '%s' component needs a newer version of '%s'.\n"), "looper", "gst-python"))
        m.add(T_(N_("Please upgrade '%s' to version %s or later."), "gst-python", "0.10.4"))
        result.add(m)

    result.succeed(None)
    return defer.succeed(result)
开发者ID:sergiomb2,项目名称:flumotion,代码行数:27,代码来源:checks.py

示例5: import_gst0_10

def import_gst0_10():
    global gst_version, pygst_version
    import pygst
    pygst.require("0.10")
    try:
        #initializing gstreamer parses sys.argv
        #which interferes with our own command line arguments
        #so we temporarily replace them:
        saved_args = sys.argv
        sys.argv = sys.argv[:1]
        #now do the import with stderr redirection
        #to avoid gobject warnings:
        oldfd = redirect_stderr()
        import gst
        gst_version = gst.gst_version
        pygst_version = gst.pygst_version
        gst.new_buffer = gst.Buffer
        if not hasattr(gst, 'MESSAGE_STREAM_START'):
            #a None value is better than nothing:
            #(our code can assume it exists - just never matches)
            gst.MESSAGE_STREAM_START = None
        return gst
    finally:
        unredirect_stderr(oldfd)
        sys.argv = saved_args
开发者ID:svn2github,项目名称:Xpra,代码行数:25,代码来源:gstreamer_util.py

示例6: send_video

    def send_video(self, media, local_host, local_port, remote_host, remote_port):
        # inspired from http://blog.abourget.net/2009/6/14/gstreamer-rtp-and-live-streaming/
        # we send each stream on its own port pair


        import gobject, pygst
        pygst.require("0.10")
        import gst

        raise Exception("fixme: TODO send video on RTP/RTCP")
开发者ID:ddalex,项目名称:p9,代码行数:10,代码来源:webrtc.py

示例7: __init__

 def __init__(self, usage, description, domain):
     self.domain = domain
     BaseOP.__init__(self, usage=usage, description=description)
     if use_gst:
         try:
             import pygst
             pygst.require('0.10')
             import gstoption
             self.add_option_group(gstoption.get_group())
         except ImportError:
             pass
开发者ID:flyapen,项目名称:UgFlu,代码行数:11,代码来源:options.py

示例8: checkDependencies

    def checkDependencies(self):
        print ('Checking dependencies')
        try:
            import pygst
            pygst.require('0.10')
            import gst
        except ImportError:
            self.close('IMPORT_ERROR: Could not found the GStreamer Pythonbindings.\n'
                'You can download the installers at:\n'
                'http://www.gstreamer-winbuild.ylatuya.es')
        else:
            print ('GStreamer... OK')
     
        try:
            import pygtk
            pygtk.require('2.0')
            import gtk
            import gtk.gdk
            import gobject
        except ImportError:
                self.close('IMPORT_ERROR: Could not find the Gtk Python bindings.\n'
                    'You can download the installers at:\n'
                    'http://www.pygtk.org/\n'
                    'http://www.gtk.org/')
        else:
            print ('Gtk... OK')

        try:
            import gtk.glade
        except ImportError:
            self.close('IMPORT_ERROR: Could not find libglade in the system.\n'
                    'You can download the installers at:\n'
                    'http://sourceforge.net/projects/gladewin32/files/libglade-win32'
                    '/2.4.0/libglade-2.4.0-bin.zip/download')
        else:
            print ('libglade... OK')

        try:
            import goocanvas
        except ImportError:
            self.close('IMPORT_ERROR: Could not find the Goocanvas Python bindings.\n'
                    'You can download the intallers at:\n'
                    'http://ftp.gnome.org/pub/GNOME/binaries/win32/goocanvas/\n'
                    'http://sqlkit.argolinux.org/download/goocanvas.pyd')
        else:
            print ('goocanvas... OK')

        try:
            import zope.interface
        except:
            self.close('ERROR: Could not found Zope.Interface')
        else:
            print ('zope.interface... OK')
开发者ID:Mathieu69,项目名称:Pitivi_Gargamel,代码行数:53,代码来源:setup.py

示例9: __init__

    def __init__(self, config):
        """Initialize the speech components"""
        global gst
        global gobject

        import gobject
        import pygst
        pygst.require('0.10')
        import gst

        sys.stdout = None
        sys.stderr = None

        self.config = config
        self.active_plugin = None
        self.plugins = []
        for epoint in pkg_resources.iter_entry_points("mattd.plugins"):
            log.info("Loading plugin %r" % epoint.name)
            try:
                self.plugins.append(epoint.load()(self))
            except Exception as e:
                log.warn("%r failed.  %r" % (epoint.name, e))

        log.info("Loaded %i plugins." % len(self.plugins))

        one_second_in_nanoseconds = 1000000000

        def dict2properties(d):
            return " ".join([
                "%s=%s" % (k, str(v)) for k, v in d.items()
            ])

        vader_properties = {
            'name': 'vader',
            'auto-threshold': 'true',
            'run-length': one_second_in_nanoseconds,
            'pre-length': one_second_in_nanoseconds,
        }
        self.pipeline = gst.parse_launch(
            'gconfaudiosrc ! audioconvert ! audioresample '
            + '! vader %s ' % dict2properties(vader_properties)
            + '! pocketsphinx name=asr ! fakesink')
        asr = self.pipeline.get_by_name('asr')
        asr.connect('partial_result', self.asr_partial_result)
        asr.connect('result', self.asr_result)
        asr.set_property('configured', True)

        bus = self.pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect('message::application', self.application_message)

        self.pipeline.set_state(gst.STATE_PLAYING)
开发者ID:Mondego,项目名称:pyreco,代码行数:52,代码来源:allPythonContent.py

示例10: __init__

    def __init__(self, options, tmp_dir):
        self.options = options
        self.tmp_dir = tmp_dir
        self.frame_capture_padding = 0.5 * 1000000000

        # Import python gstreamer libraries
        global pygst, gst, gobject, threading, time
        import pygst
        pygst.require("0.10")
        import gst
        import gobject
        import threading
        import time

        # Create gstreamer player object
        self.player = gst.Pipeline("player")

        # File source and universal decoder
        filesrc = gst.element_factory_make("filesrc", "file-source")
        decoder = gst.element_factory_make("decodebin", "decoder")
        decoder.connect("new-decoded-pad", self.decoder_callback)

        # PNG encoder, Multiple File sink and colorspace converter required by PNG encoder
        colorspace = gst.element_factory_make("ffmpegcolorspace", "video-sink")
        pngenc = gst.element_factory_make("pngenc", "png-encoder")
        pngenc.set_property("snapshot", True)
        multifilesink = gst.element_factory_make("multifilesink", "multi-file-sink")
        multifilesink.set_property("location",
            os.path.join(self.tmp_dir, "output-%05d.png"))
        multifilesink.set_property("post-messages", True)

        # Add elements to player pipeline
        self.player.add(filesrc, decoder, colorspace, pngenc, multifilesink)
        gst.element_link_many(filesrc, decoder)
        gst.element_link_many(colorspace, pngenc, multifilesink)

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.connect("message", self.on_message)

        # Initialize gobject MainLoop in a new thread
        gobject.threads_init()
        self.main_loop = gobject.MainLoop()
        def main_loop_thread():
            self.main_loop.run()
        self.main_loop_thread = threading.Thread(target=main_loop_thread)
        self.main_loop_thread.daemon = True
        self.main_loop_thread.start()
开发者ID:bihicheng,项目名称:Video-Previewer,代码行数:48,代码来源:video_previewer.py

示例11: _deferred_imports

def _deferred_imports():
    # The GStreamer (or bulkio) modules may not be installed; defer imports
    # until creation of a SoundSink to report the error only when it's relevant
    try:
        import pygst
        pygst.require('0.10')
        import gst

        from bulkio.bulkioInterfaces import BULKIO__POA

        def _deferred_imports():
            pass

        globals().update(locals())
    except ImportError, e:
        raise RuntimeError("Missing required package for sandbox audio: '%s'" % e)
开发者ID:RedhawkSDR,项目名称:framework-core,代码行数:16,代码来源:audio.py

示例12: load_pygtk

def load_pygtk():
    try:
        import pygst
        pygst.require('0.10')
        import gst
    except Exception:
        import struct
        is64bit = len(struct.pack(b'P', 0)) == 8
        logging.info("Python arch: %d-bit" % (64 if is64bit else 32))
        gstroot = os.environ.get('GSTREAMER_SDK_ROOT_X86_64', r'C:\gstreamer-sdk\0.10\x64') \
                if is64bit \
                else os.environ.get('GSTREAMER_SDK_ROOT_X86', r'C:\gstreamer-sdk\0.10\x86')
        if not os.path.exists(gstroot):
            error("GStreamer not found",
                    "GStreamer was not found. It can be downloaded from http://www.gstreamer.com/\r\n\r\n" +
                    "See README.Windows for more information.")
        os.environ['PATH'] = gstroot + r'\bin;' + os.environ['PATH']
        gstpypath = gstroot + r'\lib\python2.7\site-packages'
        sys.path.insert(1, gstpypath)
        os.environ['PYTHONPATH'] = gstpypath
        try:
            import pygst
            pygst.require('0.10')
            import gst
        except Exception:
            error("GStreamer Python bindings not found",
                    "The Python bindings for GStreamer could not be imported. Please re-run the GStreamer installer and ensure that \"GStreamer python bindings\" is selected for installation (it should be selected by default).\r\n\r\n" +
                    "GStreamer can be downloaded from http://www.gstreamer.com/\r\n\r\n" +
                    "See README.Windows for more information.")
        else:
            logging.info("GStreamer: %s" % gstroot)
    else:
        logging.info("GStreamer works out of the box")

    try:
        import pygtk
        pygtk.require('2.0')
        import gtk
    except Exception:
        error("GTK/PyGTK not found",
                "PyGTK 2.x could not be imported. Please re-run the GStreamer installer and ensure that \"Gtk toolkit\" and \"Gtk python bindings\" are selected (they should be selected by default). Note that the PyGTK library from pygtk.org is NOT compatible with the GStreamer library from gstreamer.com.\r\n\r\n" +
                "GStreamer can be downloaded from http://www.gstreamer.com/\r\n\r\n" +
                "See README.Windows for more information.")
    else:
        logging.info("PyGTK works")
开发者ID:Twinters007,项目名称:FRC-2014,代码行数:45,代码来源:load_pygtk_windows.py

示例13: parse_arguments

def parse_arguments(args):
  regex = re.compile("^gstreamer\|([0-9])+\.([0-9]+)\|(.+)\|(.+)\|([a-z]+)-(.*)[|]?")
  requests = []
  xid = None
  gst_init = False
  major = 0
  minor = 0
  for arg in args:
    if arg[0:16] == "--transient-for=":
      try:
        xid = int(arg[16:])
      except:
        pass
      continue
    elif arg[0:2] == "--":
      continue

    match = regex.search(arg)
    if not match:
      continue
    try:
      r_major = int(match.group(1))
      r_minor = int(match.group(2))
      if not gst_init:
        import pygst
        pygst.require("%d.%d" % (r_major, r_minor))
        import gst
        gst_init = True
        major = r_major
        minor = r_minor
      elif r_major != major or r_minor != minor:
        return None
    except ValueError:
      continue

    if match.group(5) == "decoder" or match.group(5) == "encoder":
      try:
        requests.append(Request(major, minor, match.group(3), match.group(4), match.group(5), caps=gst.Caps(match.group(6))))
      except TypeError:
        continue
    elif match.group(5) == "urisource" or match.group(5) == "urisink" or match.group(5) == "element":
      requests.append(Request(major, minor, match.group(3), match.group(4), match.group(5), feature=match.group(6)))
    else:
      continue
  return (requests, xid)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:45,代码来源:Main.py

示例14: activate

	def activate (self, totem_object):
		"""Check for the availability of the flvdemux and souphttpsrc GStreamer plugins"""
		bvw_name = totem_object.get_video_widget_backend_name ()

		"""If the user's selected 1.5Mbps or greater as their connection speed, grab higher-quality videos
		   and drop the requirement for the flvdemux plugin."""
		self.gconf_client = gconf.client_get_default ()

		if bvw_name.find ("GStreamer") != -1:
			try:
				import pygst
				pygst.require ("0.10")
				import gst

				registry = gst.registry_get_default ()
				if registry.find_plugin ("soup") == None:
					"""This means an error will be displayed when they try to play anything"""
					self.gstreamer_plugins_present = False
			except ImportError:
				"""Do nothing; either it's using xine or python-gstreamer isn't installed"""

		"""Continue loading the plugin as before"""
		self.builder = self.load_interface ("youtube.ui", True, totem_object.get_main_window (), self)
		self.totem = totem_object

		self.search_entry = self.builder.get_object ("yt_search_entry")
		self.search_entry.connect ("activate", self.on_search_entry_activated)
		self.search_button = self.builder.get_object ("yt_search_button")
		self.search_button.connect ("clicked", self.on_search_button_clicked)
		self.progress_bar = self.builder.get_object ("yt_progress_bar")

		self.notebook = self.builder.get_object ("yt_notebook")
		self.notebook.connect ("switch-page", self.on_notebook_page_changed)

		self.notebook_pages = ["search", "related"]
		for page in self.notebook_pages:
			self.setup_treeview (page)
		self.current_treeview_name = "search"

		self.vbox = self.builder.get_object ("yt_vbox")
		self.vbox.show_all ()
		totem_object.add_sidebar_page ("youtube", _("YouTube"), self.vbox)

		"""Set up the service"""
		self.service = gdata.service.GDataService (account_type = "HOSTED_OR_GOOGLE", server = "gdata.youtube.com")
开发者ID:haniokasai,项目名称:netwalker-rootfs,代码行数:45,代码来源:youtube.py

示例15: _init_gst_version

def _init_gst_version(gst_majorminor):

    def tup2version(tup):
        return '.'.join(map(str, tup))

    if gst_majorminor not in GST_REQ:
        raise SystemExit('ERROR: Invalid FLU_GST_VERSION: %r (expected '
                         'one of %r)' % (gst_majorminor, GST_REQ.keys()))

    pygst_req = GST_REQ[gst_majorminor]['gst-python']
    gst_req = GST_REQ[gst_majorminor]['gstreamer']

    try:
        import pygst
        pygst.require(gst_majorminor)
        import gst
    except ImportError:
        return False
    except AssertionError:
        return False

    try:
        gst_version = gst.get_gst_version()
        pygst_version = gst.get_pygst_version()
    except AttributeError:
        # get_foo_version() added in 0.10.4, fall back
        gst_version = gst.gst_version
        pygst_version = gst.pygst_version

    if gst_req[:2] != gst_version[:2]:
        raise SystemExit(
            'ERROR: Expected GStreamer %s, but got incompatible %s'
            % (gst_majorminor, tup2version(gst_version[:2])))

    if gst_version < gst_req:
        raise SystemExit(
            'ERROR: GStreamer %s too old; install %s or newer'
            % (tup2version(gst_version), tup2version(gst_req)))

    if pygst_version < pygst_req:
        raise SystemExit(
            'ERROR: gst-python %s too old; install %s or newer'
            % (tup2version(pygst_version), tup2version(pygst_req)))

    return True
开发者ID:flyapen,项目名称:UgFlu,代码行数:45,代码来源:boot.py


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