toyplot.mp4 module¶
Generate MPEG-4 videos.
- toyplot.mp4.render(canvas, filename, width=None, height=None, scale=None, progress=None)[source]¶
Render a canvas as an MPEG-4 video.
By default, the canvas dimensions in CSS pixels are mapped directly to pixels in the output MPEG-4 video. Use one of width, height, or scale to override this behavior.
- Parameters
canvas (
toyplot.canvas.Canvas
) – Canvas to be rendered.filename (string) – Output video filename.
width (number, optional) – Specify the width of the output video in pixels.
height (number, optional) – Specify the height of the output video in pixels.
scale (number, optional) – Ratio of output video pixels to canvas drawing units.
progress (callback function taking a single frame argument, optional) – Callback function that will receive the number of each frame as it’s written; useful to provide an indication of progress to end-users.
Notes
The individual video frames are rendered using PNG representations of the canvas generated with
toyplot.png.render_frames()
.Examples
>>> def callback(frame): ... print "Writing frame %s" % frame ... toyplot.mp4.render(canvas, "test.mp4", progress=callback)