gstreamer dynamic pipeline filesink add, getting not-negotiated error

4.1k views Asked by At

This works :

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

I'm trying to do the same in a dynamic way using python and pygst, the autovideosink branch is always there and after user input I want to attach the filesink.

This is the dynamic connection code:

    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)

on linking I get this error:

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) 

Any ideas?

2

There are 2 answers

0
user1296240 On BEST ANSWER

Now It works!. The solution was to add "format" to capsfilter. Previous caps filter string was:

caps = gst.Caps('video/x-raw-yuv,width=640,height=480,framerate=30/1')

and now it is:

caps = gst.Caps('video/x-raw-yuv,format=(fourcc)I420,width=640,height=480,framerate=30/1')

The problem was that my webcam default output pixel format was "YUYV" and the theoraenc element in my fileSink Bin not accepted this format, so adding format=(fourcc)I420 helped. Still I don't know why the previous capsfilter string worked with gst-launch but I don't mind now. Thanks for help

1
user2618142 On

I am not very sure, but the error may be below ...
Please try to link before setting state to PLAYING.

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

I guess, the negotiation error generally occurs when caps of the two linked elements are not compatible.