Problems using gstreamer pipeline in openCV for recording video

Hi,
If you don’t need to do processing to 4032x3040 buffers. You can use tee like:

import sys
import cv2

def read_cam():
    cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! tee name=t t. ! queue ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=a.mkv t. ! queue ! nvvidconv ! video/x-raw, format=(string)I420, width=640, height=480 ! appsink sync=0 ")
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img = cap.read();
            img2 = cv2.cvtColor(img, cv2.COLOR_YUV2BGR_I420);
            cv2.imshow('demo',img2)
            cv2.waitKey(10)
    else:
     print("camera open failed")

    cv2.destroyAllWindows()


if __name__ == '__main__':
    read_cam()
1 Like