python 螢幕、鏡頭錄製
使用pyautogui 、 openCVpyautogui 用來抓螢幕寬高,及螢幕截圖
123456789101112131415161718192021222324252627282930313233343536373839import osimport pyautoguiimport timeimport cv2import numpy as np# 螢幕寬高screen_width, screen_height = pyautogui.size()# 設定視頻文件參數fourcc = cv2.VideoWriter_fourcc(*'XVID')out = cv2.VideoWriter('screen_recording.avi', fourcc, 20.0, (screen_width, screen_height))# 錄製時間(秒)duration = 5# 開始錄製start_time = time.time()while (time.time() - start_time) < duration: # 截取當前螢幕畫 ...