Using Gstreamer with python3 opencv to dispaly and save a video in Desktop with flir hadron camera

Hey, i have been trying to display and save videos from my flir hadron camera using Gstreamer commands that worked to do the same but i want use the gstreamer command in python3 opencv but ican not seem figure it out i get an (Cannot open camera. Existing )ERROR so the problem is in my camset pipline i guess, you’ll find the gstreamer commands and the python3 code in case somoene could help please.

Gstreamer command to display and save from the camera:
gst-launch-1.0 v4l2src io-mode=4 device=/dev/video0 do-timestamp=true ! tee name=t ! ‘video/x-raw, format=UYVY, width=1920, height=1080, framerate=30/1’ ! queue leaky=1 ! xvimagesink sync=false t. ! queue ! nvvidconv ! nvv4l2h265enc bitrate=8000000 ! h265parse ! qtmux ! filesink location=/home/nvidia/Desktop/RGB_$(date ‘+%Y-%m-%d_%H-%M-%S’).mp4 -e

The python3 code:
import cv2

fps=30
frame_width=1920
frame_height=1080

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

cam=cv2.VideoCapture(camset,cv2.CAP_GSTREAMER)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, frame_width)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT,frame_height)
cam.set(cv2.CAP_PROP_FPS, fps)

if cam.isOpened() is not True:
print(“Cannot open camera. Existing.”)
quit()

gst_str = ’ appsrc ! video/x-raw,format=UYVY, width=1920, height=1080, framerate=30/1 ! queue ! videoconvert ! nvvidconv ! nvv4l2h265enc maxperf-enable=1 preset-level=4 control-rate=1 bitrate=16000000 ! h265parse ! qtmux ! filesink location=streaming.mp4 ’

fourcc = cv2.VideoWriter_fourcc(*‘H265’)
out=cv2.VideoWriter(gst_str, fourcc , 30, (frame_width, frame_height), True)

while (True):
ret,frame = cam.read()

cv2.imshow('camera',frame)
out.write(frame)
if cv2.waitKey(1) & 0XFF == ord('q'):
	break

cam.release()
cv2.destroyAllWindows()