imtools.recmovie

imtools.recmovie(figobj=None, movie=None, savedir=None, fps=None)[source]

Save Matplotlib figures and generate a movie sequences

Parameters:

figobj : Matplotlib figure

Figure to base the movie on

movie : str

Filename of the generated movie

savedir : str

Output directory for video file or name of directory of/for source image files

fps : int

Target frames per second

Returns:

Nothing : None

See also

Matplotlib
a collection of codes illustrating how to use animation in Matplotlib

Examples

The command

>>> recmovie(figobj) 

saves the Matplotlib figure-object figobj in the default directory _tmp as png-image. If the default directory is empty the image will be named _tmp0000.png, otherwise the highest number in the png-file-names incremented by one will be used as filename.

Use

>>> recmovie(figobj,savedir="somedir") 

to save the Matplotlib figure-object figobj in the directory defined by the string savedir. If the directory does not exist, it will be created. If the directory savedir is empty the image will be named _tmp0000.png, otherwise the highest number in the png-file-names incremented by one will be used as filename.

The command recmovie() will attempt to use mencoder to generate an avi-movie composed of the png-images found in the default directory _tmp. The movie’s default name will be composed of the default prefix _tmp and the current date and time. After the movie has been generated the default-directory _tmp and its contents will be deleted.

Use

>>> recmovie(movie="somename") 

to launch mencoder and generate an avi-video composed of the png-images found in the default directory _tmp. The string movie will be used as filename for the generated movie (in the above example a file somename.avi will be created). After the movie has been generated the default-directory _tmp and its contents will be deleted. Similarly

>>> recmovie(savedir="somedir") 

will generate an avi-movie composed of the png-images found in the directory specified by the string savedir. The movie’s name is given by the prefix _tmp and the current date and time. After the movie has been generated it will be moved to the directory savedir. If a movie-file of the same name exists in savedir a WARNING is printed and the movie will not be moved. Analogously,

>>> recmovie(movie="somename",savedir="somedir") 

will generate an avi-movie named “somename” composed of the png-images found in the directory specified by the string savedir. After the movie has been generated it will be moved to the directory savedir. If a movie-file of the same name exists in savedir a WARNING is printed and the movie will not be moved.

Note: the command

>>> recmovie(figobj,movie="somename",savedir="somedir") 

will ONLY save the Matplotlib-figure-object figobj in the directory defined by the string savdir. The optional argument movie will be ignored.

Note: the default-directory, image-format and movie-type can be changed in the source code by editing the variables prefix, imgtype and movtype.