Are you searching for Free Screen Recorder????.. STOP!! - Build your own with Python

 Recently I have been searching for a video recorder to make some videos for my YouTube Channel. Most of them were with different packages and pricing suddenly I thought Let's build one.




As I started I realized it is not that simple..JK
I wanted to make it simple as it can be. 
My requirements were just capturing screen only no sound. So I started with pyautogui package and started taking screen shoots.
    # Take screenshot using PyAutoGUI 
    img = pyautogui.screenshot() 

for video file I used CV2 package and make a video codec and file with current time stamp title in the directory.

    fourcc = cv2.VideoWriter_fourcc(*"MJPG")
    now = datetime.now()
    current_time = now.strftime("%H_%M_%S")
    # print current_time
    # create the video write object
    out = cv2.VideoWriter("recording_"+current_time+".avi", fourcc, 10, (1366768))

The thing taking those screenshots and aligning them to array so numpy package imported 

        # Convert the screenshot to a numpy array 
        frame = np.array(img) 

now mapping this array to the file we have created earlier for video creation.

        # Convert it from BGR(Blue, Green, Red) to 
        # RGB(Red, Green, Blue) 
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    
        # Write it to the output file 
        out.write(frame) 

                                                               Isn't this so simple 


This will start recording screen and converting screenshot to a video right away. using this I have implemented a video recording App with Tinker package which works as a stop watch where you begin clock it will start recording and pause and resume as well.
here is the video for you.




Happy Coding👦👦👦👦



Comments