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

**URL:** <https://forum.opencv.org/t/how-to-create-gstreamer-pipeline-using-videocapture-in-opencv/11597>\
**Category:** Python\
**Tags:** gstreamer, videoio\
**Created:** [January 13, 2023, 1:41am UTC](https://forum.opencv.org/t/how-to-create-gstreamer-pipeline-using-videocapture-in-opencv/11597 "2023-01-13T01:41:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fourier](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@Fourier](https://forum.opencv.org/u/Fourier)\
**Post date:** [January 13, 2023, 1:41am UTC](https://forum.opencv.org/t/how-to-create-gstreamer-pipeline-using-videocapture-in-opencv/11597/1 "2023-01-13T01:41:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 13, 2023, 10:53am UTC](https://forum.opencv.org/t/how-to-create-gstreamer-pipeline-using-videocapture-in-opencv/11597/2 "2023-01-13T10:53:04Z")

</div>

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.
