# Using gstreamer to read video frame into cv GpuMat

**URL:** <https://forum.opencv.org/t/using-gstreamer-to-read-video-frame-into-cv-gpumat/6890>\
**Category:** C++\
**Created:** [December 28, 2021, 8:46am UTC](https://forum.opencv.org/t/using-gstreamer-to-read-video-frame-into-cv-gpumat/6890 "2021-12-28T08:46:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![strongnguyen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/strongnguyen/32/4095_2.png) [@strongnguyen](https://forum.opencv.org/u/strongnguyen)\
**Post date:** [December 28, 2021, 8:46am UTC](https://forum.opencv.org/t/using-gstreamer-to-read-video-frame-into-cv-gpumat/6890/1 "2021-12-28T08:46:22Z")

</div>

Hi, I notice the original code used gstreamer to read video frame into cv::Mat :

```auto
videoCaptureBackend = cv::CAP_GSTREAMER;
videoSource = "filesrc location=\"" + addressIn + "\" ! decodebin ! videoconvert ! appsink";
video_cap = cv::VideoCapture(videoSource, videoCaptureBackend);

```

However, if I want to used the nvidia hardware accelerator to faster performance, I will need to used nvdecode:

```auto
videoSource = "filesrc location=\"" + addressIn + "\" ! qtdemux ! queue ! h264parse ! nvh264dec ! cudadownload ! appsink";

```

This way, data is read using nvidia decode and transfer back to cpu memory cvMat, yield a slower performace than cpu only read code.  
Is there any way/ sample code that used gstreamer pipeline that could load video frame directly into gpuMat ?
