Python gstreamer动态管道文件链接添加,获取未协商错误
这项工作:Python gstreamer动态管道文件链接添加,获取未协商错误,python,dynamic,gstreamer,pipeline,pygst,Python,Dynamic,Gstreamer,Pipeline,Pygst,这项工作: gst-launch -e v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! tee name=splitter ! queue ! autovideosink splitter. ! queue ! theoraenc ! oggmux ! filesink location=testogg.ogg 我正在尝试使用python和pygst以动态方式执行相同的操作,autovideosink分支始终在那里
gst-launch -e v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! tee name=splitter ! queue ! autovideosink splitter. ! queue ! theoraenc ! oggmux ! filesink location=testogg.ogg
我正在尝试使用python和pygst以动态方式执行相同的操作,autovideosink分支始终在那里,在用户输入之后,我希望附加FileLink
这是动态连接代码:
fileSink = self.getFileSink()
pad = fileSink.get_static_pad('sink')
pad.set_blocked_async(True, self.padBlockedOnRecordStart, None)
self.player.add(fileSink)
fileSink.set_state(gst.STATE_PLAYING)
self.player.get_by_name('splitter').link(fileSink)
pad.set_blocked_async(False, self.padBlockedOnRecordStart, None)
在链接时,我遇到以下错误:
Error: GStreamer encountered a general stream error. gstbasesrc.c(2625): gst_base_src_loop (): /GstPipeline:player/GstV4l2Src:video:
streaming task paused, reason not-negotiated (-4)
有什么想法吗?我不是很确定,但错误可能在下面…
请在将状态设置为播放之前尝试链接
self.player.get_by_name('splitter').link(fileSink)
fileSink.set_state(gst.STATE_PLAYING)
我想,协商错误通常发生在两个链接元素的上限不兼容的情况下。现在可以了!。解决方案是在capsfilter中添加“格式”。以前的caps筛选器字符串为:
caps = gst.Caps('video/x-raw-yuv,width=640,height=480,framerate=30/1')
现在是:
caps = gst.Caps('video/x-raw-yuv,format=(fourcc)I420,width=640,height=480,framerate=30/1')
问题是我的网络摄像头默认输出像素格式为“YUYV”,而我的文件链接箱中的Theoreanc元素不接受此格式,因此添加format=(fourcc)I420
会有所帮助。
我仍然不知道为什么以前的capsfilter字符串与gst发布一起工作,但我现在不介意。
感谢您的帮助我已经尝试过了,但它给出了相同的错误,另外管道将变为空状态-您尝试链接到现有管道的元素必须与管道处于相同的状态我猜您忘记将capsfilter添加为元素,但我需要查看所有链接代码才能确定。