我正试图将一段视频从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的新手。我已经参考了这个问题来编写代码:用python-gstreamer玩RTSP
谁能指出我做错了什么吗?为什么我会得到Adderror?
您不必再次将元素源添加到管道中。它已经添加。
来自gstreamer gst_pipeline_add_many()文档:
将以null终止的元素列表添加到bin中。
所以应该是:
gst.element_link_many(source, decoder, sink, NULL);