Remotion Claude 技能文档
概述
Remotion Claude 技能是一个全面的 TypeScript 模块,可直接在 Claude AI 中实现程序化视频创建和渲染。它提供了使用 React 组件创建、管理和渲染视频合成的直观 API。
功能特性
- ✅ 创建视频合成 - 使用 React 组件定义视频项目
- ✅ 管理合成 - 注册、检索和组织视频合成
- ✅ 渲染队列管理 - 将合成加入队列以进行批量渲染
- ✅ 多种输出格式 - 支持 h264、h265、VP8、VP9、ProRes、PNG 序列
- ✅ 模板系统 - 常见视频模式的预构建模板
- ✅ 组件库 - 即用型组件,如 TextOverlay 和动画效果
- ✅ 类型安全 - 全面的 TypeScript 支持,包含完整接口
安装
# 克隆 Remotion 仓库
git clone https://github.com/remotion-dev/remotion.git
cd remotion
# 安装依赖
bun install
# 技能位于以下路径:
packages/skills-evals/remotion-claude-skill.ts
快速入门
1. 创建技能实例
import { createRemotionSkill } from './remotion-claude-skill';
const skill = createRemotionSkill({
projectName: 'my-video-project',
width: 1920,
height: 1080,
fps: 30,
durationInFrames: 150,
});
2. 创建 React 组件
import React from 'react';
export const MyVideo: React.FC<{ title: string }> = ({ title }) => {
return (
<div style={{
flex: 1,
backgroundColor: '#000',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
fontSize: 100,
color: '#fff',
fontWeight: 'bold',
}}>
{title}
</div>
);
};
3. 注册合成
skill.createComposition(
'my-video',
'My Video Title',
MyVideo,
{
durationInFrames: 150,
fps: 30,
width: 1920,
height: 1080,
defaultProps: { title: 'Hello World' },
}
);
4. 加入渲染队列
skill.queueForRender('my-video', {
codec: 'h264',
outputLocation: './output/my-video.mp4',
overwrite: true,
});
5. 获取元数据
const metadata = skill.getMetadata();
console.log(metadata);
// {
// name: 'Remotion Claude Skill',
// version: '1.0.0',
// compositionsCount: 1,
// queueLength: 1,
// ...
// }
API 参考
RemotionClaudeSkill 类
构造函数
constructor(config: RemotionSkillConfig)
使用提供的配置创建新的技能实例。
参数:
config:包含 width、height、fps、durationInFrames、projectName 的配置对象
方法
createComposition(id, name, component, options?): CompositionDefinition
创建并注册一个新的合成。
skill.createComposition(
'intro',
'Intro Sequence',
IntroComponent,
{
durationInFrames: 200,
fps: 60,
width: 1920,
height: 1080,
defaultProps: { subtitle: 'My Project' },
}
);
registerComposition(definition): void
注册一个已定义的合成。
const composition: CompositionDefinition = {
id: 'outro',
name: 'Outro Sequence',
component: OutroComponent,
durationInFrames: 150,
fps: 30,
width: 1920,
height: 1080,
};
skill.registerComposition(composition);
getCompositions(): CompositionDefinition[]
返回所有已注册的合成。
const all = skill.getCompositions();
console.log(`Total compositions: ${all.length}`);
getComposition(id): CompositionDefinition | undefined
根据 ID 获取特定的合成。
const intro = skill.getComposition('intro');
if (intro) {
console.log(`Found: ${intro.name}`);
}
queueForRender(compositionId, options): void
将合成加入渲染队列。
skill.queueForRender('intro', {
codec: 'h264',
outputLocation: './videos/intro.mp4',
crf: 18,
concurrency: 4,
overwrite: true,
});
getRenderQueue(): RenderOptions[]
返回所有排队中的渲染作业。
const queue = skill.getRenderQueue();
console.log(`Queued jobs: ${queue.length}`);
clearRenderQueue(): void
清除所有排队中的渲染作业。
skill.clearRenderQueue();
getMetadata(): object
返回技能元数据和统计信息。
const metadata = skill.getMetadata();
console.log(metadata.capabilities);
generateTemplate(type?): string
生成视频组件的模板。
// 选项:'intro' | 'animation' | 'slideshow'
const template = skill.generateTemplate('animation');
console.log(template);
接口
RemotionSkillConfig
interface RemotionSkillConfig {
projectName: string;
width: number;
height: number;
fps: number;
durationInFrames: number;
}
CompositionDefinition
interface CompositionDefinition {
id: string;
name: string;
component: React.ComponentType;
durationInFrames: number;
fps: number;
width: number;
height: number;
defaultProps?: Record<string, unknown>;
}
RenderOptions
interface RenderOptions {
codec: 'h264' | 'h265' | 'vp8' | 'vp9' | 'prores' | 'png';
pixelFormat?: 'yuv420p' | 'yuv422p' | 'yuv444p';
crf?: number;
audioBitrate?: string;
videoBitrate?: string;
outputLocation: string;
concurrency?: number;
overwrite?: boolean;
logFn?: (message: string) => void;
errorFn?: (error: Error) => void;
}
内置组件
TextOverlay
一个简单的文字叠加组件。
import { TextOverlay } from './remotion-claude-skill';
export const MyVideo = () => (
<TextOverlay
text="Hello Claude!"
fontSize={80}
color="#fff"
backgroundColor="rgba(0,0,0,0.7)"
/>
);
动画工具
createFadeInAnimation
生成淡入动画的 CSS。
import { createFadeInAnimation } from './remotion-claude-skill';
const animation = createFadeInAnimation(150, 30);
// 返回:"@keyframes fadeIn { ... }"
模板
片头模板
const template = skill.generateTemplate('intro');
在黑色背景上创建一个简单的文字标题。
动画模板
const template = skill.generateTemplate('animation');
演示弹簧动画和缩放效果。
幻灯片模板
const template = skill.generateTemplate('slideshow');
展示如何创建多个序列以实现幻灯片效果。
完整示例
import React from 'react';
import { createRemotionSkill, TextOverlay } from './remotion-claude-skill';
import { useCurrentFrame, useVideoConfig } from 'remotion';
// 创建技能实例
const skill = createRemotionSkill({
projectName: 'demo',
width: 1920,
height: 1080,
fps: 30,
durationInFrames: 300,
});
// 定义组件
const DemoVideo: React.FC<{ message: string }> = ({ message }) => {
const frame = useCurrentFrame();
const { durationInFrames, fps } = useVideoConfig();
const progress = frame / durationInFrames;
const opacity = Math.min(progress * 2, 1);
return (
<div style={{
flex: 1,
backgroundColor: '#1a1a2e',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
opacity,
}}>
<TextOverlay
text={message}
fontSize={100}
color="#00d4ff"
backgroundColor="rgba(0,0,0,0.8)"
/>
</div>
);
};
// 注册合成
skill.createComposition('demo', 'Demo Video', DemoVideo, {
durationInFrames: 300,
fps: 30,
width: 1920,
height: 1080,
defaultProps: { message: 'Welcome to Remotion + Claude' },
});
// 加入渲染队列
skill.queueForRender('demo', {
codec: 'h264',
outputLocation: './output/demo.mp4',
crf: 18,
overwrite: true,
});
// 检查元数据
console.log(skill.getMetadata());
高级功能
多个合成
skill.createComposition('intro', 'Intro', IntroComponent, {...});
skill.createComposition('main', 'Main Content', MainComponent, {...});
skill.createComposition('outro', 'Outro', OutroComponent, {...});
// 将所有合成都加入渲染队列
for (const comp of skill.getCompositions()) {
skill.queueForRender(comp.id, {
codec: 'h264',
outputLocation: `./videos/${comp.id}.mp4`,
overwrite: true,
});
}
自定义属性
interface VideoProps {
title: string;
subtitle: string;
duration: number;
}
const MyVideo: React.FC<VideoProps> = ({ title, subtitle, duration }) => {
// 组件代码
};
skill.createComposition('custom', 'Custom Video', MyVideo, {
defaultProps: {
title: 'My Title',
subtitle: 'My Subtitle',
duration: 5,
},
});
条件渲染
const ConditionalVideo: React.FC<{ showSubtitle?: boolean }> = ({ showSubtitle }) => {
return (
<div>
<h1>Main Content</h1>
{showSubtitle && <h2>Subtitle</h2>}
</div>
);
};
最佳实践
- 使用 TypeScript - 充分利用组件和属性的类型安全
- 创建可复用组件 - 构建常用模式的组件库
- 优化性能 - 对繁重计算使用记忆化
- 批量渲染 - 将多个合成排队以减少启动开销
- 处理错误 - 在 RenderOptions 中使用
errorFn进行错误处理 - 验证属性 - 始终验证默认属性和用户输入
故障排除
未找到合成
try {
skill.queueForRender('nonexistent', {...});
} catch (error) {
console.error('Composition not found:', error.message);
}
渲染队列管理
// 在添加新作业前清除队列
skill.clearRenderQueue();
// 检查队列长度
console.log(`Pending renders: ${skill.getRenderQueue().length}`);
配置验证
const config = skill.getMetadata();
console.log('Current Configuration:');
console.log(`- Resolution: ${config.config.width}x${config.config.height}`);
console.log(`- FPS: ${config.config.fps}`);
console.log(`- Duration: ${config.config.durationInFrames} frames`);
与 Claude 的集成
在 Claude 会话中
- 引用该技能以交互方式创建视频
- 实时修改组件
- 将多个版本加入队列以进行比较
- 将配置导出为 JSON
示例 Claude 交互
User: "Create an intro video for my podcast"
Claude: I'll create an intro video using the Remotion Claude Skill.
skill.createComposition('podcast-intro', 'Podcast Intro', PodcastIntro, {
durationInFrames: 180,
fps: 30,
width: 1920,
height: 1080,
defaultProps: {
podcastName: 'Your Podcast Name',
tagline: 'Conversations that Matter',
},
});
资源链接
许可证
该技能遵循与 Remotion 相同的许可证。详情请参阅 LICENSE.md。
贡献
要为此技能做出贡献:
- Fork 该仓库
- 创建一个功能分支
- 进行您的更改
- 提交 Pull Request
更多信息请参阅 CONTRIBUTING.md。
支持
- 📖 文档
- 💬 Discord 社区
- 🐛 问题追踪器
- 🌐 网站