concept-to-video
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConcept to Video
概念转视频
Creates animated explainer videos from concepts using Manim (Python) as a programmatic animation engine.
以Manim(Python)作为程序化动画引擎,将概念转换为动画讲解视频。
Reference Files
参考文件
| File | Purpose |
|---|---|
| Common scene patterns for different concept types with reusable templates |
| Wrapper around Manim CLI — handles quality, format, output path cleanup |
| 文件路径 | 用途 |
|---|---|
| 针对不同概念类型的常见场景模式,包含可复用模板 |
| 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)- Interpret the user's concept — determine the best animation approach
- Design a self-contained Manim scene file — one file, one Scene class
- Preview by rendering at low quality () for fast iteration
-ql - Iterate on the scene based on user feedback
- Export final video at high quality using
scripts/render_video.py
概念 → Manim场景文件(.py) → 预览(低画质) → 迭代优化 → 最终渲染(MP4/GIF)- 解读概念 — 确定最佳的动画实现方式
- 设计Manim场景 — 创建独立的Manim场景文件,一个文件对应一个Scene类
- 预览渲染 — 以低画质渲染()实现快速迭代
-ql - 迭代优化 — 根据用户反馈调整场景内容
- 导出成品 — 使用进行高质量最终渲染
scripts/render_video.py
Step 0: Ensure dependencies
步骤0:确保依赖已安装
Before writing any scene, ensure Manim is installed:
bash
undefined在编写任何场景之前,确保已安装Manim:
bash
undefinedSystem 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 for detailed templates.
references/scene-patterns.md| User intent | Animation pattern | Key Manim primitives |
|---|---|---|
| Explain a pipeline/flow | Sequential flow animation | Arrow, Rectangle, Text, AnimationGroup |
| Show architecture layers | Layer build-up | VGroup, Arrange, FadeIn with shift |
| Algorithm step-through | State machine transitions | Transform, ReplacementTransform, Indicate |
| Compare approaches | Side-by-side morph | Split screen VGroups, simultaneous animations |
| Data transformation | Object metamorphosis | Transform chains, color transitions |
| Mathematical concept | Equation + geometric proof | MathTex, geometric shapes, Rotate, Scale |
| Agent/multi-system interaction | Message passing animation | Arrows between entities, Create/FadeOut |
| Training/optimization loop | Iterative cycle animation | Loop with Transform, ValueTracker, plots |
| Timeline/history | Left-to-right progression | NumberLine, 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 file with one
.py.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 calls between logical sections. 0.5s for breathing room, 1-2s for major transitions.
self.wait() - Text legibility: Use minimum for body text,
font_size=36for titles. Test at target resolution.font_size=48+ - 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种颜色,每种颜色都应承载特定含义。
- 节奏控制:在逻辑段落之间添加调用。0.5秒用于过渡缓冲,1-2秒用于主要转场。
self.wait() - 文本可读性:正文文本最小字号为,标题字号至少为
font_size=36。需在目标分辨率下测试可读性。font_size=48 - 场景尺寸:Manim默认画布为14.2×8单位(16:9比例)。内容需保持在水平±6、垂直±3.5的范围内。
Animation best practices
动画最佳实践
python
undefinedpython
undefinedDO: 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
undefinedself.play(Transform(a, b), run_time=0.3) # 快到无法看清
undefinedStructure 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 mp4This 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:
| Request | Action |
|---|---|
| "Slower/faster" | Adjust |
| "Change colors" | Update color constants |
| "Add a step" | Insert new animation block between sections |
| "Reorder" | Move code blocks around |
| "Different layout" | Adjust |
| "Add labels/annotations" | Add |
| "Make it loop" | Add matching intro/outro states |
常见优化需求及处理方式:
| 用户请求 | 处理方式 |
|---|---|
| "放慢/加快速度" | 调整 |
| "修改颜色" | 更新颜色常量 |
| "添加一个步骤" | 在段落之间插入新的动画代码块 |
| "调整顺序" | 移动代码块的位置 |
| "更改布局" | 调整 |
| "添加标签/注释" | 使用 |
| "设置为循环播放" | 添加匹配的开场/收尾状态 |
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 mp4Quality presets
画质预设
| Preset | Resolution | FPS | Flag | Use case |
|---|---|---|---|---|
| 480p | 15 | | Fast preview |
| 720p | 30 | | Draft review |
| 1080p | 60 | | Final delivery |
| 2160p | 60 | | Presentation quality |
| 预设 | 分辨率 | 帧率 | 参数 | 使用场景 |
|---|---|---|---|---|
| 480p | 15 | | 快速预览 |
| 720p | 30 | | 草案评审 |
| 1080p | 60 | | 最终交付 |
| 2160p | 60 | | 演示级画质 |
Format options
格式选项
| Format | Flag | Use case |
|---|---|---|
| | Standard video delivery |
| | Embeddable in docs, social |
| | Web-optimized |
| 格式 | 参数 | 使用场景 |
|---|---|---|
| | 标准视频交付 |
| | 可嵌入文档、社交媒体 |
| | 网页优化格式 |
Delivering the output
交付产物
Present both:
- The scene file (for future editing)
.py - The rendered video file (final output)
Copy the final video to and present it.
/mnt/user-data/outputs/需同时交付:
- 场景文件(用于后续编辑)
.py - 渲染完成的视频文件(最终输出)
将最终视频复制到目录后交付给用户。
/mnt/user-data/outputs/Error Handling
错误处理
| Error | Cause | Resolution |
|---|---|---|
| Manim not installed | Run Step 0 setup commands |
| Missing system dev headers | |
| ffmpeg not installed | |
| Scene class not found | Class name mismatch | Verify class name matches CLI argument |
| Overlapping objects | Positions not calculated | Use |
| Text cut off | Text too large or positioned near edge | Reduce |
| Slow render | Too many objects or complex transformations | Reduce object count, simplify paths, use lower quality |
| LaTeX not installed (for MathTex) | Use |
| 错误 | 原因 | 解决方法 |
|---|---|---|
| 未安装Manim | 执行步骤0的安装命令 |
| 缺少系统开发依赖头文件 | 执行 |
| 未安装ffmpeg | 执行 |
| 找不到Scene类 | 类名不匹配 | 验证类名与CLI参数是否一致 |
| 对象重叠 | 位置计算错误 | 使用 |
| 文本被截断 | 文本过大或位置靠近画布边缘 | 减小 |
| 渲染速度慢 | 对象过多或变换复杂 | 减少对象数量、简化路径、使用更低画质 |
| 未安装LaTeX(用于MathTex) | 改用 |
LaTeX fallback
LaTeX备选方案
If LaTeX is not available, avoid and . Use with Unicode math symbols instead:
MathTexTexTextpython
undefined如果未安装LaTeX,请避免使用和。改用结合Unicode数学符号:
MathTexTexTextpython
undefinedInstead 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)
undefinedundefinedLimitations
局限性
- 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方法将对象对齐到一致位置