def _build_gst_pipeline(self): log.debug("Building new gstreamer pipeline") pipeline_args = self._get_pipeline_args() log.debug("Initializing gstreamer pipeline") self.gst_pipeline = Gst.parse_launch(pipeline_args) self.gst_video_source = self.gst_pipeline.get_by_name('source') self.gst_video_source.props.uri = self.source.uri self.gst_video_source_connect_id = self.gst_video_source.connect( 'autoplug-continue', self.on_autoplug_continue) assert self.gst_video_source_connect_id self.gst_queue0 = self.gst_pipeline.get_by_name('queue0') self.gst_vconvert = self.gst_pipeline.get_by_name('vconvert') self.gst_queue1 = self.gst_pipeline.get_by_name('queue1') self.gst_appsink = self.gst_pipeline.get_by_name('appsink') log.debug("appsink: %s", str(self.gst_appsink)) log.debug("appsink will emit signals: %s", self.gst_appsink.props.emit_signals) # register to receive new image sample events from gst self._gst_appsink_connect_id = self.gst_appsink.connect( 'new-sample', self.on_new_sample) self.mainloop = GObject.MainLoop() if log.getEffectiveLevel() <= logging.DEBUG: # set Gst debug log level Gst.debug_set_active(True) Gst.debug_set_default_threshold(3) # Set up a pipeline bus watch to catch errors. self.gst_bus = self.gst_pipeline.get_bus() self.gst_bus.add_signal_watch() self.gst_bus.connect('message', self.on_bus_message, self.mainloop)
def __init__(self, verbose=False, clockrate=90000): ''' gst-launch -e appsrc ! rtph264depay ! h264parse ! mp4mux ! filesink location=file.mp4 ''' # TODO check if gst initiated Gst.init(None) Gst.debug_set_active(True) #Gst.debug_set_default_threshold(Gst.DebugLevel.MEMDUMP) Gst.debug_set_default_threshold(Gst.DebugLevel.LOG) Gst.debug_set_colored(False) # config params self.clockrate = clockrate self.verbose = verbose # GST modules self.rtpfeed = None self.mediafeed = None self.codecfeed = None self.mp4feed = None self.filefeed = None # Pipeline self.pipeline = None # Video Frames self.payloads = deque() self.feedcount = 0 self.payloadcount = 0
def __init__(self): Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(2) self.data = CustomData() self.data.pipeline = Gst.parse_launch( 'playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm' ) bus = self.data.pipeline.get_bus() ret = self.data.pipeline.set_state(Gst.State.PLAYING) if ret == Gst.StateChangeReturn.FAILURE: print('ERROR: Unable to set the pipeline to the playing state.') sys.exit(-1) elif ret == Gst.StateChangeReturn.NO_PREROLL: self.data.is_live = True self.data.main_loop = GLib.MainLoop.new(None, False) bus.add_signal_watch() bus.connect('message', self.cb_message, self.data) self.data.main_loop.run()
def main(): # Standard GStreamer initialization Gst.debug_set_active(True) Gst.debug_set_default_threshold(4) GObject.threads_init() Gst.init(None) pipeline = Gst.Pipeline() source = create_element_or_error("nvarguscamerasrc", "camera-source") sink = create_element_or_error("nvoverlaysink", "overlay") source.set_property('sensor-id', 0) pipeline.add(source) pipeline.add(sink) source.link(sink) loop = GObject.MainLoop() bus = pipeline.get_bus() bus.add_signal_watch() bus.connect("message", bus_call, loop) pipeline.set_state(Gst.State.PLAYING) try: loop.run() except: pass # Cleanup pipeline.set_state(Gst.State.NULL)
def __init__(self, uri, moviewindow): Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(2) self.video_width = 1920 self.video_height = 1080 self.crop_left = 900 self.crop_right = 20 self.crop_bottom = 20 self.crop_top = 20 # self.inFileLocation = "../../../media/webos.mp4" self.inFileLocation = "/home/kemal/Developer/vdwll/media/brbad.mp4" # "/../../../media/pixar.mp4" # self.uri = "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm" # self.uri = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov" # self.uri = "rtsp://127.0.0.1:8554/test" # self.uri = "rtsp://192.168.1.32:5540/ch0" # self.uri = "http://192.168.1.32:8080/playlist.m3u" self.uri = uri self.constructPipeline() self.is_playing = False self.connectSignals()
def gst_debug(level): """Sets Gstreamer debug output Args: level : Gstreamer debug level. """ if level: Gst.debug_set_active(True) Gst.debug_set_default_threshold(level)
def create_pipeline(self): Gst.init(None) Gst.debug_set_active(True) self.source = Gst.ElementFactory.make("playbin", "player") self.sink = Gst.ElementFactory.make("gtksink", "fakesink") self.source.set_property("video-sink", self.sink) self.viewer = self.sink.get_property("widget") self.box_player.pack_start(self.viewer, True, True, 0) #self.box_player.reorder_child(viewer, 0) self.viewer.show()
def setup_gstreamer(self): # Setup GStreamer Gst.init(None) Gst.init_check(None) print Gst.version_string(), Gst.version() Gst.debug_set_active(True) Gst.debug_print_stack_trace() # If activated, debugging messages are sent to the debugging handlers. """
def setup_gstreamer(self): # Setup GStreamer Gst.init(None) Gst.init_check(None) print Gst.version_string(), Gst.version() Gst.debug_set_active(True) Gst.debug_print_stack_trace( ) # If activated, debugging messages are sent to the debugging handlers. """
def init(): try: assert os.environ.get("GST_DEBUG_DUMP_DOT_DIR", None) except (NameError, AssertionError): os.environ["GST_DEBUG_DUMP_DOT_DIR"] = os.getcwd() GObject.threads_init() Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_colored(True) Gst.debug_set_default_threshold(Gst.DebugLevel.WARNING)
def init(): try: assert os.environ.get('GST_DEBUG_DUMP_DOT_DIR', None) except (NameError, AssertionError): os.environ['GST_DEBUG_DUMP_DOT_DIR'] = os.getcwd() GObject.threads_init() Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_colored(True) Gst.debug_set_default_threshold(Gst.DebugLevel.WARNING)
def __init__(self, rtsp_uri=None, moviewindow=None, video_width=1920, video_height=1080, crop_left=0, crop_right=0, crop_bottom=0, crop_top=0): Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(2) self.data = CustomData() self.video_width = video_width self.video_height = video_height self.crop_left = crop_left self.crop_right = crop_right self.crop_bottom = crop_bottom self.crop_top = crop_top self.uri = rtsp_uri self.moviewindow = moviewindow self.player = None self.uridecodebin = None self.data.pipeline = Gst.ElementFactory.make("playbin", "playbin") # Initialize audio pipeline elements self.audioconvert = None self.queue2 = None self.audiosink = None # Initialize video pipeline elements self.autoconvert = None self.videosink = None self.capsfilter = None self.videoscale = None self.colorspace = None self.queue1 = None self.videobox = None self.construct_pipeline() self.is_playing = False self.connect_signals() bus = self.data.pipeline.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() bus.connect('message', self.cb_message, self.data) bus.connect("sync-message::element", self.on_sync_message_playbin)
def _setup_gstreamer(self): Gst.init() # Setup the Debug mode for GStreamer Gst.debug_set_active(False) Gst.debug_set_default_threshold(3) import platform if(platform.machine() == 'x86_64'): # If there is PC self._init_audio_pub_stream() else: # If there is raspberry Pi self._init_audio_rec_stream()
def _setup_gstreamer(self): Gst.init() # Setup the Debug mode for GStreamer Gst.debug_set_active(False) Gst.debug_set_default_threshold(3) import platform if (platform.machine() == 'x86_64'): # If there is PC self._init_audio_pub_stream() else: # If there is raspberry Pi self._init_audio_rec_stream()
def __init__(self, uri, moviewindow, width, height): Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(2) self.width = 0 # source olarak gelen videonun pixel olarak genişliği self.height = 0 # source olarak gelen videonun pixel olarak yüksekliği self.data = CustomData() self.uri = uri self.movie_window = moviewindow self.data.pipeline = Gst.ElementFactory.make("playbin", "playbin") self.data.pipeline.set_property("uri", self.uri) self.construct_mod_queue(video_width=width, video_height=height) # rtspsrc kullanırsan aşağıdaki gibi : # self.data.pipeline = Gst.parse_launch( # "rtspsrc location={} latency=500 timeout=18446744073709551 tcp-timeout=18446744073709551 ! decodebin ! autovideosink".format(self.uri)) self.streams_list = [ ] # streamleri analiz etmek için kullanmış ama bizde bir anlamı yok. bus = self.data.pipeline.get_bus() ret = self.data.pipeline.set_state(Gst.State.PLAYING) if ret == Gst.StateChangeReturn.FAILURE: print('ERROR: Unable to set the pipeline to the playing state.') sys.exit(-1) elif ret == Gst.StateChangeReturn.NO_PREROLL: print("Buffer oluşturmayacağız data live data...") self.data.is_live = True bus.add_signal_watch() bus.enable_sync_message_emission() bus.connect('message', self.cb_message, self.data) # bunu yapınca bus.connect("sync-message::element", self.on_sync_message) # connect to interesting signals in playbin self.data.pipeline.connect("video-tags-changed", self.on_tags_changed) self.data.pipeline.connect("audio-tags-changed", self.on_tags_changed) self.data.pipeline.connect("text-tags-changed", self.on_tags_changed)
def main(): Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(3) glib_loop = GLib.MainLoop() dbus_loop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) app = application.VideoStreamerServerApplication(sys.argv) session_bus = dbus.SessionBus() if session_bus.request_name(vstreamer_utils.DBUS_NAME ) != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER: app.logger.error("Application already running") return 1 server_controller = server.ServerController(session_bus) server_controller.start() return app.exec_()
def __init__(self, rtsp_uri=None, moviewindow=None, video_width=1920, video_height=1080, crop_left=0, crop_right=0, crop_bottom=0, crop_top=0): Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(2) self.data = CustomData() self.video_width = video_width self.video_height = video_height self.crop_left = crop_left self.crop_right = crop_right self.crop_bottom = crop_bottom self.crop_top = crop_top self.uri = uri self.player = None self.uridecodebin = None # Initialize audio pipeline elements self.audioconvert = None self.queue2 = None self.audiosink = None # Initialize video pipeline elements self.autoconvert = None self.videosink = None self.capsfilter = None self.videoscale = None self.colorspace = None self.queue1 = None self.videobox = None self.construct_pipeline() self.is_playing = False self.connect_signals()
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()
def run(self): self.logger.info("Starting maverick-visiond") if 'debug' in self.config.args and self.config.args.debug: Gst.debug_set_active(True) Gst.debug_set_default_threshold(self.config.args.debug) if 'retry' not in self.config.args or not self.config.args.retry: self.retry = 30 else: self.retry = float(self.config.args.retry) # Start the zeroconf thread if self.config.args.zeroconf: self.zeroconf = StreamAdvert(self.config) self.zeroconf.start() else: self.zeroconf = None self.janus = JanusInterface(self.config, self.zeroconf) self.janus.start() # Start the pipeline. Trap any errors and wait for 30sec before trying again. while not self._should_shutdown: try: if 'pipeline_override' in self.config.args and self.config.args.pipeline_override: self.logger.info("pipeline_override set, constructing manual pipeline") self.manualconstruct() else: self.logger.info("pipeline_override is not set, auto-constructing pipeline") self.autoconstruct() except ValueError as e: self.logger.critical("Error constructing pipeline: {}, retrying in {} sec".format(repr(e), self.retry)) # Inform systemd that start is complete #self.logger.info("Notifying systemd of startup failure") #self.notify.notify("ERRNO=1") #self.notify.notify("STATUS=Error constructing pipeline: {}".format(repr(e))) self.logger.info("Notifying systemd of startup completion") self.notify.notify("READY=1") self.notify.notify("STATUS=Manual Pipeline Initialisation Complete") sys.exit(0)
def main(): Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(5) gui = Application() # create a pyro daemon with object daemon = Pyro4.Daemon(host=IP) obj = RemoteCommander(gui) ns = Pyro4.locateNS() uri = daemon.register(obj) ns.register(IP, uri) gui.install_pyro_event_callback(daemon) urimsg = "Pyro object uri = {0}".format(uri) print(urimsg) GObject.threads_init() exitStatus = gui.run(sys.argv) sys.exit(exitStatus)
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() self._photoBinAttachDetachLock = Lock() #Make sure attach and detach operation wait for each other to complete 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._pipeline.add(self._videoEncBin.bin) self._pipeline.add(self._photoCaptureBin.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()
import numpy as np from datetime import datetime import time import pathlib from glob import glob # Setting GST_DEBUG_DUMP_DOT_DIR environment variable enables us to have a # dotfile generated. The environment variable cannot be set inside the class. os.environ["GST_DEBUG_DUMP_DOT_DIR"] = "/tmp" # GStreamer imports import gi gi.require_version('Gst', '1.0') gi.require_version('GstPbutils', '1.0') #gi.require_version('Gtk', '3.0') from gi.repository import GObject, Gst Gst.init(None) Gst.debug_set_active(False) Gst.debug_set_default_threshold(0) from gi.repository import GstPbutils #GObject.threads_init() def list_connected_cameras(): """ Returns a list of connected video devices. """ return glob('/dev/video*') def get_file_info(fname, verbose=False): """ Gets info from video file. See:
return 0 def check_plugins(needed): missing = list(filter(lambda p: Gst.Registry.get().find_plugin(p) is None, needed)) if len(missing): print('Missing gstreamer plugins:', missing) return False return True WSS="wss://wss.vdo.ninja:443" if __name__=='__main__': Gst.init(None) Gst.debug_set_active(False) ## disable logging to help reduce CPU load? Gst.debug_set_default_threshold(0) error = False parser = argparse.ArgumentParser() parser.add_argument('--streamid', type=str, default=str(random.randint(1000000,9999999)), help='Stream ID of the peer to connect to') parser.add_argument('--room', type=str, default=None, help='optional - Room name of the peer to join') parser.add_argument('--server', type=str, default=None, help='Handshake server to use, eg: "wss://wss.vdo.ninja:443"') parser.add_argument('--bitrate', type=int, default=4000, help='Sets the video bitrate; kbps. This is not adaptive, so packet loss and insufficient bandwidth will cause frame loss') parser.add_argument('--audiobitrate', type=int, default=64, help='Sets the audio bitrate; kbps.') parser.add_argument('--width', type=int, default=1920, help='Sets the video width. Make sure that your input supports it.') parser.add_argument('--height', type=int, default=1080, help='Sets the video height. Make sure that your input supports it.') parser.add_argument('--framerate', type=int, default=30, help='Sets the video framerate. Make sure that your input supports it.') parser.add_argument('--test', action='store_true', help='Use test sources.') parser.add_argument('--hdmi', action='store_true', help='Try to setup a HDMI dongle') parser.add_argument('--v4l2',type=str, default='/dev/video0', help='Sets the V4L2 input device.')
""" GObject.threads_init() gst.init(None) if len(sys.argv) > 2: print "#ERROR: Máximo un argumento" print "Use --help para más informacion" sys.exit() elif len(sys.argv) == 2: if sys.argv[1] == '--help': print "Si quiere activar las trazas del programa use los siguientes argumentos:" print "--DEBUG=G -> Para activar las trazas de GStreamer" sys.exit() elif sys.argv[1] == '--DEBUG=G': gst.debug_set_active(True) gst.debug_set_default_threshold(3) else: print "#ERROR: Argumento no valido" sys.exit() # s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # s.connect(("gmail.com", 80)) # mutant_ip, port = s.getsockname() netif = raw_input("Indica la interfaz de red que va a usar: ") netifaces.ifaddresses(netif) mutant_ip = netifaces.ifaddresses(netif)[netifaces.AF_INET][0]['addr'] app = mutantGUI() app.title("Mutante de Cerebro") app.mainloop()
def _set_gst_debug_level(self): if log.getEffectiveLevel() <= logging.INFO: # set Gst debug log level Gst.debug_set_active(True) Gst.debug_set_default_threshold(3)
from datetime import datetime import gi gi.require_version('Gtk', '3.0') gi.require_version('Gst', '1.0') gi.require_version('GstWebRTC', '1.0') from gi.repository import GstWebRTC gi.require_version('GstSdp', '1.0') from gi.repository import GstSdp from gi.repository import Gtk, Gst, GObject, GLib Gst.debug_set_active(False) Gst.debug_set_default_threshold(3) Gst.init(None) Gst.init_check(None) SENDER_PIPELINE = "filesrc location=B:/python/sample_files_custom/Custom_2.mp4 ! qtdemux ! h264parse config-interval=-1 ! tee name=t t. ! queue ! rtph264pay ! udpsink host=127.0.0.1 port=25570 t. ! queue ! avdec_h264 ! queue ! videoanalyse ! videoconvert ! autovideosink" #SENDER_PIPELINE = "filesrc location=B:/python/sample_files_custom/Custom_2.mp4 ! qtdemux ! h264parse config-interval=-1 ! tee name=t t. ! queue ! mpegtsmux ! srtsink uri=srt://192.168.0.119:25570/ t. ! queue ! avdec_h264 ! videoanalyse ! videoconvert ! autovideosink" #SENDER_PIPELINE = "videotestsrc ! videoconvert ! autovideosink" #SENDER_PIPELINE = "filesrc location=B:/python/sample_files_custom/Custom_2.mp4 ! queue ! qtdemux ! queue ! h264parse config-interval=-1 ! queue ! avdec_h264 ! identity signal-handoffs=true name=ident ! videoanalyse ! videoconvert ! autovideosink" #RECEIVER_PIPELINE = 'srtsrc uri=srt://:25570 ! queue ! decodebin ! queue ! videoconvert ! fpsdisplaysink' RECEIVER_PIPELINE = 'udpsrc port=25570 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! queue ! rtph264depay ! h264parse config-interval=-1 update-timecode=true ! queue ! avdec_h264 output-corrupt=true debug-mv=true ! queue ! videoconvert ! fpsdisplaysink'
def __init__(self, s1, s2, s3, s4, outType): if s1 is not None: self.source1 = s1 if s2 is not None: self.source2 = s2 if s3 is not None: self.source3 = s3 if s4 is not None: self.source4 = s4 self.otype = outType Gst.debug_set_active(True) Gst.debug_set_default_threshold(3) self.mainloop = GLib.MainLoop() self.pipeline = Gst.Pipeline() self.clock = self.pipeline.get_pipeline_clock() self.bus = self.pipeline.get_bus() self.bus.add_signal_watch() self.bus.connect('message::error', self.on_error) sources = [['rtmpsrc', self.source1], ['rtmpsrc', self.source2], ['rtmpsrc', self.source3], ['rtmpsrc', self.source4]] # Video input index = 0 for source in sources: self.malm([ [source[0], None, { 'location': source[1], 'do-timestamp': 1 }], ['queue', None, {}], ['decodebin', 'decoder{}'.format(index), { 'use-buffering': 1 }] ]) decoder = getattr(self, 'decoder{}'.format(index)) prev = None self.malm([['queue', 'video_in{}'.format(index), {}], ['videoconvert', None, {}], ['videoscale', None, {}], [ 'capsfilter', None, { 'caps': 'video/x-raw, width={}, height={}'.format( settings.x1, settings.y1) } ], ['queue', 'video_out{}'.format(index), {}]]) prev = None self.malm([ ['queue', 'audio_in{}'.format(index), {}], ['audioconvert', None, {}], #['audioresample', None, {}], #['capsfilter', None, {'caps': 'audio/x-raw, rate=44100'}], ['queue', 'audio_out{}'.format(index), {}] ]) if index == 0: decoder.connect('pad-added', self.__on_decoded_pad) elif index == 1: decoder.connect('pad-added', self.__on_decoded_pad1) elif index == 2: decoder.connect('pad-added', self.__on_decoded_pad2) elif index == 3: decoder.connect('pad-added', self.__on_decoded_pad3) index += 1 #video mixer prev = None self.malm([['videomixer', 'm', {}], ['videoscale', None, {}], [ 'capsfilter', None, { 'caps': 'video/x-raw, width={}, height={}'.format( settings.width, settings.height) } ], ['videorate', None, {}], [ 'capsfilter', None, { 'caps': 'video/x-raw, framerate=30000/1001' } ], ['queue', None, {}], ['x264enc', None, { 'tune': 'zerolatency' }], ['queue', 'vmix_out', {}]]) vmix_pads = [] vmix_pads.append(self.m.get_request_pad('sink_%u')) vmix_pads.append(self.m.get_request_pad('sink_%u')) vmix_pads.append(self.m.get_request_pad('sink_%u')) vmix_pads.append(self.m.get_request_pad('sink_%u')) vmix_pads[1].set_property('xpos', settings.x1) vmix_pads[2].set_property('ypos', settings.y1) vmix_pads[3].set_property('xpos', settings.x1) vmix_pads[3].set_property('ypos', settings.y1) vmix_pads[0].set_offset(2000000000) #audio mixer prev = None self.malm([['audiomixer', 'ma', {}], ['audioconvert', None, {}], ['queue', None, {}], ['voaacenc', None, { 'bitrate': 96000 }], [ 'queue', None, { 'max-size-bytes': 0, 'max-size-buffers': 0, 'max-size-time': 0 } ], ['aacparse', None, {}], ['queue', 'amix_out', {}]]) prev = None if self.otype == 'rtmp': #flvmux for streaming to RTMP self.malm([['flvmux', 'smux', { 'streamable': 1 }], ['rtmpsink', None, { 'sync': 0, 'location': settings.outRtmp }]]) elif self.otype == 'hls': #mpegtsmux for streaming to HLS self.malm([['mpegtsmux', 'smux', {}], [ 'hlssink', None, { 'playlist-root': settings.outHLS, 'playlist-location': settings.playListLocation, 'location': settings.fileLocation, 'max-files': 20, 'target-duration': 8 } ]]) else: print(self.otype + ' is not supported, Exiting...') return # Video input index = 0 for source in sources: video_out = getattr(self, 'video_out{}'.format(index)) audio_out = getattr(self, 'audio_out{}'.format(index)) video_out.link(self.m) audio_out.link(self.ma) index += 1 self.amix_out.link(self.smux) self.vmix_out.link(self.smux)
from gi.repository import GLib from gi.repository import Gio import threading GObject.threads_init() Gst.init(None) print '********************************************************' print 'GObject: ' pp.pprint(GObject.pygobject_version) print '' print 'Gst: ' pp.pprint(Gst.version_string()) print '********************************************************' Gst.debug_set_active(True) Gst.debug_set_default_threshold(3) import StringIO import re import ConfigParser import signal from IPython.core.debugger import Tracer from IPython.core import ultratb sys.excepthook = ultratb.FormattedTB(mode='Verbose', color_scheme='Linux', call_pdb=True, ostream=sys.__stdout__)
def set_debug(level): Gst.debug_set_active(True) Gst.debug_set_default_threshold(level)
# --gst-fatal-warnings Make all warnings fatal # --gst-debug-help Print available debug categories and exit # --gst-debug-level=LEVEL Default debug level from 1 (only error) to 9 (anything) or 0 for no output # --gst-debug=LIST Comma-separated list of category_name:level pairs to set specificlevels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3 # --gst-debug-no-color Disable colored debugging output # --gst-debug-color-mode Changes coloring mode of the debug log. Possible modes: off, on, disable, auto, unix # --gst-debug-disable Disable debugging # --gst-plugin-spew Enable verbose plugin loading diagnostics # --gst-plugin-path=PATHS Colon-separated paths containing plugins # --gst-plugin-load=PLUGINS Comma-separated list of plugins to preload in addition to the list stored in environment variable GST_PLUGIN_PATH # --gst-disable-segtrap Disable trapping of segmentation faults during plugin loading # --gst-disable-registry-update Disable updating the registry # --gst-disable-registry-fork Disable spawning a helper process while scanning the registry ########################################################################## Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(1) except ImportError: print( textwrap.dedent(""" ERROR: A GObject Python package was not found. Mopidy requires GStreamer to work. GStreamer is a C library with a number of dependencies itself, and cannot be installed with the regular Python tools like pip. Please see http://docs.mopidy.com/en/latest/installation/ for instructions on how to install the required dependencies. """)) raise else:
import sys import gi try: gi.require_version('Gst', '1.0') from gi.repository import Gst except ValueError: print 'Could not find required Gstreamer 1.0 library.' sys.exit(1) # Setup GStreamer Gst.init(None) Gst.init_check(None) print Gst.version_string(), Gst.version() Gst.debug_set_active(True) # If activated, debugging messages are sent to the debugging handlers. for x in dir(Gst.DebugCategory()): print x Gst.debug_log_default( category = Gst.DebugCategory(), level = Gst.DebugLevel.ERROR, file = 'gst-error.log', function = 'myfunction', line = '100', object = 'myobject', message = 'this is a error', unused = 0, )