-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame_Cutter.py
More file actions
55 lines (44 loc) · 1.62 KB
/
Copy pathFrame_Cutter.py
File metadata and controls
55 lines (44 loc) · 1.62 KB
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
46
47
48
49
50
51
52
53
54
55
import PySimpleGUI as sg
import cv2
def Cutter(arquivo,ext):
cap= cv2.VideoCapture(arquivo)
i=1
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
while(cap.isOpened()):
ret, frame = cap.read()
if ret == False:
break
cv2.imwrite('frames/frame_'+str(i)+ext,frame)
sg.OneLineProgressMeter('Progresso', i, length, 'single',orientation="h")
i = i + 1
cap.release()
cv2.destroyAllWindows()
sg.popup("Concluído con sucesso!",title="AVISO")
sg.theme('DefaultNoMoreNagging')
frame_layout = [
[sg.FileBrowse("Selecionar vídeo",key="browse"), sg.Text("Somente arquivos AVI, MP4 ou GIF",key="texto")],
[sg.Text("Selecione o formato de saida:"),sg.Radio('.png', "radio", default=True,key=".png"),sg.Radio('.jpg', "radio",key=".jpg")],
[sg.Text("Suas imagens serão salvas na pasta frames")],
[sg.Button('Cortar',key="button"), sg.Button('Cancel')]
]
layout = [
[sg.Frame('Frame Cutter', frame_layout, font='Any 16')],
]
window = sg.Window('Frame Cutter', layout)
while True:
event, values = window.read()
if event in (None, 'Cancel'):
break
if event == "button":
ext = values["browse"][-3:len(values["browse"])]
if ext == "avi" or ext == "mp4" or ext == "gif":
values["texto"] = values["browse"]
caminho = values["texto"].split("/")
arquivo = caminho[-1]
if values[".png"] == True:
Cutter(values["browse"],".png")
else:
Cutter(values["browse"],".jpg")
else:
sg.popup("Somente arquivos AVI, MP4 ou GIF",title="AVISO")
window.close()