import cv2
videocapture = cv2.VideoCapture('SampleVideo.mp4')
fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (640,480) )
while(videocapture.isOpened()): v1, video1 = videocapture.read()
if v1 == True:
gray = cv2.cvtColor(video1, cv2.COLOR_BGR2GRAY)
print(videocapture.get(cv2.CAP_PROP_FRAME_WIDTH))
print(videocapture.get(cv2.CAP_PROP_FRAME_HEIGHT))
cv2.imshow('frame', gray)
if cv2.waitKey() == ord('q'):
break
else:
break
out.release() videocapture.release() cv2.destroyAllWindows()