这有效:
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 分支始终存在,并且在用户输入后我想附加文件接收器。
这是动态连接代码:
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)
有什么想法吗?
最佳答案
现在可以了!解决方案是在 capsfilter 中添加“format”。以前的大写过滤字符串是:
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”,而我的 fileSink Bin 中的 theoraenc 元素不接受此格式,因此添加 format=(fourcc)I420
有所帮助。
我仍然不知道为什么之前的 capsfilter 字符串与 gst-launch 一起使用,但我现在不介意。
感谢您的帮助
关于python - gstreamer 动态管道文件接收器添加,出现未协商错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18553197/