【问题标题】:gstreamer: could not add elementgstreamer:无法添加元素
【发布时间】:2012-09-20 17:23:18
【问题描述】:

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

【问题讨论】:

  • 这看起来像您之前在某处添加了源元素。我建议您尝试不使用 parse_launch 元素 - 尝试分别制作每个元素,添加到管道并链接它们。检查每个命令的返回,调试起来很容易。

标签: gstreamer python-gstreamer


【解决方案1】:

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

【讨论】:

  • 这是正确的,gst_parse_launch 将元素添加到管道中。执行pipeline.add(source) 将尝试再次添加元素并失败。
【解决方案2】:

来自 gstreamer gst_pipeline_add_many() 文档:

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

应该是这样的:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-07
    • 1970-01-01
    • 2021-01-05
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多