Raja
Raja

Reputation: 11

gstreamer: could not add element

I am trying to stream a video from an android phone to my laptop. I ran the gstreamer and it works fine. My problem is with the following code:

   [....]
    pipeline = gst.parse_launch('rtspsrc name=source latency=0 ! decodebin ! autovideosink')
    source = pipeline.get_by_name('source')
    source.props.location =  "rtsp://128.237.119.100:8086/"
    decoder = gst.element_factory_make("decodebin", "decoder")
    sink = gst.element_factory_make("autovideosink", "sink")

    pipeline.add(source, decoder, sink)
    gst.element_link_many(source, decoder, sink)
    [...]

I get this error when I run it:

      (server.py:2893): GStreamer-WARNING **: Name 'source' is not unique in bin 'pipeline0', not adding
       Traceback (most recent call last):
       File "server.py", line 27, in <module>
       py = pyserver()
       File "server.py", line 18, in __init__
       pipeline.add(source, decoder, sink)
       gst.AddError: Could not add element 'source'

I am new to gstreamer. I have referred to this question to write the code: Playing RTSP with python-gstreamer

Could anyone please point out what I am doing wrong? Why do I get the adderror?

Upvotes: 1

Views: 3386

Answers (2)

poplawskidaniel
poplawskidaniel

Reputation: 55

From gstreamer gst_pipeline_add_many() documentation:

Adds a NULL-terminated list of elements to a bin.

So it's should be:

gst.element_link_many(source, decoder, sink, NULL);

Upvotes: 1

av501
av501

Reputation: 6729

You don't have to add the element source to the pipeline again. It is already added.

Upvotes: 4

Related Questions