Communitygithub.com

costa-marcello/skillkit

引導在 React 中開發 Remotion 影片,包括構圖、動畫、時間控制、音訊、字幕和渲染。當使用者處理 Remotion、編寫 <Composition>/<Sequence>/interpolate/spring、編輯 remotion.config.ts、渲染或部署 Lambda 影片,或詢問關於在 React 中建立影片時使用。

skillkit 是什麼?

這個技能為使用 Remotion 程式庫在 React 中建立程式的影片開發者提供一個全面的指南。它涵蓋了從專案初始設定到最終渲染的整個工作流程,並解決了常見的 AI 錯誤,例如非確定性隨機性(使用 `random(seed)` 而非 `Math.random()`)以及未正確使用 `delayRender()` 和 `continueRender()` 處理非同步工作。技能詳細介紹了核心概念,如構圖、序列、時間控制(包括 `interpolate` 和 `spring`)以及使用 Zod 進行參數驗證。它也廣泛涵蓋了媒體處理,包括音訊、字幕、圖像、影片和 3D 內容。進階主題包含地圖、圖表、轉場效果以及 TailwindCSS 整合。對於生產環境,技能提供了透過 AWS Lambda 渲染、使用 `@remotion/player` 嵌入播放器以及確保確定性渲染和記憶體化輸入屬性的最佳實務指南。此技能與 Claude Code、Cursor 和 Cursor Tab 相容。

相容平台~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/costa-marcello/skillkit/tree/HEAD/skills/remotion-video

在你喜歡的 AI 中提問

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

說明文件

使用時機

每當您讀取或編寫 Remotion 程式碼時,從建立專案到渲染最終影片,請載入此技能。

常見的 AI 錯誤避免清單

在提交前,請針對以下重複出現的失敗模式檢查每個 Remotion 程式碼變更:

  • 非確定性隨機性 — 使用來自 remotion 的 random(seed),絕不使用 Math.random()、Date.now() 或 new Date()。否則,並行渲染會產生閃爍雜訊。
  • 未記憶化的 <Player> inputProps — 始終傳遞記憶化的 props;未記憶化的 props 會導致整個元件樹的重新渲染風暴。
  • 遺漏 delayRender() / continueRender() — 在非同步工作(fetch、字型載入、測量)周圍使用。缺少它們會導致渲染在 30,000 毫秒時掛起。
  • 字幕上非單調的 inputRange — interpolate 的 inputRange 必須嚴格遞增。對於短片段,請使用 Math.min(10, Math.floor(duration / 3)) 作為淡入/淡出視窗。
  • 處處使用線性緩動 — 優先使用 spring() 實現自然運動;僅在明確的技術需求時才使用線性緩動。
  • 遺漏 @remotion/google-fonts 導入 — 每個字型都需要明確的 loadFont({ weights, subsets }) 呼叫。
  • 單一的單一構圖輸出 — 將場景分解為小型的聚焦構圖,並使用 <Sequence> 或 <TransitionSeries> 組合。
  • 已棄用的 startFrom / endAt — 改用 trimBefore / trimAfter。

新專案設定

當在一個空的資料夾或沒有現有 Remotion 專案的工作區中時,請使用以下指令建立一個:

npx create-video@latest --yes --blank --no-tailwind my-video

將 my-video 替換為合適的專案名稱。

啟動預覽

啟動 Remotion Studio 以預覽影片:

npx remotion studio

可選:單幀渲染檢查

您可以使用 CLI 渲染單個幀,以進行佈局、顏色或時間的健全性檢查。 對於瑣碎的編輯、純重構,或者當您已從 Studio 或先前的渲染中獲得足夠信心時,可以跳過此步驟。

npx remotion still [composition-id] --scale=0.25 --frame=30

在 30 fps 下,--frame=30 表示一秒鐘的標記(--frame 是從零開始的)。

規則索引

閱讀各個規則檔案以獲取詳細說明和程式碼範例。

核心

媒體

音訊

文字

進階

工具

生產環境

整合

套件

  • packages/paths.md - @remotion/paths SVG 路徑工具(interpolatePath、warpPath、getLength)
  • packages/shapes.md - @remotion/shapes 預建 SVG 基本形狀(三角形、圓形、星形、圓餅圖、心形)
  • packages/noise.md - @remotion/noise 基於種子的 Perlin 雜訊(noise2D、noise3D、noise4D)
  • packages/motion-blur.md - @remotion/motion-blur Trail 和 CameraMotionBlur(謹慎使用)
  • packages/skia.md - @remotion/skia 高效能畫布(React Native Skia)
  • packages/rive.md - @remotion/rive 帶狀態機的動畫(Lottie 替代方案)

相關技能