Skip to content

Commit 3e2117a

Browse files
author
Srinjoy Pati
committed
screen recorder
1 parent ed0d781 commit 3e2117a

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

scripts/Screen-recorder/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Screen-recorder
2+
3+
## Introduction
4+
5+
This project , records the screen , whatever you are doing and to stop recording you need to press 'Q'. It saves the video in mp4 format with the file name of date and time when it is being recorded.
6+
7+
## Tech stack
8+
9+
The project is made using python.
10+
11+
## Demonstration video - here is a view of the project
12+
13+
<https://user-images.githubusercontent.com/91176055/159889632-837f567b-d931-4069-9e0d-251b825b05a2.mp4>
14+
15+
## Install dependencies
16+
17+
- install Python 3.8.3 or above
18+
- Further install these packages using terminal:
19+
20+
```bash
21+
pip install Pillow numpy opencv-contrib-python pywin32
22+
```
23+
24+
## Quick start (how to run locally)
25+
26+
- Clone this repository:
27+
28+
```bash
29+
git clone https://github.com/metafy-social/daily-python-scripts.git
30+
```
31+
32+
- Change directory:
33+
34+
```bash
35+
cd daily-python-scripts
36+
cd Screen-recorder
37+
```
38+
39+
- Find main.py and run it.

scripts/Screen-recorder/main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import datetime
2+
3+
import cv2
4+
from PIL import ImageGrab
5+
import numpy as np
6+
from win32api import GetSystemMetrics
7+
8+
width = GetSystemMetrics(0)
9+
height = GetSystemMetrics(1)
10+
11+
time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S')
12+
file_name = f'{time_stamp}.mp4'
13+
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
14+
captured_video = cv2.VideoWriter(file_name, fourcc, 20.0, (width, height))
15+
16+
while True:
17+
img = ImageGrab.grab(bbox=(0, 0, width, height))
18+
img_np = np.array(img)
19+
img_final = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
20+
cv2.imshow('Screen Recorder', img_final)
21+
captured_video.write(img_final)
22+
if cv2.waitKey(10) == ord('q'):
23+
break

0 commit comments

Comments
 (0)