Communitygithub.com

影片編輯工具包 (Manim 影片製作管線)

使用 Manim Community Edition 建立數學與技術動畫的生產管線,可產出 3Blue1Brown 風格的解說影片、演算法視覺化、方程式推導、架構圖與資料故事。

影片編輯工具包 (Manim 影片製作管線) 是什麼?

這是一套專為教學與技術解說動畫設計的生產管線,以 Manim Community Edition 為核心。它提供嚴謹的創作標準與流程,從敘事規劃(plan.md)、程式編寫(script.py)、渲染、拼接到配音,確保每一幀畫面都能有效傳遞知識。支援多種模式,如概念解說、方程式推導、演算法視覺化、資料故事、架構圖、論文解說與 3D 視覺化,並內建色彩調色盤、動畫速度建議與字型規範。此技能尤擅長產出 3Blue1Brown 風格的數學動畫,並透過詳細的參考文件(涵蓋動畫、物件、設計、渲染、故障排除等)讓開發者能快速上手,無需瀏覽器或 GPU。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/govindgoel2001/video-editing-toolkit/tree/HEAD/vendor/video-use/skills/manim-video

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Manim 影片製作管線

創作標準

這是教育電影。每個畫面都在教學。每個動畫都在揭示結構。

在撰寫任何程式碼之前,先釐清敘事弧線。這段動畫要糾正什麼誤解?「頓悟時刻」在哪裡?什麼樣的視覺故事能帶領觀眾從困惑走向理解?使用者的提示是起點——請以教學的野心來解讀它。

幾何先於代數。 先展示形狀,再展示方程式。視覺記憶的編碼速度比符號記憶更快。當觀眾在看到公式之前先看到幾何圖案時,方程式會顯得更理所當然。

初版渲染的品質不容妥協。 輸出必須在不需要修改的情況下,在視覺上清晰且美學上一致。如果看起來雜亂、時間控制不佳,或像「AI 生成的投影片」,那就是失敗。

不透明度分層引導注意力。 永遠不要讓所有元素都以全亮度顯示。主要元素為 1.0,背景元素為 0.4,結構元素(軸線、網格)為 0.15。大腦會分層處理視覺顯著性。

呼吸空間。 每個動畫之後都需要 self.wait()。觀眾需要時間來吸收剛剛出現的內容。千萬不要在動畫之間匆忙切換。在關鍵揭示之後暫停 2 秒鐘絕不會浪費。

統一的視覺語言。 所有場景共用一套色彩調色盤、一致的字體大小與匹配的動畫速度。一個技術正確但每個場景都使用隨機不同顏色的影片,在美學上是失敗的。

先決條件

執行 scripts/setup.sh 以驗證所有依賴項。需要:Python 3.10+、Manim Community Edition v0.20+(pip install manim)、LaTeX(Linux 上為 texlive-full,macOS 上為 mactex)以及 ffmpeg。參考文件已針對 Manim CE v0.20.1 進行測試。

模式

模式輸入輸出參考資料
概念解說主題/概念帶有幾何直覺的動畫解說references/scene-planning.md
方程式推導數學表達式逐步動畫證明references/equations.md
演算法視覺化演算法描述包含資料結構的逐步執行過程references/graphs-and-data.md
資料故事數據/指標動畫圖表、比較、計數器references/graphs-and-data.md
架構圖系統描述元件逐步建立並顯示連接references/mobjects.md
論文解說研究論文關鍵發現與方法的動畫展示references/scene-planning.md
3D 視覺化3D 概念旋轉曲面、參數曲線、空間幾何references/camera-and-3d.md

技術棧

每個專案使用單一 Python 腳本。無需瀏覽器、Node.js 或 GPU。

層級工具用途
核心Manim Community Edition場景渲染、動畫引擎
數學LaTeX (texlive/MiKTeX)透過 MathTex 渲染方程式
影片 I/Offmpeg場景拼接、格式轉換、音訊多工
語音合成ElevenLabs / Qwen3-TTS (可選)旁白配音

管線

規劃 --> 編寫 --> 渲染 --> 拼接 --> 音訊 (可選) --> 審查
  1. 規劃 — 撰寫 plan.md,包含敘事弧線、場景列表、視覺元素、色彩調色盤、旁白腳本
  2. 編寫 — 撰寫 script.py,每個場景一個類別,可獨立渲染
  3. 渲染 — manim -ql script.py Scene1 Scene2 ... 用於草稿,-qh 用於正式輸出
  4. 拼接 — 使用 ffmpeg 將場景片段串接成 final.mp4
  5. 音訊 (可選) — 透過 ffmpeg 加入旁白和/或背景音樂。請參閱 references/rendering.md
  6. 審查 — 渲染預覽靜止畫面,對照計劃驗證,進行調整

專案結構

project-name/
  plan.md                # 敘事弧線、場景分解
  script.py              # 所有場景位於一個檔案中
  concat.txt             # ffmpeg 場景列表
  final.mp4              # 拼接後的輸出
  media/                 # 由 Manim 自動產生
    videos/script/480p15/

創意方向

色彩調色盤

調色盤背景主要次要強調色使用案例
經典 3B1B#1C1C1C#58C4DD (藍色)#83C167 (綠色)#FFFF00 (黃色)一般數學/資訊科學
溫暖學術#2D2B55#FF6B6B#FFD93D#6BCB77平易近人
霓虹科技#0A0A0A#00F5FF#FF00FF#39FF14系統、架構
單色調#1A1A2E#EAEAEA#888888#FFFFFF極簡風格

動畫速度

情境run_time動畫後的 self.wait()
標題/介紹出現1.5 秒1.0 秒
關鍵方程式揭示2.0 秒2.0 秒
轉換/變形1.5 秒1.5 秒
輔助標籤0.8 秒0.5 秒
FadeOut 清理0.5 秒0.3 秒
「頓悟時刻」揭示2.5 秒3.0 秒

字型尺寸比例

角色字型大小用途
標題48場景標題、開場文字
標題列36場景內的章節標頭
正文30解說文字
標籤24註解、軸標籤
說明文字20字幕、附帶細則

字型

所有文字使用等寬字型。 Manim 的 Pango 渲染器在處理比例字型時,所有尺寸都會產生壞掉的字距調整。完整建議請參閱 references/visual-design.md。

MONO = "Menlo"  # 在檔案開頭定義一次

Text("傅立葉級數", font_size=48, font=MONO, weight=BOLD)  # 標題
Text("n=1: sin(x)", font_size=20, font=MONO)                # 標籤
MathTex(r"\nabla L")                                         # 數學(使用 LaTeX)

為確保可讀性,最小 font_size=18。

每個場景的變化

切勿對所有場景使用完全相同的設定。對於每個場景:

  • 從調色盤中選擇不同的主色
  • 採用不同的佈局 — 不要總是置中所有東西
  • 採用不同的動畫入場方式 — 在 Write、FadeIn、GrowFromCenter、Create 之間輪替
  • 採用不同的視覺重量 — 有些場景資訊密集,其他場景則留白較多

工作流程

第一步:規劃 (plan.md)

在任何程式碼之前,先撰寫 plan.md。完整的範本請參閱 references/scene-planning.md。

第二步:編寫 (script.py)

每個場景一個類別。每個場景都可獨立渲染。

from manim import *

BG = "#1C1C1C"
PRIMARY = "#58C4DD"
SECONDARY = "#83C167"
ACCENT = "#FFFF00"
MONO = "Menlo"

class Scene1_Introduction(Scene):
    def construct(self):
        self.camera.background_color = BG
        title = Text("為什麼這會成立?", font_size=48, color=PRIMARY, weight=BOLD, font=MONO)
        self.add_subcaption("為什麼這會成立?", duration=2)
        self.play(Write(title), run_time=1.5)
        self.wait(1.0)
        self.play(FadeOut(title), run_time=0.5)

關鍵模式:

  • 每個動畫都加上字幕:self.add_subcaption("文字", duration=N) 或在 self.play() 中使用 subcaption="文字"
  • 在檔案頂部定義共用顏色常數,以確保跨場景的一致性
  • 在每個場景中設定 self.camera.background_color
  • 整潔的結尾 — 在場景結束時 FadeOut 所有 mobject:self.play(FadeOut(Group(*self.mobjects)))

第三步:渲染

manim -ql script.py Scene1_Introduction Scene2_CoreConcept  # 草稿
manim -qh script.py Scene1_Introduction Scene2_CoreConcept  # 正式輸出

第四步:拼接

cat > concat.txt << 'EOF'
file 'media/videos/script/480p15/Scene1_Introduction.mp4'
file 'media/videos/script/480p15/Scene2_CoreConcept.mp4'
EOF
ffmpeg -y -f concat -safe 0 -i concat.txt -c copy final.mp4

第五步:審查

manim -ql --format=png -s script.py Scene2_CoreConcept  # 預覽靜止畫面

關鍵實作注意事項

LaTeX 使用原始字串

# 錯誤:MathTex("\frac{1}{2}")
# 正確:
MathTex(r"\frac{1}{2}")

邊緣文字使用 buff >= 0.5

label.to_edge(DOWN, buff=0.5)  # 絕不低於 0.5

在取代文字前先 FadeOut

self.play(ReplacementTransform(note1, note2))  # 不要在原有文字上使用 Write(note2)

絕不對未加入的 Mobject 進行動畫

self.play(Create(circle))  # 必須先加入
self.play(circle.animate.set_color(RED))  # 然後才能進行動畫

效能目標

品質解析度FPS速度
-ql (草稿)854x480155-15 秒/場景
-qm (中等)1280x7203015-60 秒/場景
-qh (正式輸出)1920x10806030-120 秒/場景

永遠在 -ql 下進行迭代。僅在最終輸出時才使用 -qh 渲染。

參考資料

檔案內容
references/animations.md核心動畫、速率函數、組合、.animate 語法、時間模式
references/mobjects.md文字、形狀、VGroup/Group、定位、樣式、自訂 mobject
references/visual-design.md12 項設計原則、不透明度分層、佈局範本、色彩調色盤
references/equations.mdManim 中的 LaTeX、TransformMatchingTex、推導模式
references/graphs-and-data.md座標軸、繪圖、BarChart、動畫數據、演算法視覺化
references/camera-and-3d.mdMovingCameraScene、ThreeDScene、3D 曲面、相機控制
references/scene-planning.md敘事弧線、佈局範本、場景轉換、規劃範本
references/rendering.mdCLI 參考、品質預設、ffmpeg、配音工作流程、GIF 匯出
references/troubleshooting.mdLaTeX 錯誤、動畫錯誤、常見錯誤、除錯
references/animation-design-thinking.md何時使用動畫 vs 靜態顯示、分解、節奏、旁白同步
references/updaters-and-trackers.mdValueTracker、add_updater、always_redraw、基於時間的更新器、模式
references/paper-explainer.md將研究論文轉化為動畫 — 工作流程、範本、領域模式
references/decorations.mdSurroundingRectangle、Brace、箭頭、DashedLine、Angle、註解生命週期
references/production-quality.md編碼前、渲染前、渲染後的檢查清單、空間佈局、顏色、節奏

創意發散(僅在使用者要求實驗性/創意性/獨特輸出時使用)

如果使用者要求創意、實驗性或非傳統的解說方法,請在設計動畫之前選擇一個策略並進行推導。

  • SCAMPER — 當使用者想要對標準解說進行全新詮釋時
  • 假設反轉 — 當使用者想要挑戰某個主題的典型教學方式時

SCAMPER 轉換

對標準的數學/技術視覺化進行轉換:

  • 替代 (Substitute):取代標準的視覺隱喻(數線 → 蜿蜒路徑,矩陣 → 城市網格)
  • 組合 (Combine):合併兩種解說方法(同時使用代數 + 幾何)
  • 逆向 (Reverse):反向推導 — 從結果開始,解構回公理
  • 修改 (Modify):誇大某個參數以顯示其重要性(10 倍的學習率,1000 倍的樣本數)
  • 刪除 (Eliminate):移除所有符號標記 — 完全透過動畫和空間關係來解釋

假設反轉

  1. 列出這個主題的「標準」視覺化方式(從左到右、2D、離散步驟、正式符號)
  2. 選擇最根本的假設
  3. 將其反轉(從右到左的推導、將 2D 概念嵌入 3D、連續變形取代步驟、零符號)
  4. 探索這個反轉揭示了哪些標準方法所隱藏的東西

Individual skills in this repo

This repo contains 6 individual skills — each has its own dedicated page.

govindgoel2001/video-editing-toolkit

GSAP animation reference for HyperFrames. Covers gsap.to(), from(), fromTo(), easing, stagger, defaults, timelines (gsap.timeline(), position parameter, labels, nesting, playback), and performance (transforms, will-change, quickTo). Use when writing GSAP animations in HyperFrames compositions.

govindgoel2001/video-editing-toolkit

HyperFrames CLI tool — hyperframes init, lint, inspect, preview, render, transcribe, tts, doctor, browser, info, upgrade, compositions, docs, benchmark. Use when scaffolding a project, linting, validating, inspecting visual layout in compositions, previewing in the studio, rendering to video, transcribing audio, generating TTS, or troubleshooting the HyperFrames environment.

govindgoel2001/video-editing-toolkit

Install and wire registry blocks and components into HyperFrames compositions. Use when running hyperframes add, installing a block or component, wiring an installed item into index.html, or working with hyperframes.json. Covers the add command, install locations, block sub-composition wiring, component snippet merging, and registry discovery.

govindgoel2001/video-editing-toolkit

Create video compositions, animations, title cards, overlays, captions, voiceovers, audio-reactive visuals, and scene transitions in HyperFrames HTML. Use when asked to build any HTML-based video content, add captions or subtitles synced to audio, generate text-to-speech narration, create audio-reactive animation (beat sync, glow, pulse driven by music), add animated text highlighting (marker sweeps, hand-drawn circles, burst lines, scribble, sketchout), or add transitions between scenes (crossfades, wipes, reveals, shader transitions). Covers composition authoring, timing, media, and the full video production workflow. For CLI commands (init, lint, preview, render, transcribe, tts) see the hyperframes-cli skill.

govindgoel2001/video-editing-toolkit

Capture a website and create a HyperFrames video from it. Use when: (1) a user provides a URL and wants a video, (2) someone says "capture this site", "turn this into a video", "make a promo from my site", (3) the user wants a social ad, product tour, or any video based on an existing website, (4) the user shares a link and asks for any kind of video content. Even if the user just pastes a URL — this is the skill to use.

govindgoel2001/video-editing-toolkit

Edit any video by conversation. Transcribe, cut, color grade, generate overlay animations, burn subtitles — for talking heads, montages, tutorials, travel, interviews. No presets, no menus. Ask questions, confirm the plan, execute, iterate, persist. Production-correctness rules are hard; everything else is artistic freedom.

相關技能