Still doesn't work.... :-(
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 28 Apr 2021 21:16:27 +0000 (23:16 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 28 Apr 2021 21:16:27 +0000 (23:16 +0200)
lagarde.py

index 05b2fe008489ff19077277e06be98f9cadebd70b..fd8285273617185cc57b457e53ae1e704270f2b7 100755 (executable)
@@ -179,25 +179,57 @@ class WebRTCClient:
             return
         caps = pad.get_current_caps()
         padsize = caps.get_size()
             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()
         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')
             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 = 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(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()
                 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')
 
             elif name.startswith('audio'):
                 q = Gst.ElementFactory.make('queue')