-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreverse video creator.py
40 lines (29 loc) · 1 KB
/
reverse video creator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import cv2
# Loading module
cap = cv2.VideoCapture(0)
# Creating video capture object
four_cc = cv2.VideoWriter_fourcc('X','V','I','D')
# Declaring the video format
writer = cv2.VideoWriter('outputVideo.avi',four_cc,20.0,(640,480))
# Creating video writer object
frames = []
# Creating a list where every input frame will be stored.
while cap.isOpened():
ret,image = cap.read()
# Taking frame input
if ret:
frames.append(image)
# Storing frame into a list
cv2.imshow("Input video",image)
# Displaying input frame
if cv2.waitKey(1) & 0xFF == 27:
break
for frame in frames[::-1]:
writer.write(frame)
# Writing the video from the frames appended in list in reverse order
cap.release()
# Releasing Video Capture object
writer.release()
# Releasing video writer object
cv2.destroyAllWindows()
# Freeing up memory by destorying all opened windows.