1

我正在尝试将视频从 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?

4

2 回答 2

4

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

于 2012-09-29T17:56:05.497 回答
1

来自 gstreamer gst_pipeline_add_many()文档:

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

所以应该是:

gst.element_link_many(source, decoder, sink, NULL);
于 2013-09-17T08:14:31.537 回答