forked from Mrinank-Bhowmick/python-beginner-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (34 loc) · 1.23 KB
/
main.py
File metadata and controls
45 lines (34 loc) · 1.23 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
# First of all import this modules
import cv2
import pyautogui
from win32api import GetSystemMetrics
import numpy as nu
import time
# Then set width and height of your recorder same as your screen
width = GetSystemMetrics(0)
height = GetSystemMetrics(1)
dimension = (width, height)
format = cv2.VideoWriter_fourcc(*"XVID")
# Here you can change the FPS (Frame Per Second)
video_output = cv2.VideoWriter("ScreenRecord.mp4", format, 30.0, dimension)
# Set the time interval of Recording
# Take how much time you required in the Duration variable
Present_time = time.time()
Duration = 10
finish_time = Present_time + Duration
while True:
# Here pyautogui.screenshot() captured screenshots which merge into a ScreenRecord
picture = pyautogui.screenshot()
# Here we store all the screenshots in an array
frame = nu.array(picture)
# Here we get the original color by using cv2.COLOR_BGR2RGB
frame_1 = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Now we store the video output here
video_output.write(frame_1)
# Now check the duration
current_time = time.time()
if current_time > finish_time:
break
# Finally release your ScreenRecord
video_output.release()
print("____Screen Recording finished________")