-
Notifications
You must be signed in to change notification settings - Fork 1
Recording
Recording is the most user-facing feature, so it is wrapped into two one-call
helpers in real_time_manim.record. Everything below documents both the helpers
and the lower-level hooks they drive.
record_scene |
fast_record_scene |
|
|---|---|---|
| Window | visible (user watches it) |
hidden by default (hidden=True) |
| Capture | background thread screenshots the live window at fps
|
framebuffer readback piped straight to ffmpeg |
| Speed | wall-clock (user-paced) | full speed, no compositing |
| Output default | ~/Downloads/output.mp4 |
~/Downloads/output.mp4 |
Both accept a Scene subclass / instance / callable, auto-record each MLWindow
the scene opens, and clean up the transient media/ folder by default.
from real_time_manim.record import fast_record_scene, record_scene
record_scene(MyScene, "live.mp4", fps=30) # show the window while recording
fast_record_scene(MyScene, "offline.mp4", fps=60) # hidden, as fast as possible-
Previews / demos for others →
record_scene(they see it happen live). -
CI, batch, or just a file you need fast →
fast_record_scene. -
Only want a frame count (probe) →
fast_record_scene(..., count_only=True).
fast_record_scene maps to MLWindow.enable_fast_record, which has three modes:
-
Pipe mode (default): every frame is
SaveScreenshot→ the BMP pixel data is parsed and raw BGR is piped to a residentffmpegon stdin → one MP4. No intermediate files on disk. -
BMP / segment mode (
segment=(start, end)): saves each frame as its own BMP into a directory, for range capture or parallel encoding. Whensegmentis set,out_pathis treated as a directory. -
count_only: advances frames but captures nothing — returns how many frames the scene would produce. Useful for estimating length without rendering.
record_scene maps to MLWindow.start_record / stop_record. A background
daemon thread snapshots the framebuffer at the requested fps into a temp
directory; stop_record joins the thread and encodes the frame sequence with
ffmpeg using the actual capture rate (so duration matches wall-clock time, even
if the window can't keep up). Temp frames are removed afterwards.
If a scene opens several MLWindows in sequence, the helpers emit one file per
window: out.mp4, out_part2.mp4, out_part3.mp4, and each produced path is
reported in the returned files.
Rendering leaves transient media/Tex output (see Math Rendering).
By default the recorders remove it for you after the run (cleanup=True). Set
cleanup=False if you want to keep the raw media directory.
You usually won't need these, but they are available on MLWindow:
win.start_record("out.mp4", fps=60) # begin live capture
win.stop_record() # encode + finish
win.enable_fast_record("f.mp4", fps=60, hidden=True) # begin offline capture
win._finish_fast_record() # flush + encode
win.screenshot("frame.bmp") # single-frame readbackRecording shells out to ffmpeg (libx264, yuv420p). If ffmpeg is missing,
recorders print an error and (for live mode) leave the raw frames in a temp dir
for manual encoding.