Manim 插件生态:manim-slides 幻灯片、配音、物理模拟与自制插件
Manim CE ships a real plugin system: any pip package exposing an entry point under "manim.plugins" is discovered automatically, and `manim plugin --list` shows what's installed. This chapter tours the ecosystem that saves weeks. Manim Slides turns Scene classes into keyboard-driven presentations (arrow keys advance, the optional overlay converts PowerPoint files), the fastest path from script to lecture. Manim Voiceover injects narration: it syncs subtitles and animation timing to speech, with local (edge-tts, gTTS, Coqui TTS) and paid (Azure, ElevenLabs) services behind one API. Manim Physics adds gravity, springs and collision via a Simulation scene namespace. Manim Rubiks Cube renders and twists arbitrary cube states. For teams: writing your own plugin is ~50 lines — a pyproject entry point plus functions registered on manim's namespace — enabling shared house animation across projects. We close with a frank look at maintenance status and picking libraries by commit activity, not README promises.
插件机制:一个入口点的事
Manim CE 的插件是标准 pip 包,只要在打包配置里声明 manim.plugins 入口点就会被自动发现:
pip install manim-slides
manim plugin --list # 查看已安装插件
manim-slides:把 Scene 变成 PPT
教学演示第一刚需。正常写场景,用它的渲染器导出,箭头键翻页、按空格继续中断的动画:
pip install manim-slides
# 场景里用 self.next_slide() 分页
from manim import *
from manim_slides import Slide
class Lecture(Slide):
def construct(self):
title = Text("第一章 导数", font="Microsoft YaHei", font_size=48)
self.play(Write(title))
self.next_slide() # 按键翻到下一"页"
curve = Axes().plot(lambda x: x ** 2, x_range=[-2, 2])
self.play(Create(curve))
self.next_slide()
# 渲染 + 播放
manim-slides render lecture.py Lecture
manim-slides Lecture
也支持导出 HTML(自包含网页演示)和从 PPTX 转换。
Manim Voiceover:自动配音对齐
给动画配讲解的工程化方案:语音驱动的字幕与时间轴对齐,换 TTS 服务不改场景代码:
pip install "manim-voiceover[azure]" # 或 edge-tts / gtts / coqui
from manim_voiceover import VoiceoverScene
from manim_voiceover.services.azure import AzureService
class Narrated(VoiceoverScene):
def construct(self):
self.set_speech_service(AzureService(voice="zh-CN-YunxiNeural"))
with self.voiceover("欢迎来到微积分的第一课") as tracker:
circle = Circle()
self.play(Create(circle), run_time=tracker.duration)
tracker.duration 是这句配音的时长,动画自动等语音说完——不用手调时间轴。
manim-physics:重力与弹簧
pip install manim-physics
from manim_physics import *
class Fall(SpaceScene):
def construct(self):
s = Square().shift(UP * 3)
self.add(s)
self.make_rigid_body(s) # 变刚体
self.make_gravity([s]) # 施加重力
ground = Rectangle(width=12, height=0.3).to_edge(DOWN)
self.add(ground)
self.make_static_body(ground) # 地面固定
self.wait(4)
适合做演示实验(单摆、碰撞、弹簧振子)。物理模拟类插件的结果有随机性,正式视频记得固定 seed 或多渲染几遍挑一版。
自研插件:团队共享动画库
把常用自制动画(比如你们的品牌转场)打包成插件,全组 pip install 即用:
# pyproject.toml 里声明
[project.entry-points."manim.plugins"]
my_transitions = "my_pkg.transitions"
Manim 会在启动时导入该模块,你注册的类即可直接 from manim import MyTransition 式调用(具体以官方文档 Plugins 章为准)。
选插件的三个标准
- 看提交活跃度而不是 README 许诺:半年没动且 issues 堆积的插件慎重。
- 锁定版本:插件与 manim 版本耦合紧,requirements 里同时钉住两者版本号。
- 能退回纯 Manim:插件只用于提效环节(配音、放映),核心动画逻辑保持原生,插件挂了不至于重写。