Reputation: 117
Is there a library for making a screen recorder application in python? i think it would be fun to make somthing like that. but a library that will work on linux im using ubuntu
Thanks !
Upvotes: 5
Views: 15994
Reputation: 53
Using MSS is an excellent option for screen recording using python.
For example, using this code from http://python-mss.readthedocs.io/examples.html, I got an average fps of 60.
import time
import cv2
import mss
import numpy
with mss.mss() as sct:
# Part of the screen to capture
monitor = {'top': 40, 'left': 0, 'width': 800, 'height': 640}
while 'Screen capturing':
last_time = time.time()
# Get raw pixels from the screen, save it to a Numpy array
img = numpy.array(sct.grab(monitor))
# Display the picture
cv2.imshow('OpenCV/Numpy normal', img)
# Display the picture in grayscale
# cv2.imshow('OpenCV/Numpy grayscale',
# cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))
print('fps: {0}'.format(1 / (time.time()-last_time)))
# Press "q" to quit
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
Upvotes: 2
Reputation: 20531
recordscreen.py is a command line option wrapper for avconv (previously for ffmpeg) video capturing/converting tool. Implementing this in pure Python will be too slow, but of course you can always create useful bindings for those tools, or improve existing ones, such as AVBin.
Upvotes: 0
Reputation: 104080
I know of no mechanism to perform screen recording in Python. However, you may be able to use Python to control one of the many existing screen recording programs:
Upvotes: 1