#----------------------------------------------------------------------
#saveMovieToFile - Write a list of pictures to files in order.
#movie - A list of pictures.
#dir - The directory where the pictures should be saved.
#name - The starting portion of the filenames. For example if name is "box"
# the filenames will look like "box000.jpg", "box001.jpg" etc.
#firstFrame - Where to start numbering frames. For example if this is 4,
# the first file will be named "box004.jpg".
#----------------------------------------------------------------------
def saveMovieToFile(movie, dir, name, firstFrame):
curFrame = firstFrame
for index in range(len(movie)):
if movie[index] != 0:
curName =dir+ name + "%03i" % curFrame + ".jpg"
writePictureTo(movie[index], curName)
curFrame= curFrame+1
Here is an example of calling this function:
>>> saveMovieToFile(movieA, 'M:/CS107/Movies/', 'rectangle', 0)
>>> saveMovieToFile(movieB, 'M:/CS107/Movies/', 'rectangle', 3)
Assuming that movieA and movieB are lists containing three pictures
each, the result will be the creation of the following 6 files: