Skip to content

Commit 721af8b

Browse files
Merge pull request #901 from tanujadasari/main
Screen Recorder
2 parents 5b98f27 + 7c5f7cf commit 721af8b

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed
Loading

GUIScripts/Screen Recorder/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Screen Recorder
2+
## Aim
3+
To build a screen recorder using Python pyautogui.
4+
## Purpose
5+
Screen Recorder is a software used to record your screen and saves it as a video file.
6+
## Short description
7+
- This code enables us to record screen easily.
8+
- Recorded file will be saved as "Recording.avi"
9+
- Libraries imported :
10+
- `pyautogui`
11+
- `CV2`
12+
- `numpy`
13+
14+
## Workflow
15+
- Imported required libraries i.e.,`pyautogui`,`CV2`,`numpy`.
16+
- Resolution is set to 1920x1080.
17+
- Framerate is set to 60.0 mps.
18+
- Created a video object and an empty window, resized this window and named it as LIVE.
19+
- PyautoGUI is used to take screenshots.
20+
- numpy will convert those screenshots into an array.
21+
## Compilation Steps
22+
- Download the file [screen_recorder.py](https://github.com/tanujadasari/Awesome_Python_Scripts/blob/main/GUIScripts/Screen%20Recorder/screen_recorder.py)
23+
- Run the file [screen_recorder.py](https://github.com/tanujadasari/Awesome_Python_Scripts/blob/main/GUIScripts/Screen%20Recorder/screen_recorder.py), let's start recording our screen.
24+
- Install pyautogui, CV2, numpy if you don't have them.
25+
- After clicking run,it takes continuous screenshots and makes it into an array, out.write will convert this as a video.
26+
- The screen will continue to record until we press `q`
27+
- Finally, recorded file will be saved as "Recording.avi".
28+
## Output
29+
![screenrecoder](https://user-images.githubusercontent.com/85128713/127743132-52b7ca0e-096b-47ec-854b-3f56c6faa215.png)
30+
Pathlink:https://github.com/tanujadasari/Awesome_Python_Scripts/blob/main/GUIScripts/Screen%20Recorder/Images/screenrecorder_output.jpeg
31+
## Author:
32+
[D Tanuja](https://github.com/tanujadasari)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Libraries imported:
2+
i. pyautogui
3+
ii. cv2
4+
iii. numpy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pyautogui #imported pyautogy library
2+
import cv2 #imported open cv library
3+
import numpy as np #imported numpy library
4+
5+
resolution = (1920, 1080)#video resolution
6+
codec = cv2.VideoWriter_fourcc(*"XVID")#video codec
7+
filename = "Recording.avi"#name of Output file
8+
fps = 60.0#frame rate
9+
out = cv2.VideoWriter(filename, codec, fps, resolution)#VideoWriter object created
10+
cv2.namedWindow("Live", cv2.WINDOW_NORMAL)#Empty window
11+
cv2.resizeWindow("Live", 480, 270)#window resize
12+
13+
while True:
14+
15+
img = pyautogui.screenshot()# Takes screenshot
16+
frame = np.array(img)# Convert the screenshot to a numpy array
17+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)# Convert it from BGR(Blue, Green, Red) to RGB(Red, Green, Blue)
18+
out.write(frame)#output file
19+
cv2.imshow('Live', frame)#Display the recording content on screen
20+
if cv2.waitKey(1) == ord('q'): #click q to Stop recording
21+
break
22+
23+
out.release()# Release the Video writer
24+
25+
cv2.destroyAllWindows()# Destroy all windows

0 commit comments

Comments
 (0)