Search code examples
opencvgstreamerh.264vaapi

GStreamer Pipeline problems when using appsrc and vaapiencode_h264 plugin


I am working on an app that accepts Opencv frames (originated via opencv camera Api) and tries to send those frames into the network after encoding them to H264 frames.

For this project I was asked to perform the encoding via hardware.

I used the below pipeline to do the encoding bit of the transmitter:

gst-launch-1.0 appsrc name=applicationSource ! videoconvert ! video/x-raw,width=640,format=I420,height=480,framerate=15/1 ! vaapiencode_h264 ! vaapiparse_h264 config-interval=1 ! rtph264pay config-interval=1 ! gdppay ! tcpserversink host=127.0.0.1 port=5002 sync=false

The Caps for my Appsrc are :

video/x-raw","format""RGB","width"640,"height",G_TYPE_INT,480,
                                               "framerate", 15, 1,
                                               "pixel-aspect-ratio" 1, 1,

This pipeline however gives me the below error when i try to run it:

libva info: VA-API version 0.37.0

libva info: va_getDriverName() returns 0

libva info: Trying to open /usr/lib64/dri/i965_drv_video.so

libva info: Found init function __vaDriverInit_0_37

libva info: va_openDriver() returns 0

0:00:04.597696251 23508 0x7f724003f940 WARN GST_PADS gstpad.c:3739:gst_pad_peer_query: could not send sticky events

0:00:05.030818739 23508 0x7f724003f940 WARN basesrc gstbasesrc.c:2933:gst_base_src_loop: error: Internal data flow error.

0:00:05.030864404 23508 0x7f724003f940 WARN basesrc gstbasesrc.c:2933:gst_base_src_loop: error: streaming task paused, reason not-negotiated (-4)

Error : Internal data flow error.

0:00:05.032763231 23508 0x7f724003f940 WARN baseparse gstbaseparse.c:1155:gst_base_parse_sink_event_default: error: No valid frames found before end of stream

Error : No valid frames found before end of stream

As I have highlighted, the pipeline does not start due to negotiation issues

I have tested my Appsrc and it seems to be working (receiving data).

Could anyone suggest any other plugins to overcome this ??

PS: I had tried this pipeline with a camera v4l2src plugin and the pipeline seems to be working in good condition !

Any help would be nice !

Thanks !


Solution

  • I fixed the said problem , it was due to missing caps attribute in the gstreamer pipeline...

    I had added the caps for the appsrc plugin as :

    video/x-raw","format""RGB","width"640,"height",G_TYPE_INT,480,
                                                   "framerate", 15, 1,
                                                   "pixel-aspect-ratio" 1, 1,
    

    But I was missing a

    "interlace-mode",G_TYPE_STRING,"progressive",
    

    Checked v4l2src caps to verify : Did this by enabling debug

    --gst-debug=v4l2src:6
    

    in pipeline like this and running it :

    gst-launch-1.0 --gst-debug=v4l2src:6 v4l2src ! videoconvert ! video/x-raw,width=640,format=I420,height=480,framerate=15/1 ! vaapiencode_h264 ! vaapiparse_h264 config-interval=1 ! rtph264pay config-interval=1 ! gdppay ! tcpserversink host=127.0.0.1 port=5002 sync=false