×
Namespaces

Variants
Actions

Archived:How to record video with PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

This snippet shows how to record video in Python.

Article Metadata
Tested with
Devices(s): Nokia N95, Nokia E90
CompatibilityPlatform Security
Capabilities: )
Article
Keywords: camera
Created: bogdan.galiceanu (21 Mar 2008)
Last edited: hamishwillee (14 Jun 2013)

Preconditions

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.

Source code

import appuifw, e32, camera
 
 
app_lock = e32.Ao_lock()
#Define the exit function
def quit():
#Cancel the timer when the user exits, if it has not expired
t.cancel()
#Close the viewfinder
camera.stop_finder()
#Release the camera so that other programs can use it
camera.release()
app_lock.signal()
appuifw.app.exit_key_handler = quit
 
#Function for displaying the viewfinder
def vf(im):
appuifw.app.body.blit(im)
 
def video_callback(err, current_state):
global control_light
if current_state == camera.EPrepareComplete:
control_light=1
else:
pass
 
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
camera.start_finder(vf)
#Start recording
vid = camera.start_record(video_savepath, video_callback)
#Instantiate a timer
t = e32.Ao_timer()
#Record for 10 seconds, then stop
t.after(10, lambda:camera.stop_record())
 
#Wait for the user to request the exit
app_lock.wait()

Postconditions

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.

This page was last modified on 14 June 2013, at 08:10.
77 page views in the last 30 days.