I'm not able to write an mp4 video file with cv2 on Rpi4. All I'm getting in feedback is VIDIOC_DQBUF: Invalid argument
writer = cv2.VideoWriter('test.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, (640, 480), True)
stream = cv2.VideoCapture(0)
ret, frame = stream.read()
while ret:
writer.write(frame)
cv2.imshow('Video', frame)
ret, frame = stream.read()
if cv2.waitKey(1) & 0xFF==27:
break
stream.release()
writer.release()
cv2.destroyAllWindows()
The video is displaying using cv2.imshow(frame), and the file is outputted, however no frames are actually written to it, so the video file appears corrupted.
I am assuming this is a codec error. I've tried displaying the codecs using fourcc=-1 in VideoWriter()
though the other fourcc's I've tried didn't work either. Has anyone had success using opencv writing videos on rpi4?