gstreamer:无法添加元素

时间:2012-09-28 19:55:38

标签: gstreamer python-gstreamer

我正在尝试将视频从Android手机传输到我的笔记本电脑。我跑了gstreamer它工作正常。我的问题是以下代码:

   [....]
    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)
    [...]

运行时出现此错误:

      (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'

我是gstreamer的新手。我已经提到这个问题来编写代码:Playing RTSP with python-gstreamer

有谁可以请指出我做错了什么?为什么我会收到adderror?

2 个答案:

答案 0 :(得分:4)

您不必再次将元素源添加到管道中。它已被添加。

答案 1 :(得分:1)

来自gstreamer gst_pipeline_add_many()文档:

  

将以NULL结尾的元素列表添加到bin中。

所以它应该是:

gst.element_link_many(source, decoder, sink, NULL);
相关问题