Gstreaming from GTK Python application and sychronously displaying the stream

24 Views Asked by At

I have following command that works:

gst-launch-1.0 -vv filesrc location=2024-02-01_13-42-24.mp4 ! decodebin ! videoconvert ! tee name=t t. ! queue ! videoconvert name=vc t. ! queue ! x264enc ! rtph264pay ! udpsink host=michal.local port=5000

it streams the video to the counter part.

And then I'm trying to make it working in Python in Gtk I have following function to create pipeline:

def create_pipeline2(self, source_file, target_ip, target_port):

        bin = Gst.parse_bin_from_description(f'filesrc location={source_file} ! decodebin ! videoconvert ! tee name=t \
             t. ! queue ! videoconvert name=vc \
             t. ! queue ! x264enc ! rtph264pay ! udpsink host={target_ip} port={target_port} ', True)
        
        gtksink = Gst.ElementFactory.make("gtksink")

        pipeline = Gst.Pipeline()
        pipeline.add(bin)
        pipeline.add(gtksink)
        pipeline.get_by_name("vc").link(gtksink)

        bus = pipeline.get_bus()
        bus.add_signal_watch()

        loop = GObject.MainLoop()
        bus.connect("message", self.on_message, loop)

        return pipeline, gtksink

I return gtksing which a manually add to gtk widget and pipeline and then I switch it to playing state and give me following errror:

State change request is asynchronous. Wait for the state change to complete.
Error: gst_parse_error: Delayed linking failed. (7): gst/parse/grammar.y(540): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstBin:bin0/GstDecodeBin:decodebin0:
failed delayed linking some pad of GstDecodeBin named decodebin0 to some pad of GstVideoConvert named videoconvert0

Warning: gst-stream-error-quark: Internal data stream error. (1): ../gst/isomp4/qtdemux.c(6749): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstBin:bin0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-linked (-1)

I tried many things and I simply don't know how to continue. Please advise. I can share more code if it's revelevant.

0

There are 0 best solutions below