所以我要解决的问题是获取一个未知的传入URI流,并将它们混合到一个传出流中。我现在所做的基本上是使用for-each循环,每次迭代我都创建一个源,添加videoscale和capsfilter等元素,然后将其链接到videomixer。目前,我有它的工作,如果我只是通过一个usb网络摄像头饲料与autovideosrc。然而,当我尝试使用uridecodebin时,由于链接错误,它完全崩溃了。你知道吗
我知道,通常在创建uridecodebin时,您必须使用pad-added信号,比如这个例子。你知道吗
#!/usr/bin/python
import pygst
pygst.require('0.10')
import gst
import pygtk
pygtk.require('2.0')
import gtk
# this is very important, without this, callbacks from gstreamer thread
# will messed our program up
gtk.gdk.threads_init()
def on_new_decoded_pad(dbin, pad, islast):
decode = pad.get_parent()
pipeline = decode.get_parent()
convert = pipeline.get_by_name('convert')
decode.link(convert)
pipeline.set_state(gst.STATE_PLAYING)
print "linked!"
def main():
pipeline = gst.Pipeline('pipleline')
filesrc = gst.element_factory_make("filesrc", "filesrc")
filesrc.set_property('location', 'C:/a.mp3')
decode = gst.element_factory_make("decodebin", "decode")
convert = gst.element_factory_make('audioconvert', 'convert')
sink = gst.element_factory_make("autoaudiosink", "sink")
pipeline.add(filesrc, decode, convert, sink)
gst.element_link_many(filesrc, decode)
gst.element_link_many(convert, sink)
decode.connect("new-decoded-pad", on_new_decoded_pad)
pipeline.set_state(gst.STATE_PAUSED)
gtk.main()
main()
然而,我发现的每个例子都假设我总是将一个uridecodebin连接到另一个元素。如果在本例中由“convert”表示的元素在每次调用函数时都会有所不同,那么我该如何实现呢?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐