Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc00acfe

Browse files
committed
added screen recorder tutorial
1 parent092db32 commitc00acfe

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

‎general/screen-recorder/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[How to Make a Screen Recorder in Python](https://www.thepythoncode.com/article/make-screen-recorder-python)
2+
To run this:
3+
-`pip3 install -r requirements.txt`
4+
-`python3 screen_recorder.py`
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
numpy
2+
opencv-python
3+
pyautogui
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
importcv2
2+
importnumpyasnp
3+
importpyautogui
4+
5+
# display screen resolution, get it from your OS settings
6+
SCREEN_SIZE= (1920,1080)
7+
# define the codec
8+
fourcc=cv2.VideoWriter_fourcc(*"XVID")
9+
# create the video write object
10+
out=cv2.VideoWriter("output.avi",fourcc,20.0, (SCREEN_SIZE))
11+
12+
whileTrue:
13+
# make a screenshot
14+
img=pyautogui.screenshot()
15+
# convert these pixels to a proper numpy array to work with OpenCV
16+
frame=np.array(img)
17+
# convert colors from BGR to RGB
18+
frame=cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
19+
# write the frame
20+
out.write(frame)
21+
# show the frame
22+
cv2.imshow("screenshot",frame)
23+
# if the user clicks q, it exits
24+
ifcv2.waitKey(1)==ord("q"):
25+
break
26+
27+
# make sure everything is closed when exited
28+
cv2.destroyAllWindows()
29+
out.release()
30+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp