<div dir="ltr"><br>Hi!<br><br><div>I want to achieve a scenario when a single video decoder upon client demand would feed various encoders. And when demand is gone the encoders should be stopped and recycled upon the next connection. I've tried 3 ways to achieve my goal and all failed to some extent.</div><div><br></div><div>1) Multifdsink / raw video<br><br>    Main decoder :<br><br>    fdsrc ! tsdemux ! decodebin ! videoconvert ! videorate !  multifidsink<br>    <br>    Sample encoder (Separate pipeline):<br>    <br>    fdsrc ! rawvideoparse use-sink-caps=1 ! "caps from multifdsink inserted here" ! videoconvert ! videorate ! videoscale ! x264enc tune=zerolatency key-int-max=5 ! mpegtsmux ! multifdsink<br>    <br>    <br>    This way I can start/stop encoders at ease but I get a color mess of a picture no mater what caps do multifdsink provide</div><div><br></div><div><br></div><div>2) Multiudpsink / raw video<br><br>    Main decoder:<br><br>    fdsrc ! tsdemux ! decodebin ! videoconvert ! videorate !  rtpvrawpay ! multiudpsink<br>    <br>    Sample encoder (Separate pipeline):<br>    <br>    udpsrc caps="caps from multiudpsink inserted here" ! rtpvrawdepay ! videoconvert ! videorate ! videoscale ! x264enc tune=zerolatency key-int-max=5 ! mpegtsmux ! multifdsink<br>    <br>    <br>    This way I can start/stop encoders at ease. I even get a nice picture when there's little motion on the scene, but when motion is introduced I get a lot of artifacts like missing parts of walking man. Not to mention that I get 50Mbit of network trafic on lo for a single 320X240 stream</div><div><br></div><div>3) Dynamic pipelines usage<br><br>    (Mostly inspired by <a href="https://github.com/MaZderMind/dynamic-gstreamer-pipelines-cookbook/blob/master/05-add-and-remove-network-sink.py">https://github.com/MaZderMind/dynamic-gstreamer-pipelines-cookbook/blob/master/05-add-and-remove-network-sink.py</a>)<br><br>    Main decoder:<br><br>    fdsrc ! tsdemux ! decodebin ! videoconvert ! videorate !  tee<br>    <br>    Sample encoder (Gst.Bin):<br>    <br>    queue ! videoconvert ! videorate ! videoscale !  x264enc tune=zerolatency key-int-max=5 ! mpegtsmux ! multifdsink<br>    <br>    <br>    Here I start the main decoder and on demand add a Gst.Bin containing sample encoder. First time (no encoder was requested yet) I can get a stream with visible delay of 1-2 seconds. But when encoder get stopped and detached from pipeline on the next demand I get a still frame with players actually indicate time ticking (encoder pushes the same frame all over again)<br>    <br>    <br>    Code to add encoder to main pipeline:<br>    <br>    self.motion_debug = self.create_encoder_pipeline('motion', encoder='h264')<br>    self.pipeline.add(self.motion_debug)<br>    tee = self.pipeline.get_by_name('motion_tee')<br>    print(tee.link(self.motion_debug))<br>    self.motion_debug.set_state(Gst.State.PLAYING)<br>    <br>    <br>    That goes with Link_OK every time<br>    <br>    Code to remove encoder from main pipeline<br>    <br>        <br>    ghostpad = self.motion_debug.get_static_pad("sink")<br>    teepad = ghostpad.get_peer()<br>    teepad.add_probe(Gst.PadProbeType.BLOCK, self.blocking_pad_probe)<br>    <br>    def blocking_pad_probe(self,pad, info):<br>        print("Stopping Bin")<br>        self.motion_debug.set_state(Gst.State.NULL)<br><br><br>        tee = self.pipeline.get_by_name('motion_tee')<br>        ghostpad = self.motion_debug.get_static_pad("sink")<br>        teepad = ghostpad.get_peer()<br><br>        print('Removing encoder bin')<br>        print(self.pipeline.remove(self.motion_debug))<br><br>        print("Releasing Tee-Pad")<br>        tee.release_request_pad(teepad)<br><br>        self.motion_debug = None<br><br><br>        return Gst.PadProbeReturn.REMOVE<br><br>        <br>I believe that the most right way to solve my problem would be the 3rd approach. But I welcome any solution or thought.<br><br>Thanks in advance!<br></div><div><br></div><div><br></div><div><br></div></div>