2

这有效:

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) 

有任何想法吗?

4

2 回答 2

2

现在它起作用了!解决方案是在 capsfilter 中添加“格式”。以前的大写过滤器字符串是:

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 一起使用,但我现在不介意。感谢帮助

于 2013-09-03T19:30:38.147 回答
0

我不太确定,但错误可能如下...
请在将状态设置为 PLAYING 之前尝试链接。

 self.player.get_by_name('splitter').link(fileSink)    
 fileSink.set_state(gst.STATE_PLAYING)  

我想,协商错误通常发生在两个链接元素的上限不兼容时。

于 2013-09-02T06:53:21.653 回答