mmfutils.plot.animation

Tools for creating animations and movies.

class mmfutils.plot.animation.MyFuncAnimation(*v, **kw)[source]

Bases: FuncAnimation

Refactoring of the FuncAnimation class to do the following:

  1. Allowing user to store video when generating HTML video.

  2. Allow clean stopping between frames in a NoInterupt context.

new_frame_seq()[source]

Return a new sequence of frame information.

to_html5_video(embed_limit=None, filename=None, extra_args=None)[source]

Convert the animation to an HTML5 <video> tag.

This saves the animation as an h264 video, encoded in base64 directly into the HTML5 video tag. This respects rcParams[“animation.writer”] (default: 'ffmpeg') and rcParams[“animation.bitrate”] (default: -1). This also makes use of the interval to control the speed, and uses the repeat parameter to decide whether to loop.

Parameters:
  • embed_limit (float, optional) – Limit, in MB, of the returned animation. No animation is created if the limit is exceeded. Defaults to rcParams[“animation.embed_limit”] (default: 20.0) = 20.0.

  • filename (str, optional) – (New) If provided, save the movie in this file and keep it, otherwise the movie will be stored in a temporary directory and deleted after.

Returns:

video_tag – An HTML5 video tag with the animation embedded as base64 encoded h264 video. If the embed_limit is exceeded, this returns the string “Video too large to embed.”

Return type:

str

mmfutils.plot.animation.animate(get_frames, fig=None, display=False, **kw)[source]

Make a movie of the frames as returned by get_frames().