GK SCIENTIST

General Knowledge One Stop Source
Menu
  • Home
  • Social Science
    • History
    • Political Science
    • Geography
  • Science
    • Physics
    • Chemistry
    • Biology
  • Chemistry Notes
  • Mathematics
  • Computer
  • Tutorial MySQL
  • Tutorial Python
  • Java Tutorial
  • English Grammar
  • English Essay
  • Indian Anthropology
  • Philosophy
  • Solved Paper
  • UPSC
  • Current Content
    • Current Affairs
    • RSTV News
    • Yojana and Kurukshetra Gist
  • Donate
  • Contact Us

If you are interested in advertising to our audience, submit the advertising enquiry form.

Advertising Enquiry
Computer

Create Screen Recorder in Python

Gk Scientist December 18, 2022 No Comments
Tweet WhatsApp Telegram

Create Screen Recorder in Python:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) Open the PyCharm code editor and create a new project in it. We named the project screen_recorder.py. To build a screen recorder in Python, we need to install some packages. For this open the terminal in PyCharm and install four packages i.e. opencv-python, pywin32, numpy, and pyautogui. You install all packages at the same time by simply typing in the terminal following command i.e. pip install opencv-python pywin32 numpy pyautogui and then press enter as shown below.

pip install opencv python pywin32 numpy pyautogui python - Create Screen Recorder in Python

Note: If any package shows an error while using in the code, you can simply install the package by clicking on the red bulb which appears below the error and you can directly install the package from here as shown below.

install pyautogui python - Create Screen Recorder in Python

(2) To create a screen recorder in Python write the following code as shown below.

screen recorder in python code unit - Create Screen Recorder in Python

Source Code: Do proper Code Indentation otherwise, the Source Code does not work and gives an error.

import cv2
import pyautogui
from win32api import GetSystemMetrics
import numpy as np
import time

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

x=cv2.VideoWriter_fourcc(*"XVID")
output=cv2.VideoWriter("A screen_recording.mp4",x,30.0,dimension)

start_time=time.time()
duration=10
end_time=start_time+duration
while True:
    img=pyautogui.screenshot()
    frame_1= np.array(img)
    color=cv2.cvtColor(frame_1,cv2.COLOR_BGR2RGB)
    output.write(color)
    current_time=time.time()
    if current_time > end_time:
        break
output.release()
print("Screen Recorded Successfully......")

(3) Now the video is saved in the path where you have created the Python Project as shown below.

screen recorded using python - Create Screen Recorder in Python

Tutorial MySQL
Tutorial Python
Malicious Software (Malware)
Database Management System (DBMS)
FTP (File Transfer Protocol)
Email (Electronic Mail)
Internet and Its Uses
Python (programming language)– Wikipedia
Prev Article
Next Article

Related Articles

Wireless Networking
Wireless Networking: Wireless Networking facilitates data transmission through the earth’s …
Gk Scientist October 20, 2022 Computer

Wireless Networking

Python Dictionary Methods
Python Dictionary Methods: We can use the PyCharm code editor …
Gk Scientist November 30, 2022 Computer

Python Dictionary Methods

Create Table in MySQL
Create Table in MySQL: (1) In the previous blog we …
Gk Scientist November 10, 2022 Computer

Create Table in MySQL

Multi-Dimensional Array in Java
Multi-Dimensional Array in Java: We can use the Eclipse IDE …
Gk Scientist January 3, 2023 Computer

Multi-Dimensional Array in Java

Python Random Module
Python Random Module: We can use the PyCharm code editor …
Gk Scientist December 3, 2022 Computer

Python Random Module

FTP (File Transfer Protocol)
FTP: FTP is an acronym for File Transfer Protocol. FTP …
Gk Scientist September 17, 2022 Computer

FTP (File Transfer Protocol)

Java for-each Loop
Java for-each Loop: We can use the Eclipse IDE for …
Gk Scientist January 6, 2023 Computer

Java for-each Loop

Implement Queue in Python
Queue in Python: We can use the PyCharm code editor …
Gk Scientist November 29, 2022 Computer

Implement Queue in Python

Leave a Reply Cancel Reply

Search




  • Popular
  • Recent




GK SCIENTIST

General Knowledge One Stop Source

Information

  • About Us
  • Terms and Condition, Disclaimer
  • Contact Us

Android Apps

  • IAS App For English Medium Students
  • IAS Basics App For English Medium Students
  • IAS Hindi App For Hindi Medium Students
DMCA.com Protection Status

Popular Tags

Biology (33) Biology Questions (88) Chemistry (57) Computer (212) Current Affairs (4) Current Content (0) Economy (10) English Essay (172) English Grammar (75) English Literature (10) Geography (83) History (259) Indian Anthropology (11) Indian Polity (14) JKAS Mains Question Papers (17) Mathematics (68) Moral Science (7) NCERT & Other Boards Books (25) Philosophy (114) Physics (89) Political Science (132) RS TV News (33) Science (553) Social Anthropology (7) Social Science (17) Solved Paper (47) UPSC (7) UPSC Mains Question Papers (26)

Downloads

  • NCERT Books
  • Old NCERT Books
  • NIOS Books For IAS, SSC, and State PSC Exam
  • Tamil Nadu Board Books: Important For UPSC, SSC, and State PSC Exam
  • Modern Indian and World History Notes For IAS Exam
  • UPSC Topper 2013 Gaurav Agrawal Notes For IAS Preparation
  • UPSC IAS Prelims General Studies – Previous Year Papers
  • UPSC Mains Question Papers

Copyright © 2023 GK SCIENTIST
Theme by MyThemeShop.com& Hosted On Cloudways

Ad Blocker Detected

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Refresh
 

Loading Comments...