SCREENRECORDER APP KIVY

 Please if you like my content Please do not forget to support this channel on PayPal now for $1 only! Or less 


from PIL import ImageGrab
import numpy as ny
from win32api import GetSystemMetrics
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
import cv2
import time


screenmanager = """

ScreenManager:
Screenrecordmenu:

<Screenrecordmenu>:
name: 'menu'
RelativeLayout:
orientation:'vertical'
pos: self.pos
size: root.size

Label:
text: 'Welcome to screen recorder app'
pos_hint:{'center_x':0.5,'center_y':0.905}
font_size: (self.height/15)* 0.75


Label:
text: 'Press the screen record button to screen record the screen'
pos_hint:{'center_x':0.5,'center_y':0.705}
font_size: (self.height/15)* 0.65


Label:
text: 'Input the name of the file'
pos_hint:{'center_x':0.3,'center_y':0.555}
font_size: (self.height/15)* 0.65


Label:
text: 'Input the number of minutes'
pos_hint:{'center_x':0.3,'center_y':0.455}
font_size: (self.height/15)* 0.65

TextInput:
id: screenrecordname
size_hint: 0.2, 0.05
pos_hint:{'center_x':0.6,'center_y':0.555}

TextInput:
id: screenrecordmin
size_hint: 0.2, 0.05
pos_hint:{'center_x':0.62,'center_y':0.455}


Button:
text:'Screen Record'
size_hint: .3,.1
pos_hint:{'center_x':0.47,'center_y':0.354}
on_release: root.screenrecord()



"""



class Screenrecordmenu(Screen):

def screenrecord(self):
App.get_running_app().root_window.minimize()
min = time.time()+60*eval(self.ids.screenrecordmin.text)
height = GetSystemMetrics(1)
width = GetSystemMetrics(0)

file_name = f'{self.ids.screenrecordname.text}.mp4'
format = cv2.VideoWriter_fourcc('m','p','4','v')
final_video = cv2.VideoWriter(file_name,format,20.0,(width,height))

while time.time() < min:
img = ImageGrab.grab(bbox=(0,0, width,height))
img_ny = ny.array(img)
final_image = cv2.cvtColor(img_ny, cv2.COLOR_BGR2RGB)
final_video.write(final_image)

App.get_running_app().root_window.restore()




class Screenrecord (App):

def build(self):
screen = Builder.load_string(screenmanager)
return screen

sm = ScreenManager()
sm.add_widget(Screenrecordmenu(name='menu'))
Screenrecord().run()

No comments:

Post a Comment

Drawing App For Kivy

  Below here is the source code for Drawing Application for kivy. Please if you like this content.  Don't forget to Subscribe to my YouT...