我在将音频和视频合并到一个文件时遇到麻烦。 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


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

最佳答案

您将2倍filmOggmux链接到filmFilesink:这是不允许的,只能进行一个链接。

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

08-17 09:42