Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python screen recorder

# Libraries :
# pip install opencv-python
# pip install opencv-contrib-python
# pip install numpy
# pip install Pillow
# pip install pywin32

import datetime
from PIL import ImageGrab
import numpy as np
import cv2
from win32api import GetSystemMetrics

width = GetSystemMetrics(0)
height = GetSystemMetrics(1)
time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S')
print(time_stamp)
file_name = f'{time_stamp}.mp4'
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
captured_video = cv2.VideoWriter(file_name, fourcc, 20.0, (width, height))

while True:
    img = ImageGrab.grab(bbox=(0, 0, width, height))
    img_np = np.array(img)
    img_final = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
    cv2.imshow('Secret Capture', img_final)
    captured_video.write(img_final)
    if cv2.waitKey(10) == ord('q'):
        break
       
# press q to exit
Comment

PREVIOUS NEXT
Code Example
Python :: message on member joining discord.py 
Python :: how to loop the length of an array pytoh 
Python :: matplotlib legend 
Python :: Print Table Using While Loop In Python 
Python :: how to detect a keypress tkinter 
Python :: pick random entry in dict python 
Python :: how to take list of float as input in python 
Python :: remove negative numbers from list python 
Python :: python dockerfile 
Python :: ver todas linhas dataframe pandas 
Python :: django settings variables 
Python :: convert unix timestamp to datetime python pandas 
Python :: python get time milliseconds 
Python :: matplotlib histogram 
Python :: cv show image python 
Python :: godot code for movement for topdown game 
Python :: python day number from date 
Python :: wait for element to be visible selenium python 
Python :: multipl excel sheets in pandas 
Python :: how to make text bold in tkinter 
Python :: how to clear the console python 
Python :: qspinbox value changed 
Python :: python requests.get pdf An appropriate representation of the requested resource could not be found 
Python :: mnist fashion dataset 
Python :: python format only 1 decimal place 
Python :: python date get day 
Python :: pandas select percentile 
Python :: normalise list python 
Python :: python sort with comparator 
Python :: open a filename starting with in python 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =