MrDevKnown

SELECT * FROM world WHERE humanity IS NOT NULL;

  • Home
  • About
  • Contact Us

Idea

Today we are going to create a Screen Recorder in Python using OpenCV.

Prerequisites

Knowledge of basic Python coding, basics of OpenCV, numpy and Pillow.

Install Modules

  pip install pillow
  pip install numpy
  pip install opencv-python

Type these commands one by one in your terminal: cmd, bash, etc.. and press enter (run).

  pip install pillow numpy opencv-python

Code

Import modules

from PIL import ImageGrab
import numpy as np
import cv2, datetime
from win32api import GetSystemMetrics
from screeninfo import get_monitors

Note: We import opencv module with the name cv2 in Python.

The logic

for m in get_monitors():
    width = str(m.width)
    height = str(m.height)

width = GetSystemMetrics(0)
height = GetSystemMetrics(1)

time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S')
file_name = f'{time_stamp}.mp4'

enc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
cap_vd = cv2.VideoWriter(file_name, enc, 20.0, (width, height))

def app():
    img = ImageGrab.grab(bbox=(0, 0, width, height))
    img_np = np.array(img)
    img_final = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
    cv2.imshow('Screen Capture', img_final)
    cap_vd.write(img_final)

while True:
    app()
    if cv2.waitKey(10) == ord('q'):
        break

Output

Now your app is ready. Run the code and wait. Everything on the screen will be recorded. Press q on your keyboard to stop the recording. The recording is then saved to the directory where the file is.

Summary

In this article you learnt how you can make your own screen recorder using Python. You learnt about the use of python pillow module and numpy. We made the screen recorder using opencv.

Thanks for reading. Hope you liked the idea and project. Do comment down you opinions. Also, share this project with your friends and programmers.


Newer Posts Older Posts Home

ABOUT ME

Web developer, designer. A self taught programmer. Don't hesitate to come for say a small "hello!"
Shivesh Tiwari

POPULAR POSTS

  • How to create a shining / glowing effect around the cursor on mouse hover over a div? Glassmorphism Tutorial
  • Javascript code to display a welcome message after accepting the name of the user using a prompt box
  • How to make Windows 11 Website Design | Adding Working App Windows | Dark Mode and other things
  • How to test your typing speed with Python - Make a Python app
  • Make a Windows 11 themed Website - HTML, CSS Windows 11 design
  • Top must have windows software for a developer
  • Qt Designer UI to python file export
  • Python PyQt5 complete Setup Windows
  • PyQt5 draggable Custom window code
  • Make your own Python IDE + Text Editor (Pykachu)

Categories

  • best javascript project 12
  • code 5
  • dino game 1
  • dislike 1
  • easy python projects 9
  • flask 1
  • free python code 10
  • game 2
  • git 1
  • github 1
  • hack 2
  • hack chrome dino game 1
  • hack game 1
  • html best website 4
  • javascript website 6
  • learn javascript 9
  • learn programming 13
  • learn python 15
  • like 1
  • like dislike system php 1
  • mrdevknown 5
  • music player 1
  • notification 1
  • php 2
  • programming 9
  • project 9
  • pyqt5 4
  • python 16
  • python IDE 2
  • python projects 8
  • React 5
  • react js 6
  • software 5
  • Tkinter 2
  • web app 4
  • website 4
Powered by Blogger
MrDevKnown

Search This Blog

Archive

  • August 20231
  • March 20231
  • December 20221
  • September 20222
  • August 20221
  • June 20221
  • March 20221
  • January 20226
  • December 20211
  • November 20213
  • October 202111
  • September 20213
  • August 20213
Show more Show less
  • Home
  • About
  • Contact Us

Subscribe

Posts
Atom
Posts
All Comments
Atom
All Comments

Subscribe

Posts
Atom
Posts
All Comments
Atom
All Comments

Categories

  • React5
  • Tkinter2
  • best javascript project12
  • code5
  • dino game1
  • dislike1
  • easy python projects9
  • flask1
  • free python code10
  • game2
  • git1
  • github1
  • hack2
  • hack chrome dino game1
  • hack game1
  • html best website4
  • javascript website6
  • learn javascript9
  • learn programming13
  • learn python15
  • like1
  • like dislike system php1
  • mrdevknown5
  • music player1
  • notification1
  • php2
  • programming9
  • project9
  • pyqt54
  • python16
  • python IDE2
  • python projects8
  • react js6
  • software5
  • web app4
  • website4

Translate

Pages

  • Home
  • Privacy Policy

Popular Posts

Music Player web app made in HTML, CSS, Javascript

Music Player web app made in HTML, CSS, Javascript

August 03, 2021
Top must have windows software for a developer

Top must have windows software for a developer

September 17, 2022
Javascript code to display a welcome message after accepting the name of the user using a prompt box

Javascript code to display a welcome message after accepting the name of the user using a prompt box

August 20, 2022

Trending Articles

  • How to create a shining / glowing effect around the cursor on mouse hover over a div? Glassmorphism Tutorial
  • Javascript code to display a welcome message after accepting the name of the user using a prompt box
  • How to make Windows 11 Website Design | Adding Working App Windows | Dark Mode and other things
  • How to test your typing speed with Python - Make a Python app

Popular Posts

  • Top must have windows software for a developer
  • Javascript code to display a welcome message after accepting the name of the user using a prompt box
  • How to create a shining / glowing effect around the cursor on mouse hover over a div? Glassmorphism Tutorial

Labels

Distributed By Gooyaabi | Designed by OddThemes