From 0831639af5c4d7954b3727cabcb7a75e0bd0bdf7 Mon Sep 17 00:00:00 2001 From: Philipp Spitzer Date: Wed, 28 Apr 2021 23:16:27 +0200 Subject: [PATCH] Still doesn't work.... :-( --- lagarde.py | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/lagarde.py b/lagarde.py index 05b2fe0..fd82852 100755 --- a/lagarde.py +++ b/lagarde.py @@ -179,25 +179,57 @@ class WebRTCClient: return caps = pad.get_current_caps() padsize = caps.get_size() + + log.info(f'>>>> {padsize} {caps}') + for i in range(padsize): s = caps.get_structure(i) # Gst.Structure name = s.get_name() + log.info(f'###### {name}') if name.startswith('video'): q = Gst.ElementFactory.make('queue') conv = Gst.ElementFactory.make('videoconvert') + enc = Gst.ElementFactory.make('x264enc') + enc.set_property('bitrate', 1000) + enc.set_property('tune', 'zerolatency') + capsfilter = Gst.ElementFactory.make('capsfilter') + capsfilter.set_properties(Gst.Caps.from_string('video/x-h264,stream-format=(string)avc')) + flmux = Gst.ElementFactory.make('flvmux') sink = Gst.ElementFactory.make('rtmpsink') - sink.props.location = 'rtmp://127.0.0.1:1935/cug' - # sink.props.location = 'rtmp://127.0.0.1:1936/cug' + sink.set_property('location', 'rtmp://192.168.1.46:1935/gregoa') + # sink.set_property('location', 'rtmp://bla:1936/gregoa') + print(sink.props.location, dir(sink.props)) + assert q and conv and enc and capsfilter and flmux and sink + self.pipe.add(q) self.pipe.add(conv) + self.pipe.add(enc) + self.pipe.add(capsfilter) + self.pipe.add(flmux) self.pipe.add(sink) self.pipe.sync_children_states() - pad.link(q.get_static_pad('sink')) - q.link(conv) - conv.link(sink) - # self.pipe.set_state(Gst.State.PLAYING) - print(dir(Gst.DebugGraphDetails)) - Gst.debug_bin_to_dot_data(element, Gst.DebugGraphDetails.ALL) + + q_pad_sink = q.get_static_pad('sink') + assert q_pad_sink + pad_link_return = pad.link(q_pad_sink) + assert pad_link_return == Gst.PadLinkReturn.OK + + # ok = element.link(q) + # assert ok + + ok = q.link(conv) + assert ok + ok = conv.link(enc) + assert ok + ok = enc.link(capsfilter) + assert ok + ok = capsfilter.link(flmux) + assert ok + ok = flmux.link(sink) + assert ok + self.pipe.set_state(Gst.State.PLAYING) + #print(dir(Gst.DebugGraphDetails)) + #Gst.debug_bin_to_dot_data(element, Gst.DebugGraphDetails.ALL) elif name.startswith('audio'): q = Gst.ElementFactory.make('queue') -- 2.39.5