Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyautogui
- import cv2
- import numpy as np
- import sys
- import time
- # import click
- import os
- import datetime
- today = datetime.datetime.now()
- date_str = today.strftime('%Y-%m-%d %H:%M:%S')
- date_str = date_str.replace(':','-')
- cur_dir = '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/'))
- filename = date_str + '.avi'
- # @click.command()
- # @click.option('--rec',type=str,default='class_rec',required=False,help="class you will be recording for")
- # @click.option('--filename',type=str,default=date_str + '.avi',required=False,help="you can specify filename/ default is script start datetime")
- # @click.option('--path',type=str,default=cur_dir,required=False,help="path to save folder / default is script location")
- # @click.option('--duration',type=int,default=1,help="duration for screen record / default is 60s")
- # def cli(rec,filename,path,duration):
- def cli():
- resolution = (1920, 1080)
- codec = cv2.VideoWriter_fourcc(*"XVID")
- # filename = f"{path}/{filename}"
- fps = 10.0
- out = cv2.VideoWriter(filename, codec, fps, resolution)
- cv2.namedWindow("Live", cv2.WINDOW_NORMAL)
- cv2.resizeWindow("Live", 480, 270)
- start_time = time.time()
- # duration_in_seconds = duration * 60
- while True:
- current_time = time.time()
- img = pyautogui.screenshot()
- frame = np.array(img)
- frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
- out.write(frame)
- cv2.imshow('Live', frame)
- if cv2.waitKey(1) == ord('q'):
- break
- # if current_time - start_time > duration_in_seconds:
- # break
- out.release()
- cv2.destroyAllWindows()
- if __name__ == '__main__':
- cli()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement