Communitygithub.com

Remotion 程式碼解說影片生成器

將原始碼檔案轉換為沉浸式、影格同步的單畫面 Remotion 解說影片 (1920×1080 30fps MP4),採用 Log2Base2 單階段格式,聚焦單行亮點、全螢幕動畫記憶體區塊、指標箭頭、資料封包與即時執行狀態。

Remotion 程式碼解說影片生成器 是什麼?

Remotion Code Explainer 是一個 AI 代理技能,專為將原始碼檔案自動生成專業、高畫質的解說影片而設計。它採用獨特的「單畫面 Log2Base2 工作室格式」,將所有視覺元素(焦點程式碼行、動畫記憶體與變數、執行狀態、指標、資料流)整合在一個統一的 SVG 畫布上,避免分割畫面或資訊混雜,確保觀眾注意力完全集中於程式碼的執行邏輯。此技能支援 Claude Code、Cursor、Codex 等平台,其工作流程包含三個主要步驟:首先,透過 CLI 工具 scaffold 建立 Remotion 專案結構;其次,使用 edge-tts 合成神經網路語音旁白,並精確提取逐字時間戳記以驅動逐字卡拉 OK 字幕;最後,利用高效能的並行渲染引擎輸出最終的 1080p MP4 檔案。其核心優勢在於將抽象的程式邏輯轉化為具體的視覺敘事,例如用動畫指標箭頭展示資料傳遞、用記憶體區塊的數值變化顯示變數賦值過程,讓學習者能直觀理解程式碼的執行流程,非常適合製作教學、技術解說或程式碼審查影片。

相容平台✓Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/uzowurumauritius-rgb/remotion-stage/tree/main/skills/remotion-code-explainer

在你喜歡的 AI 中提問

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

說明文件

Remotion 程式碼解說影片生成器 (remotion-code-explainer)

概述

將任何原始碼檔案轉換為沉浸式、影格同步的 1920×1080 30fps MP4 Remotion 解說影片,採用 單畫面 Log2Base2 工作室格式。

絕不將畫面分割為相互競爭的並排窗格或擁擠的多卡片牆。每部影片皆使用 一個統一的視覺舞台 (<SinglePaneStage>),讓觀眾的注意力完全鎖定在程式碼如何執行:

  1. 精簡頂部欄 (44px,內建於 SinglePaneStage):
    • 左側顯示課程標題與當前活躍章節標籤;右側顯示細微的步驟計數器與細條進度條。
  2. 一個統一的 Log2Base2 舞台 (SinglePaneStage — 100% 寬度):
    • 聚焦的單行重點標題:僅顯示當前步驟標題和單一活躍程式碼行 (使用清晰等寬字型,透過 borderBottom: "2px solid #FACC15" 原地標記活躍的口語 token,絕不添加水平內距),外加一個在 triggerFrame 時彈入的緊湊活躍呼叫標籤 (token → 白話解釋)。
    • 全寬沉浸式 SVG 畫布 (viewBox="0 0 1600 680"):寬敞、連續的動態圖形,在同一開放畫布上直接結合 Log2Base2 的記憶體/執行視覺元素 (標籤記憶體區塊 0x1004、可變變數、動畫 strokeDashoffset 指標箭頭、推入/彈出的堆疊框架、陣列/樹狀結構交換) 與即時 UI/stdout/張量預覽。
  3. 精簡底部字幕欄 (VoiceoverCaptionBar — 68px):
    • 清晰置中的逐字卡拉 OK 高亮字幕,由精確的 TTS WordBoundary 毫秒時間戳記 (startMs、endMs) 驅動。

相依性

  • remotion-best-practices (~/.gemini/skills/remotion/SKILL.md):必須遵循所有 Remotion 動畫規則 (useCurrentFrame()、interpolate()、spring()、<Sequence premountFor>、<Audio>、@remotion/google-fonts 和零 CSS 過渡)。
  • uv (~/.gemini/config/plugins/science/skills/uv/SKILL.md):需用於執行 uv run --with edge-tts 以進行神經網路語音合成和 WordBoundary 時間戳記提取。

快速開始

# 1. 建立 Remotion 解說專案
uv run python3 \
  ~/.gemini/config/skills/remotion-code-explainer/scripts/code_explainer_cli.py \
  scaffold \
  --project-dir "/path/to/project" \
  --source-file "/path/to/source.ext" \
  --output "/path/to/project/scaffold-status.json"

# 2. 合成自然神經網路語音旁白 + 精確的逐字 & token 時間戳記
uv run --with edge-tts python3 \
  ~/.gemini/config/skills/remotion-code-explainer/scripts/code_explainer_cli.py \
  synthesize-voiceover \
  --project-dir "/path/to/project" \
  --beats-json "/path/to/project/beats.json" \
  --voice "en-US-AndrewNeural" \
  --rate "+2%" \
  --pause-sec 0.40 \
  --output "/path/to/project/public/voiceover/manifest.json"

# 3. 透過快速的 8 工作執行緒關鍵影格去重複渲染器輸出最終 1080p 30fps MP4
uv run python3 \
  ~/.gemini/config/skills/remotion-code-explainer/scripts/code_explainer_cli.py \
  render-mp4 \
  --project-dir "/path/to/project" \
  --composition-id "CodeExplainer" \
  --out-name "Explainer.mp4" \
  --concurrency 8 \
  --output "/path/to/project/render-report.json"

沉浸式敘事與工作流程

  1. 設計充滿活力的章節 (beats.json):
    • 撰寫清晰、對話式的旁白,立即吸引觀眾了解程式碼行為背後的原因。
    • 保持 codeSnippet 聚焦 (1–4 行),以便傳遞給 <SinglePaneStage> 的活躍行能逐字包含活躍的 token。
    • 對於包含移動封包、指標跳躍、陣列交換或即時張量/UI 動畫的章節,設定 "motionStepFrames": 2。
  2. 建立專案與合成語音:
    • 透過 scripts/code_explainer_cli.py 執行 scaffold (複製 SinglePaneStage.tsx、VoiceoverCaptionBar.tsx 和 render_full_mp4.mjs) 和 synthesize-voiceover。
  3. 編寫全畫布動態圖形 (viewBox="0 0 1600 680"):
    • 將您動畫化的 Log2Base2 × KodeKloud SVG 故事板作為 children 傳遞給 <SinglePaneStage>。
    • 展示,而非講述:以實際的動畫取代靜態的程式碼牆和文字框——數值從暫存器/變數飛入記憶體插槽、指標平滑重新路由、資料封包在元件間傳輸,以及即時狀態/UI 輸出在同一開放畫布上更新。
    • 將動態網格或滾動軌跡包裹在 <clipPath> 中,使動畫不會溢出其區域。
  4. 驗證靜止畫面與渲染最終 MP4:
    • 執行 npm run lint 並使用 read_file 檢查代表性的靜止影格 (npx remotion still),確認無重疊或裁剪。
    • 執行 render-mp4 (scripts/render_full_mp4.mjs),確保最終的 .mp4 檔案儲存到 out/、專案根目錄以及工作空間根目錄。

速率限制與常見錯誤

  • scripts/code_explainer_cli.py 強制執行 /tmp/remotion_edge_tts.lock (0.35 秒間隔,3 次重試,退避時間為 1 秒/2 秒/4 秒)。
  • 絕不使用 2 區域分割畫面儀表板或傾倒 40 行的滾動程式碼牆;保持畫面為一個 <SinglePaneStage> 窗格。
  • 絕不為高亮的行內 token 添加水平 padding (僅使用 borderBottom: "2px solid #FACC15" 和 backgroundColor)。
  • 絕不在 SVG 舞台內部使用靜態文字卡片,當可以透過動畫的記憶體/指標/封包動態來演示概念時。

Individual skills in this repo

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

remotion-electronic-explainer

Creates synchronized, immersive single-pane Remotion visual explainer videos for Electronic Engineering (Semiconductors, PN Junctions, Diodes, BJTs, MOSFETs, CMOS Logic, Op-Amp IC Stages, ADC/DAC, PCB Signal Integrity) in a pure Log2Base2 single-stage format—with a focused single-line device equation spotlight, full-screen animated carrier/channel diagrams and live I-V curves on one canvas, WordBoundary karaoke captions, and fast 1080p MP4 rendering. Use whenever the user asks to explain electronic engineering, semiconductors, transistors, or analog/digital ICs with /remotion.

remotion-math-explainer

Creates synchronized, immersive single-pane Remotion visual explainer videos for Mathematics (Calculus, Linear Algebra, Differential Equations, Probability, Proofs) in a pure Log2Base2 single-stage format—with a focused single-line equation spotlight, full-screen 3Blue1Brown x Log2Base2 animated geometric/data motion graphics, WordBoundary karaoke captions, and fast 1080p MP4 rendering. Use whenever the user asks to explain math with /remotion, animate a derivation or theorem, or turn a math script into an MP4 explainer.

remotion-physics-explainer

Creates synchronized, immersive single-pane Remotion visual explainer videos for Physics (Mechanics, Electromagnetism, Thermodynamics, Optics/Waves, Quantum Mechanics, Relativity) in a pure Log2Base2 single-stage format—with a focused single-line governing law spotlight, full-screen animated free-body/field/wave simulations and live telemetry on one canvas, millisecond-accurate WordBoundary karaoke captions, and fast 1080p MP4 rendering. Use whenever the user asks to explain physics with /remotion or animate a physical law/system.

remotion-software-explainer

Creates synchronized, immersive single-pane Remotion visual explainer videos for Software Engineering (System Design, Distributed Systems, Microservices, Kubernetes/Docker, Design Patterns, Database Internals, CI/CD, Networking) in a pure Log2Base2 single-stage format—with a focused single-line contract/YAML spotlight, full-screen animated architecture flows with traveling request packets and live trace timelines on one canvas, WordBoundary karaoke captions, and fast 1080p MP4 rendering. Use whenever the user asks to explain software engineering, system design, or architecture with /remotion.

相關技能