Python gi.repository.Gst.init() Examples
The following are 21
code examples of gi.repository.Gst.init().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gst
, or try the search function
.
Example #1
Source File: bt-audio.py From bt-audio with GNU General Public License v3.0 | 7 votes |
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
Example #2
Source File: gCamera.py From Cherry-Autonomous-Racecar with MIT License | 7 votes |
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)
Example #3
Source File: prayertime.py From Silaty with GNU General Public License v3.0 | 7 votes |
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
Example #4
Source File: video_maker.py From avocado-vt with GNU General Public License v2.0 | 6 votes |
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)
Example #5
Source File: modules.py From gpt with GNU General Public License v3.0 | 6 votes |
def __init__(self): # init GStreamer Gst.init(None)
Example #6
Source File: brave.py From brave with Apache License 2.0 | 6 votes |
def setup_config(args): if ('c' in args and args['c'] is not None): brave.config.init(args['c'][0]) else: brave.config.init()
Example #7
Source File: brave.py From brave with Apache License 2.0 | 6 votes |
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()
Example #8
Source File: test_file_output.py From brave with Apache License 2.0 | 6 votes |
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()
Example #9
Source File: video.py From avocado-virt with GNU General Public License v2.0 | 5 votes |
def __init__(self, params, verbose=False): self.verbose = verbose self.params = params Gst.init(None)
Example #10
Source File: playsound.py From playsound with MIT License | 5 votes |
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)
Example #11
Source File: gstfunctions.py From tapas with GNU General Public License v2.0 | 5 votes |
def gst_init(): from twisted.internet import gireactor as reactor reactor.install() import gi gi.require_version('Gst', '1.0') from gi.repository import GObject, Gst GObject.threads_init() Gst.init(None)
Example #12
Source File: seek.py From gstreamer-python-player with MIT License | 5 votes |
def __init__(self): #constructing the window and setting up its size, and the destroy signal super(SeekingExample, self).__init__() self.set_size_request(600, 50) self.set_title("Simple audio player") self.connect("destroy", self.on_destroy) Gst.init() #setting up the playbin elements self.playbin = Gst.ElementFactory.make("playbin", "playbin") self.playbin.set_property("uri", "file:///tmp/lea.mp3") #setting up a simple Horizontal box layout, with a window size of 500 self.box = Gtk.Box(orientation = Gtk.Orientation.HORIZONTAL) self.add(self.box) #setting up controls with their signals and callbacks self.play_button = Gtk.Button.new_from_stock(Gtk.STOCK_MEDIA_PLAY) self.play_button.connect("clicked", self.on_play) self.pause_button = Gtk.Button.new_from_stock(Gtk.STOCK_MEDIA_PAUSE) self.pause_button.connect("clicked", self.on_pause) #creating a slider and calculating its range self.slider = Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL, 0, 100, 0.5) self.slider_handler_id = self.slider.connect("value-changed", self.on_slider_seek) #adding the controls to the layout self.box.pack_start(self.play_button, False, False, 2) self.box.pack_start(self.pause_button, False, False, 2) self.box.pack_start(self.slider, True, True, 2) #showing the GUI elements self.show_all()
Example #13
Source File: silaty.py From Silaty with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent): Gtk.Window.__init__(self) GLib.threads_init() Gst.init(None) # Set parent widget self.parent = parent self.lock_location_updates = False # Init dialog self.dialog = None # Tweak window self.set_decorated(True) self.set_icon_name('silaty') self.set_modal(True) self.set_resizable(False) self.set_position(Gtk.WindowPosition.CENTER) self.connect('delete-event', self.hide_window) #self.set_default_size(429, 440) self.headerbar = Gtk.HeaderBar() # Set up mainbox self.mainbox = Gtk.Box() self.mainbox.set_orientation(Gtk.Orientation.HORIZONTAL) self.prayertimes = Prayertime() self.prayertimes.calculate() #self.prayertimes.notify('Title', 'This is a test.') # Set language set_language(self.prayertimes.options.language) if self.prayertimes.options.language == 'Arabic': #self.set_gravity(Gdk.Gravity.NORTH_EAST) #self.set_direction(Gtk.TextDirection.RTL) Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL) # Set layout self.set_layout() if self.prayertimes.options.start_minimized == False: self.show_all() self.sidebar.emit("window-shown")
Example #14
Source File: prayertime.py From Silaty with GNU General Public License v3.0 | 5 votes |
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()
Example #15
Source File: gst_backend.py From pympress with GNU General Public License v2.0 | 5 votes |
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()
Example #16
Source File: playsound.py From goreviewpartner with GNU General Public License v3.0 | 5 votes |
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)
Example #17
Source File: gstreamer.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): Gst.init(None) self._glib_loop = GLibMainLoopThread()
Example #18
Source File: pomodoro_indicator.py From pomodoro-indicator with GNU General Public License v3.0 | 5 votes |
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()
Example #19
Source File: gstreamer_pipeline.py From video-analytics-serving with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()
Example #20
Source File: session.py From brave with Apache License 2.0 | 5 votes |
def init(): Gst.init(None) global singleton singleton = Session() return singleton
Example #21
Source File: gst-player.py From streamlink with BSD 2-Clause "Simplified" License | 4 votes |
def main(): if len(sys.argv) < 3: exit("Usage: {0} <url> <quality>".format(sys.argv[0])) # Initialize and check GStreamer version gi.require_version("Gst", "1.0") gobject.threads_init() gst.init(None) # Collect arguments url = sys.argv[1] quality = sys.argv[2] # Create the Streamlink session streamlink = Streamlink() # Enable logging streamlink.set_loglevel("info") streamlink.set_logoutput(sys.stdout) # Attempt to fetch streams try: streams = streamlink.streams(url) except NoPluginError: exit("Streamlink is unable to handle the URL '{0}'".format(url)) except PluginError as err: exit("Plugin error: {0}".format(err)) if not streams: exit("No streams found on URL '{0}'".format(url)) # Look for specified stream if quality not in streams: exit("Unable to find '{0}' stream on URL '{1}'".format(quality, url)) # We found the stream stream = streams[quality] # Create the player and start playback player = StreamlinkPlayer() # Blocks until playback is done player.play(stream)