save video cv2

Solutions on MaxInterview for save video cv2 by the best coders in the world

showing results for - "save video cv2"
Daniela
26 Aug 2020
1import numpy as np
2import cv2
3
4cap = cv2.VideoCapture(0)
5
6# Define the codec and create VideoWriter object
7#fourcc = cv2.cv.CV_FOURCC(*'DIVX')
8#out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
9out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480))
10
11while(cap.isOpened()):
12    ret, frame = cap.read()
13    if ret==True:
14        frame = cv2.flip(frame,0)
15
16        # write the flipped frame
17        out.write(frame)
18
19        cv2.imshow('frame',frame)
20        if cv2.waitKey(1) & 0xFF == ord('q'):
21            break
22    else:
23        break
24
25# Release everything if job is finished
26cap.release()
27out.release()
28cv2.destroyAllWindows()
29