

- #Simple screenshot program how to
- #Simple screenshot program install
- #Simple screenshot program software
Note that if you increase the FPS, you may see the video is a bit sped up, that's because your CPU can't handle that speed. The loop will finish once the seconds are passed or if you hit the "q" button.

After that, we need to convert that frame into RGB, that's because OpenCV uses BGR by default. # make sure everything is closed when exitedįirst, we use the screenshot() function which returns an image object, so we need to convert it to a proper numpy array. # convert these pixels to a proper numpy array to work with OpenCVįrame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) Now we need to keep capturing screenshots and writing to the file in a loop until the seconds are passed or the user clicks the "q" button, here is the main loop for that: for i in range(int(record_seconds * fps)): The record_seconds is the number of seconds you want to record, if you want to record until pressing the "q" button, then simply set this to a large value. We also set the FPS to 12.0 and pass these parameters to the cv2.VideoWriter() object.

We're getting the screen resolution from the pyautogui.size() function which returns the height and the width of the screen as a two-integer tuple.įourcc is the video codec library that OpenCV will use to write the video file, we specified XVID here. Out = cv2.VideoWriter("output.avi", fourcc, fps, (SCREEN_SIZE)) Let's initialize the format we gonna use to write our video file ( named "output.avi" ): # display screen resolution, get it using pyautogui itself Write that numpy array to a file with the proper format using a video writer in OpenCV.Convert that screenshot to a numpy array.The process of this tutorial is as follows:
#Simple screenshot program install
Let's get started, first, install the required dependencies for this tutorial: pip3 install numpy opencv-python pyautogui
#Simple screenshot program how to
Related: How to Use Steganography to Hide Secret Data in Images in Python. If you want to record a specific window, then check this tutorial, as it's exactly what you need. This tutorial is about recording your whole screen. In this tutorial, you will learn how to make your own simple screen recorder in Python that you can further extend to your own needs.
#Simple screenshot program software
Many industrial software exists out there that can help you do that very easily though. Screen recording enables you to create demonstration videos, record gaming achievements, and create videos that can be shared online on social media. Disclosure: This post may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.
