更新时间:2020年03月02日 13:59:52 作者:linnahan https://www.jb51.net/article/181757.htm
import time,threading
from datetime import datetime
from PIL import ImageGrab
from cv2 import *
import numpy as np
from pynput import keyboard
def video_record(): # 录入视频
global name
name = datetime.now().strftime('%Y-%m-%d %H-%M-%S') # 当前的时间(当文件名)
screen = ImageGrab.grab() # 获取当前屏幕
width, high = screen.size # 获取当前屏幕的大小
fourcc = VideoWriter_fourcc('X', 'V', 'I', 'D') # MPEG-4编码,文件后缀可为.avi .asf .mov等
video = VideoWriter('%s.avi' % name, fourcc, 15, (width, high)) # (文件名,编码器,帧率,视频宽高)
print('3秒后开始录制----') # 可选
time.sleep(3)
print('开始录制!')
global start_time
start_time = time.time()
while Tru