Skip to content

API Reference

Tagin T edited this page Sep 4, 2026 · 1 revision

API Reference

All modules live under the top-level package real_time_manim. The wheel has no re-exported __init__ API, so import from the submodules directly.


MLWindow — the live renderer

real_time_manim.vulkan_bind

from real_time_manim.vulkan_bind import MLWindow
win = MLWindow(w=1920, h=1080)
win.scene = my_scene          # bind a Manim Scene
win.play(...)                 # run animations
win.close()
Member Type / Signature Purpose
MLWindow(w=1920, h=1080) ctor Open a real-time Vulkan window.
.scene attribute Bind the Manim Scene being driven.
.play(*animations, **kwargs) method Run one or more animations (respects run_time, lag_ratio, …).
.close() method Shut the window down (releases the Vulkan device).
.screenshot(path) method Save the current frame (framebuffer readback) to a BMP.
.screenshot_printwindow(path) method Capture the client area (screen-based; occlusion-sensitive).
.start_record(path, fps=60) method Begin real-time capture of the visible window (background thread).
.stop_record() method Stop capture, encode frames to the MP4, clean temp frames.
.enable_fast_record(path, fps=60, segment=None, hidden=True, count_only=False) method Begin offline capture (pipe or BMP mode).
._finish_fast_record() method Flush/encode an offline capture.

Prefer the high-level helpers in record.py over driving start_record/enable_fast_record by hand.


record — one-call recording

real_time_manim.record

Both helpers accept a Scene subclass, a Scene instance, or a no-arg callable, run it, auto-record every MLWindow it opens, and (by default) clean up the transient media/ folder afterwards. Return {"out_path", "windows", "files"}.

fast_record_scene(scene, out_path=None, *, fps=60, hidden=True, count_only=False, segment=None, overwrite=True, cleanup=True, verbose=True)

Offline, windowless-by-default recording via framebuffer readback piped to ffmpeg. Output defaults to ~/Downloads/output.mp4.

Param Default Meaning
out_path None → ~/Downloads/output.mp4 Destination MP4 (or a directory in segment mode).
fps 60 Output frame rate.
hidden True Hide the Vulkan window while capturing.
count_only False Probe mode — count frames without capturing/rendering.
segment None (start_frame, end_frame) → capture a frame range into BMP files (then out_path is a directory).
overwrite True If False, raise FileExistsError when the target exists.
cleanup True Remove transient manim media/ after recording.
verbose True Print per-window progress.

record_scene(scene, out_path=None, *, fps=60, overwrite=True, cleanup=True, verbose=True)

Records a live, visible window in a background thread (the interactive path). Same return shape and defaults as fast_record_scene (no hidden/count_only/segment — it needs a visible window).

from real_time_manim.record import fast_record_scene, record_scene
fast_record_scene(MyScene)                       # ~/Downloads/output.mp4
fast_record_scene(MyScene, "a.mp4", fps=30, hidden=False)
record_scene(MyScene, "live.mp4")

A scene that opens several windows produces out.mp4, out_part2.mp4, …


util — LaTeX cache & cleanup

real_time_manim.util

from real_time_manim.util import restore_tex_cache, save_tex_cache, clear_media
Function Purpose Notable params
restore_tex_cache(cache_dir, media_dir=None, *, tex_subdir="Tex", only_ext=(".svg",), overwrite=False, dry_run=False, verbose=True) Copy cached SVGs into manim's compile dir so unchanged math is reused (returns count copied). media_dir, tex_subdir, only_ext, overwrite, dry_run, verbose
save_tex_cache(cache_dir, media_dir=None, *, ...) Store newly compiled SVGs back into the cache (returns count saved). same knobs
clear_media(media_dir=None, *, verbose=True) Force-remove the transient media folder. Not optional — always attempts full removal. media_dir, verbose

media_dir defaults to <cwd>/media; manim writes LaTeX SVGs into its Tex sub-folder by default.


Animations

real_time_manim.animations (re-exported by real_time_manim.vulkan_bind)

from real_time_manim.vulkan_bind import Create, Write, Transform, FadeOut, ...
Category Names
Transforms Transform, ReplacementTransform, FadeTransform, FadeTransformPieces, TransformMatchingShapes, TransformMatchingTex
Drawing Create, Uncreate, DrawBorderThenFill, ShowIncreasingSubsets, SpiralIn
Fading FadeIn, FadeOut
Movement / scaling MoveToTarget, MoveAlongPath, GrowFromCenter, GrowFromEdge, GrowFromPoint, GrowArrow, SpinInFromNothing
Text Write, Unwrite, TypeWithCursor, UntypeWithCursor
Rotation Rotate, Rotating
Effects ApplyWave, Circumscribe, Indicate, ShowPassingFlash, Blink, Homotopy
Grouping / timing AnimationGroup, Succession
Numeric TextDecimalNumber
Base Animation, Wait, Add

See Recording for the recorders and Internals for how animations are tracked on mobjects.

Clone this wiki locally