How to write images to SD card faster?

Hi,
Please try the sample:

import sys
import cv2

def read_cam():
    cap = cv2.VideoCapture("v4l2src ! video/x-raw,width=1344,height=376,format=YUY2,framerate=30/1 ! videoconvert ! video/x-raw,format=BGR ! appsink sync=0 ")

    w = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
    h = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
    fps = cap.get(cv2.CAP_PROP_FPS)
    print('Src opened, %dx%d @ %d fps' % (w, h, fps))

    gst_out = "appsrc ! video/x-raw, format=BGR ! queue ! filesink location=/tmp/a.yuv sync=0 "
    out = cv2.VideoWriter(gst_out, cv2.CAP_GSTREAMER, 0, float(fps), (int(w), int(h)))
    if not out.isOpened():
        print("Failed to open output")
        exit()

    if cap.isOpened():
        for i in range(1, 300):
            ret_val, img = cap.read();
            if not ret_val:
                break;
            out.write(img);
    else:
     print("pipeline open failed")

    print("successfully exit")
    cap.release()
    out.release()


if __name__ == '__main__':
    read_cam()

Not sure if it helps but we generally run gstreamer pipeline in cv2.VideoCapture() and cv2.VideoWriter(). If it still cannot achieve target fps, we suggest encode to h264/h265 steam. Please refer to this sample:
Displaying to the screen with OpenCV and GStreamer - #9 by DaneLLL