-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame_Split.py
More file actions
44 lines (32 loc) · 977 Bytes
/
Frame_Split.py
File metadata and controls
44 lines (32 loc) · 977 Bytes
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
import cv2
from pathlib import Path
import glob
image_dir= Path("/home/Halivious/Videos/Frames/")
count = len(list(image_dir.glob('*.jpg')))
print(count)
cap1 = cv2.VideoCapture("/home/Halivious/Videos/1.mkv")
cap2 = cv2.VideoCapture("/home/Halivious/Videos/2.mkv")
cap3 = cv2.VideoCapture("/home/Halivious/Videos/3.mkv")
i=0
while(cap1.isOpened()):
ret, frame = cap1.read()
if ret == False:
break
cv2.imwrite("/home/Halivious/Videos/Frames/frame"+str(i)+".jpg",frame)
i +=1
cap1.release()
while(cap2.isOpened()):
ret, frame = cap2.read()
if ret == False:
break
cv2.imwrite("/home/Halivious/Videos/Frames/frame"+str(i)+".jpg",frame)
i +=1
cap2.release()
while(cap3.isOpened()):
ret, frame = cap3.read()
if ret == False:
break
cv2.imwrite("/home/Halivious/Videos/Frames/frame"+str(i)+".jpg",frame)
i +=1
cap3.release()
cv2.destroyAllWindows()