-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenRecorder.py
More file actions
85 lines (69 loc) · 3.17 KB
/
ScreenRecorder.py
File metadata and controls
85 lines (69 loc) · 3.17 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import tkinter
import customtkinter
import pyautogui
import numpy
import cv2
import sys
class Frame(customtkinter.CTkFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
class Application(customtkinter.CTk):
def start_recording(self):
fourcc = cv2.VideoWriter_fourcc(*"XVID")
fps = 60
out = cv2.VideoWriter('output.mp4', fourcc, fps, (self.ScreenSize))
cv2.namedWindow("Live", cv2.WINDOW_NORMAL)
cv2.resizeWindow("Live", 480, 270)
while self.Config:
img = pyautogui.screenshot()
frame = numpy.array(img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
out.write(frame)
cv2.imshow('Live', frame)
if cv2.waitKey(1) == ord('q'):
break
out.release()
cv2.destroyAllWindow()
def stop_recording(self):
sys.exit()
def __init__(self):
super().__init__()
self.geometry("640x480")
self.title("ScreenRecorder")
self.minsize(width=640, height=480)
self.maxsize(width=640, height=480)
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
self.my_frame = Frame(master=self, )
self.my_frame.grid(row=0, column=0, padx=20, pady=20, sticky="nsew")
self.lable = customtkinter.CTkLabel(master=self,
text="ScreenRecorder",
width=120,
height=25,
text_color="White",
font=("", 30),
corner_radius=8)
self.lable.place(relx=0.50, rely=0.15, anchor=tkinter.CENTER)
self.Record = customtkinter.CTkButton(master=self,
width=120,
height=32,
border_width=0,
corner_radius=8,
font=("",24),
text="Start Recording",
command=self.start_recording
)
self.Record.place(relx=0.50, rely=0.47, anchor=tkinter.CENTER)
self.Stop = customtkinter.CTkButton(master=self,
width=120,
height=32,
border_width=0,
corner_radius=8,
font=("", 24),
text="Stop Recording",
command=self.stop_recording)
self.Stop.place(relx=0.50, rely=0.60, anchor=tkinter.CENTER)
self.ScreenSize=tuple(pyautogui.size())
self.Config=True
application = Application()
application.mainloop()