def pipe_set(cam_id): loop = GObject.MainLoop() GObject.threads_init() Gst.init(None) Gst.segtrap_set_enabled(False) pipe = Gst.parse_launch(""" rtmpsrc location=rtmp://127.0.0.1:5935/live/""" + str(cam_id) + """ ! queue ! flvdemux name=demuxer demuxer.video ! queue ! decodebin ! tee name=t t. ! queue ! videoconvert ! video/x-raw,format=BGR ! appsink name=sink """) return pipe
def __init__ (self, volume=None): """ Class initialiser """ global GObject, Gst # super class inits super().__init__(volume) # GStreamer1.0 support import gi gi.require_version("Gst", "1.0") from gi.repository import GObject, Gst # mandatory inits GObject.threads_init() Gst.init() # this disables Gst's weird SIGSEGV communication maechanism # see http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-Gst.html#gst-segtrap-set-enabled # for more detail Gst.segtrap_set_enabled(False) # get audio player self.player = Gst.ElementFactory.make("playbin") self.set_volume(volume) # debugging session tron("audio player init'ed OK.")
def start(self, params = None, last_return = None): """ Starts the GStreamer process und underlying library if applicable. :param params: Parameter specified :param last_return: The return value from the last hook called. :since: v0.2.00 """ with self._instance_lock: if (self._glib_mainloop is None): self._glib_mainloop = GLib.get_mainloop_instance() # with Gstreamer._lock: if (not Gst.is_initialized()): Gst.segtrap_set_enabled(False) Gst.Registry.fork_set_enabled(False) if (not Gst.init_check(sys.argv)): raise IOException("GStreamer initialization failed") gst_version = Gst.version_string() if (self.log_handler is not None): self.log_handler.debug("#echo(__FILEPATH__)# -{0!r}.__init__()- reporting: {1} ready", self, gst_version, context = "pas_gapi_gstreamer")
#!/usr/bin/env python3 import gi gi.require_version('Gst', '1.0') from gi.repository import GObject, Gst loop = GObject.MainLoop() GObject.threads_init() Gst.init() Gst.segtrap_set_enabled(False) class Passthrough(Gst.Element): __gstmetadata__ = ("Passthrough element", "element.py", "Proxy buffers", "Andrew Cook <*****@*****.**>") _src_template = Gst.PadTemplate.new('src', Gst.PadDirection.SRC, Gst.PadPresence.ALWAYS, Gst.caps_from_string('ANY')) _sink_template = Gst.PadTemplate.new('sink', Gst.PadDirection.SINK, Gst.PadPresence.ALWAYS, Gst.caps_from_string('ANY')) _gsttemplates = ( _src_template, _sink_template, ) def __init__(self):