1

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?

Community
  • 1
  • 1
Raja
  • 11
  • 1
  • 2
  • This looks like you added source element somewhere before. I suggest you try without parse_launch element - try to make each element separately, add to pipeline and link them. Check return of every command and it will be easy to debug it. – 10robinho Oct 02 '12 at 16:31

2 Answers2

4

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

av501
  • 6,645
  • 2
  • 23
  • 34
  • This is correct, `gst_parse_launch` adds the elements to the pipeline. Performing a `pipeline.add(source)` will attempt to add the element again and fail. – ystreet00 Aug 07 '18 at 12:00
1

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);
poplawskidaniel
  • 55
  • 1
  • 10