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

**URL:** https://forum.opencv.org/t/i-am-not-able-to-display-and-save-a-video-from-my-flir-hadron-camera-using-gstreamer-command-in-python3-opencv/17370
**Category:** Python
**Tags:** gstreamer, camera, videoio
**Created:** [April 22, 2024, 10:48am UTC](https://forum.opencv.org/t/i-am-not-able-to-display-and-save-a-video-from-my-flir-hadron-camera-using-gstreamer-command-in-python3-opencv/17370 "2024-04-22T10:48:40Z")
**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 22, 2024, 10:48am UTC](https://forum.opencv.org/t/i-am-not-able-to-display-and-save-a-video-from-my-flir-hadron-camera-using-gstreamer-command-in-python3-opencv/17370/1 "2024-04-22T10:48:40Z")

</div>

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

```auto
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

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

````

---

<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:50am UTC](https://forum.opencv.org/t/i-am-not-able-to-display-and-save-a-video-from-my-flir-hadron-camera-using-gstreamer-command-in-python3-opencv/17370/2 "2024-04-29T08:50:55Z")

</div>

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

> <https://stackoverflow.com/questions/78361491/i-am-not-able-to-display-and-save-a-video-from-my-flir-hadron-camera-using-gstre>

> <https://stackoverflow.com/questions/78355003/problem-with-using-gstreamer-with-python-3-opencv-to-display-and-save-a-video-in>
