concept-to-video

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Concept to Video

概念转视频

Creates animated explainer videos from concepts using Manim (Python) as a programmatic animation engine.
以Manim(Python)作为程序化动画引擎,将概念转换为动画讲解视频。

Reference Files

参考文件

FilePurpose
references/scene-patterns.md
Common scene patterns for different concept types with reusable templates
scripts/render_video.py
Wrapper around Manim CLI — handles quality, format, output path cleanup
文件路径用途
references/scene-patterns.md
针对不同概念类型的常见场景模式,包含可复用模板
scripts/render_video.py
Manim CLI的封装脚本 — 处理画质、格式、输出路径清理等操作

Why Manim as the engine

为何选择Manim作为引擎

Manim is the "SVG of video" — you write Python code that describes animations declaratively, and it renders to MP4/GIF at any resolution. The Python scene file IS the editable intermediate: the user can see the code, request changes ("make the arrows red", "add a third step", "slow down the transition"), and only do a final high-quality render once satisfied. This makes the workflow iterative and controllable, exactly like concept-to-image uses HTML as an intermediate.
Manim堪称“视频界的SVG”——你可以编写Python代码来声明式地描述动画,它会渲染出任意分辨率的MP4/GIF文件。Python场景文件就是可编辑的中间产物:用户可以查看代码,提出修改需求(比如“将箭头改成红色”、“添加第三个步骤”、“放慢过渡速度”),直到满意后再进行最终的高质量渲染。这种工作流具备迭代性和可控性,就像“概念转图片”使用HTML作为中间产物一样。

Workflow

工作流

Concept → Manim scene (.py) → Preview (low-quality) → Iterate → Final render (MP4/GIF)
  1. Interpret the user's concept — determine the best animation approach
  2. Design a self-contained Manim scene file — one file, one Scene class
  3. Preview by rendering at low quality (
    -ql
    ) for fast iteration
  4. Iterate on the scene based on user feedback
  5. Export final video at high quality using
    scripts/render_video.py
概念 → Manim场景文件(.py) → 预览(低画质) → 迭代优化 → 最终渲染(MP4/GIF)
  1. 解读概念 — 确定最佳的动画实现方式
  2. 设计Manim场景 — 创建独立的Manim场景文件,一个文件对应一个Scene类
  3. 预览渲染 — 以低画质渲染(
    -ql
    )实现快速迭代
  4. 迭代优化 — 根据用户反馈调整场景内容
  5. 导出成品 — 使用
    scripts/render_video.py
    进行高质量最终渲染

Step 0: Ensure dependencies

步骤0:确保依赖已安装

Before writing any scene, ensure Manim is installed:
bash
undefined
在编写任何场景之前,确保已安装Manim:
bash
undefined

System deps (usually pre-installed)

系统依赖(通常已预装)

apt-get install -y libpango1.0-dev libcairo2-dev ffmpeg 2>/dev/null
apt-get install -y libpango1.0-dev libcairo2-dev ffmpeg 2>/dev/null

Python package

Python包

pip install manim --break-system-packages -q

Verify with: `python3 -c "import manim; print(manim.__version__)"`
pip install manim --break-system-packages -q

验证安装:`python3 -c "import manim; print(manim.__version__)"`

Step 1: Interpret the concept

步骤1:解读概念

Determine the best animation pattern. Read
references/scene-patterns.md
for detailed templates.
User intentAnimation patternKey Manim primitives
Explain a pipeline/flowSequential flow animationArrow, Rectangle, Text, AnimationGroup
Show architecture layersLayer build-upVGroup, Arrange, FadeIn with shift
Algorithm step-throughState machine transitionsTransform, ReplacementTransform, Indicate
Compare approachesSide-by-side morphSplit screen VGroups, simultaneous animations
Data transformationObject metamorphosisTransform chains, color transitions
Mathematical conceptEquation + geometric proofMathTex, geometric shapes, Rotate, Scale
Agent/multi-system interactionMessage passing animationArrows between entities, Create/FadeOut
Training/optimization loopIterative cycle animationLoop with Transform, ValueTracker, plots
Timeline/historyLeft-to-right progressionNumberLine, sequential Indicate
确定最佳的动画模式。可阅读
references/scene-patterns.md
获取详细模板。
用户需求动画模式核心Manim原语
讲解流程/数据流顺序流动画Arrow, Rectangle, Text, AnimationGroup
展示架构分层分层构建动画VGroup, Arrange, FadeIn with shift
算法分步演示状态机转场动画Transform, ReplacementTransform, Indicate
对比不同方案并排变形动画分屏VGroups, 同步动画
数据转换对象变形动画变换链、颜色过渡
数学概念公式+几何证明动画MathTex, 几何图形, Rotate, Scale
Agent/多系统交互消息传递动画实体间箭头、Create/FadeOut
训练/优化循环迭代循环动画带Transform的循环、ValueTracker、图表
时间线/历史从左到右推进动画NumberLine, 顺序Indicate

Step 2: Design the Manim scene

步骤2:设计Manim场景

Core rules:
  • Single file, single Scene class: Everything in one
    .py
    file with one
    class XxxScene(Scene)
    .
  • Self-contained: No external assets unless absolutely necessary. Use Manim primitives for everything.
  • Readable code: The scene file IS the user's artifact. Use clear variable names, comments for each animation beat.
  • Color with intention: Use Manim's color constants (BLUE, RED, GREEN, YELLOW, etc.) or hex colors. Max 4-5 colors. Every color should encode meaning.
  • Pacing: Include
    self.wait()
    calls between logical sections. 0.5s for breathing room, 1-2s for major transitions.
  • Text legibility: Use
    font_size=36
    minimum for body text,
    font_size=48+
    for titles. Test at target resolution.
  • Scene dimensions: Default Manim canvas is 14.2 × 8 units (16:9). Keep content within ±6 horizontal, ±3.5 vertical.
核心规则:
  • 单文件单Scene类:所有内容放在一个
    .py
    文件中,且仅包含一个
    class XxxScene(Scene)
    类。
  • 自包含:除非绝对必要,否则不使用外部资源。所有元素均使用Manim原语实现。
  • 代码可读性:场景文件是交付给用户的产物。使用清晰的变量名,为每个动画节点添加注释。
  • 有目的性地使用颜色:使用Manim的颜色常量(BLUE、RED、GREEN、YELLOW等)或十六进制颜色。最多使用4-5种颜色,每种颜色都应承载特定含义。
  • 节奏控制:在逻辑段落之间添加
    self.wait()
    调用。0.5秒用于过渡缓冲,1-2秒用于主要转场。
  • 文本可读性:正文文本最小字号为
    font_size=36
    ,标题字号至少为
    font_size=48
    。需在目标分辨率下测试可读性。
  • 场景尺寸:Manim默认画布为14.2×8单位(16:9比例)。内容需保持在水平±6、垂直±3.5的范围内。

Animation best practices

动画最佳实践

python
undefined
python
undefined

DO: Use animation groups for simultaneous effects

推荐:使用动画组实现同步效果

self.play(FadeIn(box), Write(label), run_time=1)
self.play(FadeIn(box), Write(label), run_time=1)

DO: Use .animate syntax for property changes

推荐:使用.animate语法实现属性变更

self.play(box.animate.shift(RIGHT * 2).set_color(GREEN))
self.play(box.animate.shift(RIGHT * 2).set_color(GREEN))

DO: Stagger related elements

推荐:错开相关元素的动画时机

self.play(LaggedStart(*[FadeIn(item) for item in items], lag_ratio=0.2))
self.play(LaggedStart(*[FadeIn(item) for item in items], lag_ratio=0.2))

DON'T: Add/remove without animation (jarring)

不推荐:无动画地添加/移除元素(过于突兀)

self.add(box) # Only for setup before first frame
self.add(box) # 仅在第一帧之前的初始化阶段使用

DON'T: Make animations too fast

不推荐:动画速度过快

self.play(Transform(a, b), run_time=0.3) # Too fast to read
undefined
self.play(Transform(a, b), run_time=0.3) # 快到无法看清
undefined

Structure template

结构模板

python
from manim import *

class ConceptScene(Scene):
    def construct(self):
        # === Section 1: Title / Setup ===
        title = Text("Concept Name", font_size=56, weight=BOLD)
        self.play(Write(title))
        self.wait(1)
        self.play(FadeOut(title))

        # === Section 2: Core animation ===
        # ... main content here ...

        # === Section 3: Summary / Conclusion ===
        # ... wrap-up animation ...
        self.wait(2)
python
from manim import *

class ConceptScene(Scene):
    def construct(self):
        # === 第一部分:标题/初始化 ===
        title = Text("概念名称", font_size=56, weight=BOLD)
        self.play(Write(title))
        self.wait(1)
        self.play(FadeOut(title))

        # === 第二部分:核心动画 ===
        # ... 此处为主要内容 ...

        # === 第三部分:总结/结尾 ===
        # ... 收尾动画 ...
        self.wait(2)

Step 3: Preview render

步骤3:预览渲染

Use low quality for fast iteration:
bash
python3 scripts/render_video.py scene.py ConceptScene --quality low --format mp4
This renders at 480p/15fps — fast enough for previewing timing and layout. Present the video to the user.
使用低画质实现快速迭代:
bash
python3 scripts/render_video.py scene.py ConceptScene --quality low --format mp4
此命令会以480p/15fps渲染——速度足够快,可用于预览时间节奏和布局。将预览视频展示给用户。

Step 4: Iterate

步骤4:迭代优化

Common refinement requests and how to handle them:
RequestAction
"Slower/faster"Adjust
run_time=
params and
self.wait()
durations
"Change colors"Update color constants
"Add a step"Insert new animation block between sections
"Reorder"Move code blocks around
"Different layout"Adjust
.shift()
,
.next_to()
,
.arrange()
calls
"Add labels/annotations"Add
Text
or
MathTex
objects with
.next_to()
"Make it loop"Add matching intro/outro states
常见优化需求及处理方式:
用户请求处理方式
"放慢/加快速度"调整
run_time=
参数和
self.wait()
的持续时间
"修改颜色"更新颜色常量
"添加一个步骤"在段落之间插入新的动画代码块
"调整顺序"移动代码块的位置
"更改布局"调整
.shift()
.next_to()
.arrange()
调用
"添加标签/注释"使用
.next_to()
添加
Text
MathTex
对象
"设置为循环播放"添加匹配的开场/收尾状态

Step 5: Final export

步骤5:最终导出

Once the user is satisfied:
bash
python3 scripts/render_video.py scene.py ConceptScene --quality high --format mp4
当用户满意后,执行以下命令:
bash
python3 scripts/render_video.py scene.py ConceptScene --quality high --format mp4

Quality presets

画质预设

PresetResolutionFPSFlagUse case
low
480p15
-ql
Fast preview
medium
720p30
-qm
Draft review
high
1080p60
-qh
Final delivery
4k
2160p60
-qk
Presentation quality
预设分辨率帧率参数使用场景
low
480p15
-ql
快速预览
medium
720p30
-qm
草案评审
high
1080p60
-qh
最终交付
4k
2160p60
-qk
演示级画质

Format options

格式选项

FormatFlagUse case
mp4
--format mp4
Standard video delivery
gif
--format gif
Embeddable in docs, social
webm
--format webm
Web-optimized
格式参数使用场景
mp4
--format mp4
标准视频交付
gif
--format gif
可嵌入文档、社交媒体
webm
--format webm
网页优化格式

Delivering the output

交付产物

Present both:
  1. The
    .py
    scene file (for future editing)
  2. The rendered video file (final output)
Copy the final video to
/mnt/user-data/outputs/
and present it.
需同时交付:
  1. .py
    场景文件(用于后续编辑)
  2. 渲染完成的视频文件(最终输出)
将最终视频复制到
/mnt/user-data/outputs/
目录后交付给用户。

Error Handling

错误处理

ErrorCauseResolution
ModuleNotFoundError: manim
Manim not installedRun Step 0 setup commands
pangocairo
build error
Missing system dev headers
apt-get install -y libpango1.0-dev
FileNotFoundError: ffmpeg
ffmpeg not installed
apt-get install -y ffmpeg
Scene class not foundClass name mismatchVerify class name matches CLI argument
Overlapping objectsPositions not calculatedUse
.next_to()
,
.arrange()
, explicit
.shift()
calls
Text cut offText too large or positioned near edgeReduce
font_size
or adjust position within ±6,±3.5
Slow renderToo many objects or complex transformationsReduce object count, simplify paths, use lower quality
LaTeX Error
LaTeX not installed (for MathTex)Use
Text
instead, or install
texlive-latex-base
错误原因解决方法
ModuleNotFoundError: manim
未安装Manim执行步骤0的安装命令
pangocairo
构建错误
缺少系统开发依赖头文件执行
apt-get install -y libpango1.0-dev
FileNotFoundError: ffmpeg
未安装ffmpeg执行
apt-get install -y ffmpeg
找不到Scene类类名不匹配验证类名与CLI参数是否一致
对象重叠位置计算错误使用
.next_to()
.arrange()
、显式
.shift()
调用
文本被截断文本过大或位置靠近画布边缘减小
font_size
或调整位置至±6、±3.5范围内
渲染速度慢对象过多或变换复杂减少对象数量、简化路径、使用更低画质
LaTeX Error
未安装LaTeX(用于MathTex)改用
Text
组件,或安装
texlive-latex-base

LaTeX fallback

LaTeX备选方案

If LaTeX is not available, avoid
MathTex
and
Tex
. Use
Text
with Unicode math symbols instead:
python
undefined
如果未安装LaTeX,请避免使用
MathTex
Tex
。改用
Text
结合Unicode数学符号:
python
undefined

Instead of: MathTex(r"\frac{1}{n} \sum_{i=1}^{n} x_i")

替代:MathTex(r"\frac{1}{n} \sum_{i=1}^{n} x_i")

Use: Text("(1/n) Σ xᵢ", font_size=36)

使用:Text("(1/n) Σ xᵢ", font_size=36)

undefined
undefined

Limitations

局限性

  • Manim + ffmpeg required — cannot render without these dependencies.
  • No audio support in this workflow — Manim supports audio but adds complexity. Keep videos silent or add audio post-export.
  • LaTeX optional — MathTex requires a LaTeX installation. Fall back to Text with Unicode for math.
  • Render time scales with complexity — a 30-second 1080p scene with many objects can take 1-2 minutes to render.
  • 3D scenes require OpenGL — ThreeDScene may not work in headless containers. Stick to 2D Scene class.
  • No interactivity — output is a static video file, not an interactive widget.
  • 必须依赖Manim和ffmpeg — 缺少这些工具无法进行渲染。
  • 本工作流不支持音频 — Manim本身支持音频,但会增加复杂度。请保持视频静音,或在导出后添加音频。
  • LaTeX为可选依赖 — MathTex需要安装LaTeX。数学内容可改用带Unicode符号的Text组件。
  • 渲染时间随复杂度增加 — 一个包含大量对象的30秒1080p场景可能需要1-2分钟渲染。
  • 3D场景需要OpenGL支持 — ThreeDScene在无图形界面的容器中可能无法运行。建议使用2D的Scene类。
  • 无交互性 — 输出为静态视频文件,而非交互式组件。

Design anti-patterns to avoid

需避免的设计反模式

  • Walls of text on screen — keep to 3-5 words per label, max 2 lines
  • Everything appearing at once — use staged animations with LaggedStart
  • Uniform timing — vary run_time to create rhythm (fast for simple, slow for important)
  • No visual hierarchy — use size, color, and position to guide attention
  • Rainbow colors — 3-4 intentional colors max
  • Ignoring the grid — align objects to consistent positions using arrange/align
  • 屏幕上出现大段文本 — 每个标签最多3-5个单词,最多2行
  • 所有元素同时出现 — 使用LaggedStart实现分阶段动画
  • 统一的动画时长 — 调整run_time创造节奏(简单动画快,重要内容慢)
  • 无视觉层次 — 使用大小、颜色和位置引导用户注意力
  • 彩虹色滥用 — 最多使用3-4种有明确目的的颜色
  • 无视布局网格 — 使用arrange/align方法将对象对齐到一致位置