-
Notifications
You must be signed in to change notification settings - Fork 0
/
video_read_write.py
45 lines (29 loc) · 1.12 KB
/
video_read_write.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
41
42
43
44
45
import cv2
import numpy as np
image_path = r"C:\Users\emircan\Desktop\openCV/"
capture= cv2.VideoCapture(image_path + "animation.mp4")
capture_height = capture.get(cv2.CAP_PROP_FRAME_HEIGHT)
capture_width = capture.get(cv2.CAP_PROP_FRAME_WIDTH)
capture_count = capture.get(cv2.CAP_PROP_FRAME_COUNT)
capture_fps = capture.get(cv2.CAP_PROP_FPS)
print(capture_height, capture_width, capture_count, capture_fps)
#Avi şeklinde kaydet
write_out = cv2.VideoWriter(image_path + "animation_save.avi",
cv2.VideoWriter_fourcc('D', 'I', 'V', 'X'), 15,
(np.int(capture_width), np.int(capture_height)), True)
while True:
#Kameradan görüntü alma
ret, frame = capture.read()
#Görüntünün gelip gelmediğinin kontrolü
if ret is True:
#Görüntüyü ekrana ver
cv2.imshow("Animasyon Videosu", frame)
write_out.write(frame)
#50 sn sonra çık
c = cv2.waitKey(50)
if c == 27:
break
else:
break
capture.release()
write_out.release()