Communitygithub.com

joyehuang/skills

將結構化的影片腳本轉換為可執行的 Remotion 專案,包含 React 元件、音訊和渲染功能。

skills 是什麼?

此技能專為將結構化影片腳本(如 `article-to-script` 技能產生的 `script.json`)轉換為生產級別的 Remotion 專案而設計。它涵蓋從 React 元件生成、TTS(文字轉語音)音訊整合、智慧字幕分段到最終 MP4 影片渲染的完整工作流程。核心優勢在於強制遵循 Remotion 最佳實踐,例如使用 `spring()` 物理動畫而非 CSS 動畫、利用 `fitText` 和 `measureText` 進行響應式文字排版,並支援六種預定義場景類型(鉤子、文字展示、數字比較、三列對比、案例研究、行動呼籲)。此技能以文件驅動,詳細說明每個階段的規則,適合需要自動化或簡化程式化影片創作流程的開發者,支援 Node.js 18+ 與 pnpm,並可選整合 Google Gemini API 進行 TTS 音訊生成。

相容平台✓Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/joyehuang/skills/tree/HEAD/script-to-remotion

在你喜歡的 AI 中提問

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

說明文件

script-to-remotion

將結構化的影片腳本轉換為可執行的 Remotion 專案,包括 React 元件生成、TTS 音訊整合、字幕生成和影片渲染。

使用場景

使用此技能當您需要:

  • 將 script.json 轉換為 Remotion 影片專案
  • 生成符合 remotion-best-practices 的 React 元件
  • 可選生成 TTS 音訊(使用 Google Gemini API)
  • 自動生成智慧分段的字幕
  • 渲染最終影片(MP4 格式)

不要使用當:

  • 直接從文章生成腳本(使用 article-to-script 技能)
  • 編輯現有影片或剪輯
  • 建立互動式影片內容

前置要求

必需

  • script.json - 來自 article-to-script 技能的輸出
  • Node.js - 版本 18+ 和 pnpm 套件管理員
  • remotion-best-practices 技能 - 必須參考以確保元件品質

可選

  • Google Gemini API Key - 用於 TTS 音訊生成
  • 背景音樂 - BGM 檔案(如需要)

工作流程

此技能遵循 4階段工作流:

階段 1: 元件生成 (30-45分鐘)

為每個場景生成 React 元件

流程:

  1. 讀取 script.json
  2. 參考 remotion-best-practices 技能
  3. 為每個場景類型生成對應元件
  4. 確保使用 spring 動畫(不用 CSS 動畫)
  5. 使用 fitText/measureText 處理文字尺寸

規則檔案: rules/component-generation.md 場景類型指南: rules/scene-types/*.md(6個檔案)

階段 2: 專案組裝 (15-20分鐘)

建立完整的 Remotion 專案結構

流程:

  1. 建立專案目錄結構
  2. 複製 package.json、tsconfig.json、remotion.config.ts
  3. 建立 Root.tsx 主元件
  4. 複製共用元件(NeonBackground、Subtitle等)
  5. 複製主題檔案(theme.ts)
  6. 安裝依賴

規則檔案: rules/project-assembly.md

階段 3: TTS 音訊生成(可選,10-15分鐘)

使用 Google Gemini API 生成 TTS 音訊

流程:

  1. 建立獨立的 tts-generator.js 腳本
  2. 為每個場景生成音訊檔案
  3. 套用 1.25x 播放速度
  4. 生成字幕分段資料
  5. 儲存到 public/audio/ 目錄

規則檔案: rules/tts-integration.md, rules/subtitle-generation.md

階段 4: 預覽和渲染 (5-10分鐘)

啟動預覽和渲染影片

流程:

  1. 啟動 Remotion 預覽伺服器(pnpm start)
  2. 在瀏覽器中檢查效果
  3. 渲染最終影片(pnpm build)
  4. 輸出 video.mp4

規則檔案: rules/render-configuration.md

快速開始

# 1. 準備 script.json
# 假設已透過 article-to-script 生成

# 2. 參考 remotion-best-practices
Read .claude/skills/remotion-best-practices/skill.md

# 3. 參考 script-to-remotion 規則
Read .claude/skills/script-to-remotion/rules/component-generation.md
Read .claude/skills/script-to-remotion/rules/scene-types/*.md

# 4. 生成元件(為每個場景)
# 根據場景類型選擇對應的模板和規則生成程式碼

# 5. 組裝專案
Read .claude/skills/script-to-remotion/rules/project-assembly.md
# 按照說明建立完整專案結構

# 6. 可選:生成 TTS
Read .claude/skills/script-to-remotion/rules/tts-integration.md
# 建立並執行 tts-generator.js

# 7. 安裝依賴
cd video-output-<timestamp>
pnpm install

# 8. 預覽
pnpm start
# 瀏覽器訪問 http://localhost:3000

# 9. 渲染
pnpm build
# 輸出到 out/video.mp4

核心特性

6種場景類型支援

每種場景類型都有專門的模板和動畫:

場景類型時長用途關鍵特性
hook5-8s開場鉤子打字機效果,彈跳動畫
textDisplay15-20s核心資訊展示fitText 自適應,滑入動畫
numberComparison12-18s資料對比數字動畫,前後對比佈局
threeColumns15-20s三列對比錯位顯示,Series 序列
caseStudy20-30s案例故事TransitionSeries,前後轉場
cta8-12s行動呼籲多步驟顯示,強調動畫

Spring 物理動畫

所有動畫使用 Remotion 的 spring() 物理引擎:

const scale = spring({
  frame,
  fps,
  config: { damping: 12, stiffness: 100 }
});

禁止使用 CSS 動畫(違反 remotion-best-practices)

響應式文字

使用 @remotion/layout-utils 確保文字適配:

import { fitText, measureText } from '@remotion/layout-utils';

const fittedText = fitText({
  text: narration,
  withinWidth: 1600,
  fontFamily: 'Inter',
  fontSize: 80
});

智慧字幕分段

自動將長旁白分段為易讀的字幕:

  • 按標點符號自然斷句
  • 每段 3-8 秒時長
  • 淡入淡出效果(0.2秒)
  • 完美同步音訊

規則檔案

所有工作流規則文件化在 rules/ 目錄:

核心規則:

  • component-generation.md - React 元件生成指南
  • project-assembly.md - 專案結構和配置
  • render-configuration.md - Remotion 渲染設定
  • troubleshooting.md - 常見問題解決

場景類型指南(6個):

  • scene-types/hook-scene.md - 開場鉤子場景
  • scene-types/text-display-scene.md - 文字展示場景
  • scene-types/number-comparison-scene.md - 數字對比場景
  • scene-types/three-columns-scene.md - 三列場景
  • scene-types/case-study-scene.md - 案例故事場景
  • scene-types/cta-scene.md - CTA 場景

音訊和字幕:

  • tts-integration.md - TTS 音訊生成(可選)
  • subtitle-generation.md - 字幕分段演算法

模板檔案

即用型程式碼模板在 templates/ 目錄:

配置檔案:

  • package.json.template - 專案依賴
  • tsconfig.json.template - TypeScript 配置
  • remotion.config.ts.template - Remotion 設定
  • theme.ts - 霓虹玻璃態主題

共用元件:

  • components/NeonBackground.tsx - 動態漸變背景
  • components/SceneAudio.tsx - 音訊播放器
  • components/Subtitle.tsx - 字幕元件

其他:

  • Root.tsx.template - 主元件模板
  • tts-generator.js.template - TTS 生成腳本

範例

  • examples/script-input.json - 範例輸入腳本
  • examples/Hook-scene-example.tsx - 完整的 Hook 場景元件
  • examples/complete-project/ - 完整專案參考

Bash 命令

所有 CLI 操作文件化在 commands/bash-commands.md:

  • 專案設定命令
  • 依賴安裝
  • TTS 生成(可選)
  • 預覽和渲染
  • 錯誤處理

品質保證

必須遵循 remotion-best-practices

關鍵規則:

  • ✅ 使用 spring() 做所有動畫
  • ✅ 使用 fitText/measureText 處理文字
  • ✅ 元件必須是純函式(無副作用)
  • ✅ 正確使用 useCurrentFrame() 和 useVideoConfig()
  • ❌ 不使用 CSS animations 或 transitions
  • ❌ 不使用 useState/useEffect
  • ❌ 不使用外部 API 呼叫

元件品質標準

每個生成的元件必須:

  • TypeScript 無錯誤編譯
  • 匯出正確類型(場景元件)
  • Props 包含 startFrame, durationFrames, scene
  • 動畫流暢(60fps)
  • 文字清晰可讀
  • 顏色對比度充足

故障排查

常見問題和解決方案在 rules/troubleshooting.md:

  • TypeScript 編譯錯誤
  • 動畫卡頓
  • 文字溢出
  • 音訊同步問題
  • 渲染失敗

版本歷史

  • v3.0.0 (2025-01): 純文件技能,模板驅動
  • v2.1.0 (2024-12): CLI 驅動的 Phase 4-8 實作
  • v1.0.0 (2024-11): 初始單體技能

支援

遇到問題時:

  • 查看 rules/troubleshooting.md 常見問題
  • 參考 examples/ 範例實作
  • 諮詢 remotion-best-practices 技能
  • 檢查 Remotion 官方文件

相關技能

  • article-to-script - 上游:生成 script.json
  • remotion-best-practices - 必須參考:確保元件品質

相關技能