How to create Gstreamer pipeline using VideoCapture() in openCV?

Device: Qualcomm rb5
OpenCV: 4.4.0
GStreamer: 1.16.2

I am using OpenCV’s VideoCapture() to use Gstreamer pipeline.

gst-launch-1.0 -e qtiqmmfsrc camera-id=0 ! video/x-h264,format=NV12,width=1920,height=1080,framerate=30/1 ! h264parse ! avdec_h264 ! videoconvert ! waylandsink sync=false

This is working independently, but when I am passing through VideoCapture() using below code, it shows error of: appsink not working in Gstreamer pipeline

import cv2

pipeline = 'gst-launch-1.0 -e qtiqmmfsrc camera-id=0 ! video/x-h264,format=NV12,width=1920,height=1080,framerate=30/1 ! h264parse ! avdec_h264 ! videoconvert ! waylandsink sync=false'


cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)


if not cap.isOpened():
print('Error: Unable to open pipeline')
exit()

while True:
# Read a frame from the pipeline
ret, frame = cap.read()

# Check if a frame was successfully read
if not ret:
    print('Error: Unable to read frame')
    break

# Display the frame
cv2.imshow('Frame', frame)

# Check if the user pressed 'q' to quit
if cv2.waitKey(1) & 0xFF == ord('q'):
    break
cap.release()
cv2.destroyAllWindows()

Qualcomm rb5 works with walyand display, hence waylandsink is working. But when I am passing following command, nothing shows on the display.

gst-launch-1.0 -e qtiqmmfsrc camera-id=0 ! video/x-h264,format=NV12,width=1920,height=1080,framerate=30/1 ! h264parse ! avdec_h264 ! videoconvert ! appsink name=sink command, 

How should I solve this? Would I need to create gstreamer plugin to use OpenCV in rb5?

the argument is supposed to be just the pipeline, not gst-launch-1.0

OpenCV does not start a subprocess. it calls into the gstreamer library.