这有效:
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。
这是动态连接代码:
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)
有什么想法吗?
答案 0 :(得分:2)
现在它有效!解决方案是向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配合使用但我现在不介意。
谢谢你的帮助
答案 1 :(得分:0)
我不太确定,但错误可能低于...... 请在设置状态到PLAYING之前尝试链接。
self.player.get_by_name('splitter').link(fileSink)
fileSink.set_state(gst.STATE_PLAYING)
我猜,当两个链接元素的大写不兼容时,通常会发生协商错误。