Archived:How to record video with PySymbian
This snippet shows how to record video in Python.
Note: The camera module is not available for S60 1st Edition.
Valid file formats must be used. Their availability may vary from one device generation to another and they tipically include 3GP, MP4.
import appuifw, e32, camera
app_lock = e32.Ao_lock()
#Define the exit function
#Cancel the timer when the user exits, if it has not expired
#Close the viewfinder
#Release the camera so that other programs can use it
appuifw.app.exit_key_handler = quit
#Function for displaying the viewfinder
def video_callback(err, current_state):
if current_state == camera.EPrepareComplete:
video_savepath = u"C:\\vid.mp4"
#This is the path and name of the video to be recorded
appuifw.app.body = appuifw.Canvas()
#Start the viewfinder
vid = camera.start_record(video_savepath, video_callback)
#Instantiate a timer
t = e32.Ao_timer()
#Record for 10 seconds, then stop
#Wait for the user to request the exit
The viewfinder will be displayed on the device's screen and a video clip will be recorded to the specified path for the specified duration (note that due to hardware capabilities and processes executed, the actual duration of the recorded clip may vary). Recording will automatically stop after that duration and the script will wait for the user to exit.