Python + GStreamer - 无法连接

时间:2010-08-14 20:21:06

标签: python gstreamer

我在将音频和视频合并到一个文件时遇到了问题。 Python代码看起来像这样;

            filmPipe = gst.Pipeline("filmPipe")
            filmSrc = gst.element_factory_make("multifilesrc", "filmSrc")
            filmSrc.set_property("location", "pictures/%d.png")
            filmFilt1 = gst.element_factory_make("capsfilter", "filmFilt1")
            filmCap1 = gst.Caps("image/png,framerate=5/1,pixel-aspect-ratio=1/1")
            filmFilt1.set_property("caps", filmCap1)
            filmPngDec = gst.element_factory_make("pngdec", "filmPngDec")
            filmff = gst.element_factory_make("ffmpegcolorspace", "filmff")
            filmFilt2 = gst.element_factory_make("capsfilter", "filmFilt2")
            filmCap2 = gst.Caps("video/x-raw-yuv")
            filmFilt2.set_property("caps", filmCap2)
            filmTheora = gst.element_factory_make("xvidenc", "filmTheora")
            filmQue = gst.element_factory_make("queue", "filmQue")
            filmOggmux = gst.element_factory_make("ffmux_mp4", "filmOggmux")
            filmFilesink = gst.element_factory_make("filesink", "filmFilesink")
            filmFilesink.set_property("location", self.movPath)
            musicSrc = gst.element_factory_make("filesrc", "musicSrc")
            musicSrc.set_property("location", self.musicPath)
            musicDec = gst.element_factory_make("ffdec_mp3", "musicDec")
            musicEnc = gst.element_factory_make("lame", "musicEnc")
            musicQue = gst.element_factory_make("queue", "musicQue")

            filmPipe.add(filmSrc, filmFilt1, filmPngDec, filmff, filmFilt2, filmTheora, filmQue, filmOggmux, filmFilesink)
            filmPipe.add(musicSrc, musicDec, musicEnc, musicQue)
            gst.element_link_many(filmSrc, filmFilt1, filmPngDec, filmff, filmFilt2, filmTheora, filmQue, filmOggmux, filmFilesink)
            gst.element_link_many(musicSrc, musicDec, musicEnc, musicQue, filmOggmux, filmFilesink)
            filmPipe.set_state(gst.STATE_PLAYING)

这会返回以下错误:

Traceback (most recent call last):
 File "app.py", line 100, in movGen
gst.element_link_many(musicSrc, musicDec, musicEnc, musicQue, filmOggmux, filmFilesink)
gst.LinkError: failed to link filmOggmux with filmFilesink

有人知道我哪里出错了,或者如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

你将2次filmOggmux链接到filmFilesink:这是不允许的,只有一个链接是可能的。

尝试在第二个gst.element_link_many()删除filmFilesink。