# Gstreamer: Losing frames while displaying from the camera

**URL:** <https://forum.opencv.org/t/gstreamer-losing-frames-while-displaying-from-the-camera/17447>\
**Category:** Python\
**Tags:** gstreamer, videoio\
**Created:** [April 28, 2024, 8:40pm UTC](https://forum.opencv.org/t/gstreamer-losing-frames-while-displaying-from-the-camera/17447 "2024-04-28T20:40:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ihssane](https://avatars.discourse-cdn.com/v4/letter/i/d26b3c/32.png) [@ihssane](https://forum.opencv.org/u/ihssane)\
**Post date:** [April 28, 2024, 8:40pm UTC](https://forum.opencv.org/t/gstreamer-losing-frames-while-displaying-from-the-camera/17447/1 "2024-04-28T20:40:55Z")

</div>

i’m wondering if someone could help me, i’m trying to display and save videos from my flir hadron camera ,i’m using gstreamer in python3 opencv and it succefully displays and saves the IR videos from the BOSON, but i’m losing frames in the RGB videos which leads to slow displaying and fast playback and tried to add various command to the gstreamer piplines such as videorate to control the fps but nothing help .

i cheked while executing the code that it’s using just the CPU part of the jetson nano , so i’ve installed CUDA to be able to use the GPU and i don’t know what i’ve have to add in my code to force it to use the GPU of the computer

i’de appreciate any help thank you

here is the RGB code for displaying and saving:

```auto
import cv2

camset=‘v4l2src io-mode=4 device=/dev/video0 do-timestamp=true ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=30/1 ! queue ! videoconvert ! videorate ! video/x-raw,format=BGR ! appsink drop=1’

cap=cv2.VideoCapture(capset,cv2.CAP_GSTREAMER)
if cap.isOpened() is not True:
print(“Cannot open camera. Exiting.”)
quit()
actual_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
actual_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
actual_fps = float(cap.get(cv2.CAP_PROP_FPS));
print(‘Capture opened framing %d x %d @ %f’ % (actual_width,actual_height,actual_fps))

gst_writer_str = ‘appsrc ! video/x-raw,format=BGR,width=1920,height=1080,framerate=30/1 ! queue ! videoconvert ! video/x-raw,format=BGRx ! nvvidconv ! nvv4l2h265enc maxperf-enable=1 preset-level=4 control-rate=1 bitrate=14000000 ! h265parse ! qtmux ! filesink location=streaming.mp4’
fourcc = 0 #RAW
out = cv2.VideoWriter(gst_writer_str, cv2.CAP_GSTREAMER, fourcc, actual_fps, (actual_width, actual_height), True)
if not out.isOpened():
print(“Cannot open writer. Exiting.”)
quit()

while (True):
ret,frame = cap.read()
cv2.imshow(‘camera’,frame)
out.write(frame)
if cv2.waitKey(1) & 0XFF == ord(‘q’):
break
out.release()
cap.release()
cv2.destroyAllWindows()

```

---

<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:** [April 29, 2024, 8:48am UTC](https://forum.opencv.org/t/gstreamer-losing-frames-while-displaying-from-the-camera/17447/2 "2024-04-29T08:48:38Z")

</div>

> [@ihssane](#):
>
> `videorate ! video/x-raw,format=BGR ! appsink drop=1’`

what do you suppose that `videorate` and `drop=1` do?

[crosspost](https://meta.stackoverflow.com/a/266159):

> <https://stackoverflow.com/questions/78399545/losing-frames-while-displaying-from-the-camera>
