Hello everyone,
I’m new to Gstreamer and I need to save a video stream from an e-con See3CAM_CU135 camera to an .avi file. I have successfully
streamed the video to a small window, so then I tried to use OpenCV in Python to save the frames to the file, but
I think my pipeline is not configured correctly.
This is how I configured VideoCapture and VideoWriter:
if __name__ == '__main__':
width = 4208
height = 3120
fps = 20
gst_in = f"v4l2src device=/dev/video0 ! image/jpeg, width={width}, height={height}, framerate={fps}/1, format=MJPG ! nvv4l2decoder mjpeg=1 ! nvvidconv ! appsink max-buffers=1 drop=true"
gst_out= f"appsrc ! video/x-raw, format=BGR ! avimux ! filesink location=video_{datetime.timestamp(datetime.now())}.avi "
stream = cv2.VideoCapture(gst_in, cv2.CAP_GSTREAMER)
writer = cv2.VideoWriter(gst_out, cv2.CAP_GSTREAMER, 0, fps, (int(width), int(height)))
At first I tried to use videoconvert before the appsink in the VideoCapture pipeline, but it worked very badly, a lot
of the frames were missing. So I removed it, but now I get this error:
[ WARN:1] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1629) writeFrame OpenCV | GStreamer warning: cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 3.
And I have no idea how to fixed it, I couldn’t find anything online. If anyone can give me a solution or some
advice I’d really appreciate it.
Thank you in advance!