import cv2
import numpy as np
cam = cv2.VideoCapture(0) #get the first webcam
####defining the codec and creating the VideoWriter Obj
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out=cv2.VideoWriter('./assets/output.avi',fourcc,20.0,(1280,960))
while(cam.isOpened()):
ret, frame = cam.read()
if ret==True:
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cam.release()
out.release()
cv2.destroyAllWindows()
this is the code (the one i posted by mistake) i can change XVID with MP42 AVC1, but what would be the file extension in the name? is there a way to check which is the right codec? i tried to check the list of codec with ffmpeg -encoders