Communitygithub.com

Hownameee/short-videos

內容、動畫與效果的最佳實務

short-videos 是什麼?

這個技能提供一個完整的指南,用於在 Remotion 中編寫 React 標記,特別針對短影片的動畫、視覺效果和互動元件,以實現最佳效能和 Studio 相容性。它強制使用 `useCurrentFrame()` 和 `interpolate()` 進行動畫驅動,避免使用 CSS 或 Tailwind 的 `transition`/`animation`,並偏好 `scale`、`translate` 和 `rotate` 等簡化屬性,而非 `transform` 字串。該技能深度涵蓋 Remotion 可編輯架構,透過 `Interactive.withSchema({wrapInSequence: true})` 推廣互動、可預掛的元件,以及用於獨立時間軸場景的已連接組合物件。它還處理資產管理、媒體元件(影片、音訊、CanvasImage、AnimatedImage)、延遲修剪屬性,並連結到進階主題,例如多場景影片、轉場、3D 內容、語音旁白、地圖、字幕、Lottie 動畫、字型載入、音訊視覺化、運動模糊和基於著色器的效果。此技能可用於 Cursor、Claude Code 和 Codex 等 AI 代理工具,確保生成的 Remotion 程式碼能與 Studio 的視覺編輯器和可編輯 Props 系統正確協作。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Hownameee/short-videos/tree/HEAD/.agent/skills/remotion-markup

在你喜歡的 AI 中提問

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

預覽

來自技能 README

說明文件

這是指導如何撰寫 Remotion React 標記的說明。 如果這不相關,請改為載入 Remotion 最佳實務。

保留使用者的變更

使用者可能會在對話之外的程式碼中進行編輯。

如果你在此期間發現意外的變更,請勿覆蓋它,假設該變更是有意為之,或先請求確認。

一般規則

使用 useCurrentFrame() 和 interpolate() 來驅動動畫。 CSS transition 或 animation 無法正確渲染,需要進行重構。 Tailwind 動畫類別無法正確渲染,需要進行重構。

使用 Easing.bezier() 和 Easing.spring() 來自訂時間曲線。

根據 Remotion 互動性最佳實務來建構你的標記。 優先使用 Interactive.withSchema({wrapInSequence: true}) 來建立具有可編輯 Props 的自訂視覺元件,並將可重複使用的場景註冊為已連接組合物件。 將時間參數直接放在支援它的元件上;避免冗餘的 <Sequence> 包裹層。 為每個支援 premountFor 的計時元件給予一秒的預掛載時間: premountFor={fps},其中 fps 來自 useVideoConfig()。將此應用於媒體、互動元件、<Sequence>、<Series.Sequence>、<TransitionSeries.Sequence> 和 <TransitionSeries.Overlay>,包括巢狀在場景內部的計時元件。當巢狀項目需要在父項目開始之前掛載時,也要預掛載父時間軸項目。不支援 premountFor 的元件(例如 <TransitionSeries.Transition>)無需替代方案。

Studio 會編輯建立項目的 JSX 原始節點。每個組合物件註冊、剪輯、場景、圖層和序列都應該作為獨立的 JSX 節點編寫,其可編輯的 props 內嵌其中。 程式化迴圈適用於生成的實例被有目的地作為一個來源模板控制的情況,而非使用者需要單獨編輯各個實例的情況。

import { useCurrentFrame, useVideoConfig, Easing, interpolate, Interactive } from "remotion";

export const FadeIn = () => {
  const frame = useCurrentFrame();
  const {fps} = useVideoConfig();

  return (
    <Interactive.Div
      name="Title"
      premountFor={fps}
      style={{
        opacity: interpolate(frame, [0, 2 * fps], [0, 1], {
          extrapolateRight: "clamp",
          extrapolateLeft: "clamp",
          easing: Easing.bezier(0.16, 1, 0.3, 1),
        }),
      }}
    >
      Hello World!
    </Interactive.Div>
  );
};

保持 interpolate() 的內嵌寫法在 style props 中。 使用 scale、translate、rotate CSS 屬性,而非 transform。

// 👍 可內嵌編輯的關鍵影格與變形簡寫
style={{
  scale: interpolate(frame, [0, 100], [0, 1], {
    extrapolateLeft: 'clamp',
    extrapolateRight: 'clamp',
    easing: Easing.spring({damping: 200}),
    output: 'perceptual-scale' // 對於 `scale` 動畫,使用 "output: 'perceptual-scale'"
  }),
  translate: interpolate(frame, [0, 100], ["0px 0px", "100px 100px"], {
    extrapolateLeft: 'clamp',
    extrapolateRight: 'clamp',
    easing: Easing.spring({damping: 200}),
  }),
  rotate: interpolate(frame, [0, 100], ["20deg", "90deg"], {
    extrapolateLeft: 'clamp',
    extrapolateRight: 'clamp',
    easing: Easing.spring({damping: 200}),
  }),
}}

// 👎 非內嵌的值和 transform 字串在 Studio 中會變得更難編輯
const scale = interpolate(frame, [0, 100], [0, 1]);

style={{
  transform: `scale(${scale})`,
}}

素材

將素材放置在專案根目錄的 public/ 資料夾中。 使用 staticFile() 來引用 public/ 資料夾中的檔案。

媒體元件

使用來自 @remotion/media 的 <Video> 和 <Audio> 來添加影片和音訊。 使用 <CanvasImage> 元件來添加圖片。 使用 <AnimatedImage> 來添加動畫 GIF、APNG、WebP 或 AVIF 圖片;如果未使用 Chrome,則使用 @remotion/gif。 對 public/ 中的檔案使用 staticFile(),或直接傳遞遠端 URL:

import { Audio, Video } from "@remotion/media";
import { staticFile, CanvasImage, AnimatedImage, useVideoConfig } from "remotion";

export const MyComposition = () => {
  const {fps} = useVideoConfig();

  return (
    <>
      <Video src={staticFile("video.mp4")} premountFor={fps} style={{ opacity: 0.5 }} />
      <Audio src={staticFile("audio.mp3")} premountFor={fps} />
      <CanvasImage
        src={staticFile("logo.png")}
        premountFor={fps}
        style={{ width: 100, height: 100 }}
      />
      <Video src="https://remotion.media/video.mp4" premountFor={fps} />
      <AnimatedImage src={staticFile('nyancat.gif')} premountFor={fps} />
    </>
  );
};

如果組合物件主要是影片或音訊剪輯的時間軸,請在選擇其來源結構之前先閱讀 video-editing.md。

範例場景

一個帶有下方三分之一標題的背景影片。 下方三分之一是一個具有自己時間軸的互動元件,註冊為一個已連接組合物件。 其文字以 children 傳入,accentColor 是可編輯的 prop。 淡入效果在呼叫處內嵌關鍵影格。

// MyScene.tsx
import { Video } from "@remotion/media";
import { Easing, interpolate, useCurrentFrame, useVideoConfig } from "remotion";
import { LowerThird } from "./LowerThird";

export const MyScene = () => {
  const { fps } = useVideoConfig();
  const frame = useCurrentFrame();

  return (
    <>
      <Video
        name="Background"
        src="https://remotion.media/video.mp4"
        premountFor={fps}
        objectFit="cover"
        style={{
          position: "absolute",
          width: "100%",
          height: "100%",
        }}
      />
      <LowerThird
        name="Lower third"
        from={1 * fps}
        premountFor={fps}
        accentColor="#0b84f3"
        style={{
          opacity: interpolate(frame, [1 * fps, 2 * fps], [0, 1], {
            extrapolateRight: "clamp",
            extrapolateLeft: "clamp",
            easing: Easing.bezier(0.16, 1, 0.3, 1),
          }),
        }}
      >
        Jane Doe, Product Designer
      </LowerThird>
    </>
  );
};
// LowerThird.tsx
import type React from "react";
import { Interactive, type InteractivitySchema } from "remotion";

type LowerThirdProps = {
  readonly children: string;
  readonly accentColor: string;
  readonly style?: React.CSSProperties;
};

const LowerThirdInner: React.FC<LowerThirdProps> = ({
  children,
  accentColor,
  style,
}) => {
  return (
    <Interactive.Div
      style={{
        position: "absolute",
        left: 80,
        bottom: 80,
        display: "flex",
        alignItems: "center",
        gap: 20,
        backgroundColor: "white",
        borderRadius: 16,
        padding: "20px 32px",
        color: "black",
        fontFamily: "Helvetica, Arial, sans-serif",
        fontSize: 48,
        fontWeight: 600,
        ...style,
      }}
    >
      <div
        style={{
          width: 8,
          alignSelf: "stretch",
          borderRadius: 4,
          backgroundColor: accentColor,
        }}
      />
      {children}
    </Interactive.Div>
  );
};

const lowerThirdSchema = {
  children: { type: "text-content", default: "", description: "Text" },
  accentColor: {
    type: "color",
    default: "#0b84f3",
    description: "Accent color",
  },
} as const satisfies InteractivitySchema;

export const LowerThird = Interactive.withSchema({
  Component: LowerThirdInner,
  componentName: "<LowerThird>",
  schema: lowerThirdSchema,
  wrapInSequence: true,
});
// Root.tsx
import { Composition } from "remotion";
import { LowerThird } from "./LowerThird";
import { MyScene } from "./MyScene";

export const RemotionRoot: React.FC = () => {
  return (
    <>
      <Composition
        id="MyScene"
        component={MyScene}
        durationInFrames={60}
        fps={30}
        width={1280}
        height={720}
      />
      <Composition
        id="LowerThird"
        component={LowerThird}
        durationInFrames={30}
        fps={30}
        width={1280}
        height={720}
        defaultProps={{
          children: "Jane Doe, Product Designer",
          accentColor: "#0b84f3",
        }}
      />
    </>
  );
};

延遲與修剪

將時間參數直接放在支援它的元件上。請參閱時間屬性以了解支援的屬性、範例和操作順序。

地圖

如需在影片中包含地圖,請參閱 Remotion Maps。

文字高亮與註釋

請參閱 text-highlights.md 了解文字高亮(高亮標記)、圓圈、底線、刪除線、劃掉文字、方框。

多場景影片

如果計畫製作包含多個後續場景的影片,請參閱 multi-scene-video.md。

已連接組合物件

當一個場景或一組圖層需要其自己的可編輯時間軸時,請遵循 connected-compositions.md。對於多場景影片中的主要場景,優先使用此結構。

預組裝動作

對於 Studio 的要求,例如 Pre-compose Ambient glow (src/BarChart.tsx:134),請在指定位置找到所選序列的標記。建立一個已連接組合物件,遵循 connected-compositions.md:將標記提取為一個具名元件,最好使用 Interactive.withSchema({wrapInSequence: true}) 使其成為互動式,並在根目錄使用唯一的 <Composition> 註冊相同的匯出元件引用。直接使用其時間屬性渲染互動元件,或者當包裹層有特定用途時,將其作為序列的唯一子元素渲染。如果所選節點已經是一個序列,請保留其屬性並提取其子元素。註冊需要維度、fps、持續時間和與其父級使用方式等效的 defaultProps。沒有已註冊組合物件的元件提取無法完成預組裝請求。

語音旁白

請參閱 voiceover.md 了解如何使用 ElevenLabs TTS 為 Remotion 組合物件添加 AI 生成的語音旁白。

嵌入影片

請參閱 embedding-videos.md 了解關於嵌入影片的進階知識 - 修剪、音量、速度、循環、音調。

嵌入音訊

請參閱 audio.md 了解進階音訊功能,例如修剪、音量、速度、音調。

裁切

如果需要裁切元件的可視矩形,請參閱 cropping.md。

轉場

請參閱 transitions.md 了解場景轉場模式。

動態模糊

當添加動態模糊或運動軌跡時,請閱讀 motion-blur.md 以了解偏好的 HTML-in-canvas 方法、預覽要求和替代方案。

視覺與像素效果

在創建視覺效果時,考慮使用 CSS 和 HTML 是否可行,或者是否需要著色器。 偏好順序:

  1. 常規 HTML + CSS 或其他網頁技術
  2. 直接將效果應用於元素(<Video>、<Img>),或通過將內容包裹在 <HtmlInCanvas> 中(它也接受 effects):
  • 透過 effects.md 列出效果
  • 當沒有預設效果可用時,透過 effects.md 使用自訂的 createEffect()。

3D 內容

請參閱 ./3d.md 了解如何在 Remotion 中使用 Three.js 和 React Three Fiber 處理 3D 內容。

音效

當需要使用音效時,請載入 ./sfx.md 檔案以獲取更多資訊。

音訊視覺化

當需要視覺化音訊(頻譜條、波形、低音反應效果)時,請載入 ./audio-visualization.md 檔案以獲取更多資訊。

地圖

對於靜態地圖、動畫路線和標記、地理說明、Mapbox、MapLibre、MapTiler、GeoJSON 或 3D 地理飛越,請載入 Remotion Maps。

字幕

當處理字幕時,請載入 Remotion Captions 技能以獲取更多資訊。

Google Fonts

這是在 Remotion 中載入字型的推薦方式。請參閱 google-fonts.md 了解如何載入 Google Fonts。

本地字型

請參閱 local-fonts.md 了解如何載入本地字型。

GIF

請參閱 gifs.md 了解如何顯示與 Remotion 時間軸同步的 GIF。

進階圖片

請參閱 images.md 了解調整圖片大小和位置、動態圖片路徑以及取得圖片尺寸的方法。

Lottie 動畫

請參閱 lottie.md 了解如何在 Remotion 中嵌入 Lottie 動畫。

時間控制

請參閱 timing.md 了解 interpolate() 的更多時間控制技巧。

參數化影片

請參閱 parameters.md 了解如何通過添加 Zod schema 使組合物件參數化。

測量 DOM 節點

請參閱 measuring-dom-nodes.md 了解如何在 Remotion 中測量 DOM 元素的尺寸。

測量文字

請參閱 measuring-text.md 了解如何測量文字尺寸、將文字適應容器以及檢查溢出。

使用 FFmpeg

對於某些影片操作,例如修剪影片或檢測靜音,應使用 FFmpeg。載入 ./ffmpeg.md 檔案以獲取更多資訊。

靜音檢測

當需要檢測並修剪影片或音訊檔案中的靜音片段時,請載入 ./silence-detection.md 檔案。

動態持續時間、尺寸和資料

請參閱 calculate-metadata.md 了解如何動態設定組合物件的持續時間、尺寸和 props。

組合物件與靜態畫面

在註冊 <Composition> 或 <Still> 元素之前,請閱讀 compositions.md 以了解可來源編輯的註冊、資料夾、預設 props 和巢狀結構。若要在 Studio 中導航到場景自己的時間軸,請使用已連接組合物件。

進階序列編排

請參閱 sequencing.md 了解更多的序列編排模式 - 延遲、修剪、限制項目持續時間。

安裝模組

使用 npx remotion add 來添加具有正確版本的新套件:

npx remotion add @remotion/...

更多功能

Individual skills in this repo

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

Hownameee/short-videos

Generate, revise or troubleshoot local Kokoro narration, pronunciation and scene word timing. Reuse verified unchanged clips; inspect the Python environment before setup changes. Exclude research, visuals, music composition and publishing.

Hownameee/short-videos

Router for all Remotion skills

Hownameee/short-videos

Transcribing, displaying and animating captions

Hownameee/short-videos

Structure Remotion markup for interactivity

Hownameee/short-videos

Remotion Map animation knowledge

Hownameee/short-videos

Upgrade Remotion, and related packages

Hownameee/short-videos

>- Run Phase 1 of the shared short-video workflow: turn a raw topic or prompt into a sourced research pack and 2–4 distinct video directions, each with a defensible tension hook, promise, payoff, beats, visual approach, duration range, and risks. Use whenever the user asks for video ideas, angles, research, facts, hooks, topic analysis, or choices before scriptwriting. Stop for the user's direction choice and do not silently continue into script or production.

Hownameee/short-videos

Produce an approved short video or correct an existing video's background sound, emotion, captions, mix or export. Generate only changed narration, render and review a current preview, run technical and editorial QC, then export. Exclude script-only and general audio-advice requests.

Hownameee/short-videos

>- Run Phase 2 of the shared short-video workflow: convert an explicitly selected direction and its research into a reviewable beat sheet, narration, flexible scene timing, on-screen text, visual plan, captions, music and SFX cues, pronunciation notes, payoff, takeaway, and contextual CTA. Use whenever a user asks to write, revise, preview, or approve a short-video script. Stop for script approval and do not generate TTS or render video yet.

Hownameee/short-videos

>- Design and review a coherent visual system for short-form video before and during Remotion implementation. Use for video art direction, scene UI, typography, layout, color, diagrams, captions, motion, transitions, platform safe areas, or visual-quality review. Use Remotion skills separately for API, timeline, media, Studio, and rendering behavior; do not use this skill for narration-only or research-only work.

Hownameee/short-videos

Coordinate prompt-to-short-video discovery, scripting and production. Resume existing projects and route soundtrack or mix corrections directly to production. Preserve direction choice and script approval; exclude general audio advice.

相關技能