Image to video using python
complete video recorder using python #without mouse pionter
Code from here:
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version Jun 17 2015)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################
import wx
import wx.xrc
import pyscreenshot
import os
from PIL import ImageGrab
import subprocess
###########################################################################
## Class MyFrame1
###########################################################################
TEMPDIR = 'C:\Users\Md. Khafi Hossain\Desktop\Python Tutorial'
class MyFrame1 ( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Screen Capture", pos = wx.DefaultPosition, size = wx.Size( 208,70 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
self.SetBackgroundColour( wx.Colour( 215, 243, 129 ) )
bSizer1 = wx.BoxSizer( wx.HORIZONTAL )
self.m_button1 = wx.Button( self, wx.ID_ANY, u"Capture", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer1.Add( self.m_button1, 0, wx.ALL, 5 )
self.m_button2 = wx.Button( self, wx.ID_ANY, u"Exit", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer1.Add( self.m_button2, 0, wx.ALL, 5 )
self.count = 1
self.SetSizer( bSizer1 )
self.Layout()
self.m_timer1 = wx.Timer()
self.m_timer1.SetOwner( self, wx.ID_ANY )
self.Centre( wx.BOTH )
# Connect Events
self.m_button1.Bind( wx.EVT_BUTTON, self.OnCaptureClick )
self.m_button2.Bind( wx.EVT_BUTTON, self.OnExitClick )
self.Bind( wx.EVT_TIMER, self.OnTime, id=wx.ID_ANY )
def __del__( self ):
pass
# Virtual event handlers, overide them in your derived class
def OnCaptureClick( self, event ):
self.m_timer1.Start()
event.Skip()
def Capture (self):
pathname = TEMPDIR + '/Image' + str(self.count) + '.png'
if (os.name == 'posix'):
img = pyscreenshot.grab()
img.save(pathname)
elif(os.name == 'nt'):
img = ImageGrab.grab()
img.save(pathname)
f = open(pathname, 'rb')
l = f.read(1024)
def OnExitClick( self, event ):
self.m_timer1.Stop()
p = subprocess.call('ffmpeg.exe -framerate 1 -f image2 -i "Image%01d.png" -r 1 -s 1024x768 Video.avi', shell = True)
event.Skip()
def OnTime( self, event ):
self.Capture()
self.count = self.count + 1
event.Skip()
app = wx.App(False)
frame = MyFrame1(None)
frame.Show()
app.MainLoop()
*************** End of Code *******************
Comments
Post a Comment