I am not able to display and save a video from my Flir hadron camera using Gstreamer command in python3 Opencv

I’m trying to display and save my Flir Hadron camera videos using gstreamer pipelines in Python 3 OpenCV. I have a perfectly working Gstreamer pipelines that are able to display and save videos with high resolution, but when I execute the Python3 code to display and save, I get the following ERROR:

Cannot open camera. Existing

which in my opinion means that I have a problem in the camset line of code since it prints the message in the code

if cap.isOpened() is not True

`
I still have no idea how to resolve this problem.

Also another note: I do have gstreamer in my opencv. Any help would be appreciated.

Gstreamer pipeline (displays and save):

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

python3 code:
 ```
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 ! video/x-raw,format=BGR ! appsink drop=1'  

cam=cv2.VideoCapture(camset,cv2.CAP_GSTREAMER)


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

actual_width=int(cam.get(cv2.CAP_PROP_FRAME_WIDTH))
actual_heigtht=int(cam.get(cv2.CAP_PROP_FRAME_HEIGHT))
actual_fps=float(cam.get(cv2.CAP_PROP_FPS));
print('Capture opened framing %d x %d @ %f' % (actual_width,actual_height,actual_fps))


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

fourcc=0
out=cv2.VideoWriter(gst_str, cv2.CAP_GSTREAMER, fourcc, actual_fps, (actual_width, actual_height), True)
if not out.isOpened:
        print("Cannot open writer. Existing.")
        quit()

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()

crosspost: