Screen Recording App Using Python



Hope you all are safe at home. In our today's blog, we are going to develop an application to record the screen for our own personal computer. We are going to develop this App using Python. Let's start our session.

System Requirement:

To develop Screen Recording App, we need python installed in our PC. We are going to use Jupyter notebook to code. I would recommend you to install anaconda to work with Jupyter notebook. Use this link to download Anaconda for you PC. Other packages that we will use in our App development are
      • Tkinter
      • pyautogui
      • Numpy
      • OpenCV

Initial Set-Up:

Numpy will be available by default in anaconda and other packages should be downloaded manually. To download all the required packages connect your PC to the internet connection and open anaconda command prompt. In the command prompt window, type the below shown commands to start installation of those packages.

Tkinter: It is the package which is used for GUI programming using python. To install Tkinter, type


                   conda install -c anaconda tk

Pyautogui: It is responsible for GUI automation and controls the keyboard and mouse from python scripting. To install Pyautogui, type

                   conda install -c conda-forge pyautogui

OpenCV: It is famous package in python used in the field of computer vision and machine learning. To install OpenCV. type

                   conda install -c conda-forge opencv

Now, we are all set and lets start our Screen Recording App development.

How it Works:

With Pyautogui, we take a screenshot of our computer screen every second and form a sequence on frame from this screenshot. Frames are formed using OpenCV and finally, these sequential frames are wrote into an video file using CV2.

Coding - Screen Recording:

Step 1: Open a fresh Jupyter notebook from anaconda navigator and import all the required packages as shown below in the snippet.


Step 2: With Tkinter, Add two buttons. One to Start Recording and another button to Stop recording.  We can also add timer as a label to show record timings. The basic layout after adding two buttons will be like below shown snippet.



Step 3: Add functionality to the start button. Define a function to start recording the screen. Refer the below code block for start function



Step 4: Add Functionality to Stop button. Define a stop function to stop the recording and save the output video that is recorded. Function snippet is as follows,


Step 5: Execute the main loop to start the execution of application.

Recorded Video - Output:

The below given video was recorded using the Screen Recording App that we built.


Full Program:


Enhancement in App:

Hope you all enjoyed this article. Try developing your own Screen Recording App and you can also enhance your application by adding a another button to pause the Screen recording and resume it. You can also try customizing the application name, logo, color and font size.

We can also convert this python code to an executable file (.exe), which we will learn in another post. Try this simple python code to develop your first application and let me know your thoughts and doubts in the below comment session.

Like my Facebook page LearntoSpark for regular updates.

Happy Learning!!!

Post a Comment

0 Comments