我已经编写了用于逐帧记录屏幕的代码,但是保存文件后,视频播放非常快。我想以正常速度播放视频。
我在ubuntu 16.04上尝试过的代码
import numpy as np
import cv2
# windows, mac
# from PIL import ImageGrab
# linux
import pyscreenshot as ImageGrab
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter("output.avi",fourcc,60,(1600,900))
while True:
# grab fullscreen
frame = ImageGrab.grab()
frame = np.array(frame)
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
out.write(frame)
if cv2.waitKey(50)==27:
break
out.release()
cv2.destroyAllWindows()