Skip to main content
 首页 » 编程设计

python之gstreamer 动态管道 filesink 添加,出现未协商的错误

2024年11月01日11birdshome

这个有效:

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)  

有什么想法吗?

请您参考如下方法:

现在可以了!解决方案是将“格式”添加到 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 一起使用,但我现在不介意了。 感谢帮助