'Add new sink to gstreamer examples camera

I'm very newbie at GStreamer and I can't write the output to file.

I'm testing the gstreamer detect example in the coral/examples-camera/gstreamer project. This demo run perfectly in my coral dev board mini, but I need help to add a filesink in the gstreamer pipeline of this proyect

            PIPELINE += """ ! decodebin ! queue ! v4l2convert ! {scale_caps} !
              glupload ! glcolorconvert ! video/x-raw(memory:GLMemory),format=RGBA !
              tee name=t
                t. ! queue ! glfilterbin filter=glbox name=glbox ! queue ! {sink_caps} ! {sink_element}
                t. ! queue ! glsvgoverlay name=gloverlay sync=false ! glimagesink fullscreen=true
                     qos=false sync=false
            """

The demo uses the glimagesink element to display the video on the screen and I need to add a sink that saves the video to a file

Executing with debug I've captured, I belive, the format of video in glimagesink element, the debug output is:

GST_PADS gstpad.c:3160:gst_pad_query_accept_caps_default:<salida:sink>[00m allowed caps subset ANY, caps video/x-raw(memory:GLMemory), framerate=(fraction)30/1, interlace-mode=(string)progressive, width=(int)640, height=(int)480, format=(string)RGBA, texture-target=(string)2D

I've tried this pipelines configurations:

oral board model: mt8167
Gstreamer pipeline:
 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! decodebin ! queue ! v4l2convert ! video/x-raw,format=BGRA,width=640,height=480 !
              glupload ! glcolorconvert ! video/x-raw(memory:GLMemory),format=RGBA !
              tee name=t
                t. ! queue ! glfilterbin filter=glbox name=glbox ! queue ! video/x-raw,format=RGB,width=320,height=320 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true
                t. ! queue ! glsvgoverlay name=gloverlay sync=false ! 
                videoconvert ! x264enc ! avimux ! filesink location=output.avi
            
            
Traceback (most recent call last):
  File "detect.py", line 138, in <module>
    main()
  File "detect.py", line 135, in main
    videofmt=args.videofmt)
  File "/home/mendel/google-coral/examples-camera/gstreamer/gstreamer.py", line 294, in run_pipeline
    pipeline = GstPipeline(pipeline, user_function, src_size)
  File "/home/mendel/google-coral/examples-camera/gstreamer/gstreamer.py", line 36, in __init__
    self.pipeline = Gst.parse_launch(pipeline)
gi.repository.GLib.Error: gst_parse_error: could not link videoconvert0 to x264enc0 (3)

Know anyone how write this output to file with Gstreamer?

Any help will be appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source