[OV2311]OpenCV in Python will not save footage if I have CONVERT_RGB set to False

I have been having trouble saving footage using OpenCV with Python. The problem stems from the fact that if cap.set(cv2.CAP_PROP_CONVERT_RGB, False) is set to false like in the example it doesn’t want to save footage, it just makes a file that is empty. But if I delete it or set the argument to True it only gives out a black screen which then is recorded. The black screen is to be expected since it probably does RGB conversion from 3 separate RGB channels which it doesn’t have (I’m not really sure, couldn’t find much about it).

I have already tried matching the output video resolution to the one it captures and using different codecs.

Thank you all for any help, much appriciated!


import cv2
import argparse
from utils import ArducamUtils

parser = argparse.ArgumentParser(description='Arducam Jetson Nano MIPI Camera Displayer.')
parser.add_argument('-d', '--device', default=0, type=int, nargs='?',
help='/dev/videoX default is 0')
args = parser.parse_args()

cap = cv2.VideoCapture('/dev/video0', cv2.CAP_V4L2)
cap.set(cv2.CAP_PROP_CONVERT_RGB, False)

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('pupila1.avi',fourcc, 20.0, (1600, 1300))

arducam_utils = ArducamUtils(args.device)

while True:
ret, frame = cap.read()
frame_arducam = arducam_utils.convert(frame)

frame_arducam = cv2.resize(frame_arducam, (1600,1300))
cv2.imshow("Arducam0", frame_arducam)

ret = cv2.waitKey(1)
if ret == ord('q'):


Hi @PeterN

It looks like VideoWriter does not support single-channel input, you need to manually convert the gray image to BGR format.