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

Commit d559aee

Browse files
Phoenix-031Umesh-01
andauthored
Added screen recorder feature
* added screen recorder * moved screenrecord function to a different file * updated changes * updated PA.py file Co-authored-by: Umesh Singh <83420185+Umesh-01@users.noreply.github.com>
1 parent 1830a99 commit d559aee

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

‎PA.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
import winshell as winshell # pip install winshell
2727
from geopy.geocoders import Nominatim # pip install geopy and pip install geocoder
2828
from geopy import distance
29-
import turtle # pip install turtle
30-
import random # pip install random
31-
import snake_game # user-defined
29+
import turtle
30+
import random
31+
import snake_game
32+
import record
3233

3334
engine = pyttsx3.init()
3435

@@ -75,7 +76,6 @@ def get_command():
7576

7677

7778
if __name__ == '__main__':
78-
7979
wish_user()
8080
while True:
8181
query = get_command().lower()
@@ -652,6 +652,10 @@ def send_whtmsg():
652652

653653
except Exception as e:
654654
pass
655+
656+
elif 'screen recording' in query:
657+
fun_talk('Press Q to stop and save recording') #Screen recorder functionality
658+
record.screen_record()
655659

656660
elif 'snake game' in query:
657661
try:

‎record.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import cv2
2+
import psutil
3+
import numpy as np
4+
import os
5+
import pyautogui
6+
7+
8+
9+
def screen_record(): #Screen Recording function
10+
11+
user = psutil.users()[0].name #gets the user name
12+
f_path = "C:\\Users\\" + user + "\\Desktop"
13+
# f_path = input("Enter where u want to save the file") #can also have an option as to where the user wants to save the file
14+
if os.path.exists(f_path):
15+
save_file = os.path.join(f_path,"output.mp4")
16+
else:
17+
save_file ="output.mp4" #saves the file in the corresponding directory
18+
19+
s_size = (1920,1080)
20+
fps = 10.0 #determines how fast the slow the playback speed will be
21+
22+
fcc = cv2.VideoWriter_fourcc(*"mp4v")
23+
out = cv2.VideoWriter(save_file,fcc,fps,(s_size))
24+
25+
while 1:
26+
27+
img = pyautogui.screenshot()
28+
frm = np.array(img)
29+
frm = cv2.cvtColor(frm,cv2.COLOR_BGR2RGB)
30+
cv2.imshow("recorder",frm)
31+
cv2.namedWindow("recorder",cv2.WINDOW_NORMAL)
32+
cv2.resizeWindow("recorder", 800,800)
33+
out.write(frm)
34+
35+
key = cv2.waitKey(1) # q to close the window and stop recording
36+
if key == 113:
37+
break
38+
39+
cv2.destroyAllWindows()
40+
out.release()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /