Install
openclaw skills install remotion-cnRemotion 视频创建框架 - React 编程创建视频(中文版)
openclaw skills install remotion-cnRemotion 是一个用 React 创建视频的强大框架。支持多种输出格式(MP4、WebM、GIF),可以在服务器端渲染视频。
# 使用 create-video
npx create-video@latest my-video
cd my-video
# 或使用 Vite
npx create-vite@latest my-video
cd my-video
npm install remotion
npm install remotion @remotion/cli --save-dev
// src/App.tsx
import { Composition } from 'remotion';
export const RemotionRoot: React.FC = () => {
return (
<Composition>
<HelloWorld />
</Composition>
);
};
export default RemotionRoot;
// src/HelloWorld.tsx
import { AbsoluteFill } from 'remotion';
export const HelloWorld: React.FC = () => {
return (
<AbsoluteFill style={{ backgroundColor: 'white' }}>
<div style={{ fontSize: 120, color: 'black', fontFamily: 'sans-serif' }}>
你好,Remotion!
</div>
</AbsoluteFill>
);
};
# 渲染为 MP4
npx remotion render src/App.tsx out/video.mp4
# 在浏览器中预览
npx remotion studio src/App.tsx
import { AbsoluteFill, useCurrentFrame, useVideoConfig, Video } from 'remotion';
export const TextSlide: React.FC = () => {
const frame = useCurrentFrame();
return (
<AbsoluteFill style={{ backgroundColor: '#1a1a2a' }}>
<div style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100%'
}}>
<h1 style={{
fontSize: 80,
color: 'white',
opacity: frame % 60, // 闪烁效果
transform: `translateY(${Math.sin(frame * 0.1) * 20}px)`
}}>
薅羊毛自动化
</h1>
</div>
</AbsoluteFill>
);
};
export default Video(TextSlide);
import { useVideo } from '@remotion/use-video';
import { staticFile } from 'remotion';
export const MyVideo: React.FC = () => {
const video = useVideo(staticFile('video.mp4'));
return (
<Video src={video} />
);
};
import { AbsoluteFill, useCurrentFrame, Audio, Sequence } from 'remotion';
export const AudioExample: React.FC = () => {
return (
<AbsoluteFill>
<Sequence>
<Audio src={staticFile('music.mp3')} />
</Sequence>
</AbsoluteFill>
);
};
import { GIF, useCurrentFrame, staticFile } from 'remotion';
export const AnimatedGif: React.FC = () => {
const frame = useCurrentFrame();
return (
<AbsoluteFill style={{ backgroundColor: 'black' }}>
<GIF width={400} height={400} src={staticFile('image.png')} />
</AbsoluteFill>
);
};
import { AbsoluteFill, Sequence, useCurrentFrame } from 'remotion';
export const Multitrack: React.FC = () => {
const frame = useCurrentFrame();
return (
<AbsoluteFill style={{ backgroundColor: 'white' }}>
<Sequence from={0} durationInFrames={60}>
<Text>第一轨</Text>
</Sequence>
<Sequence from={60} durationInFrames={60}>
<Text>第二轨</Text>
</Sequence>
</AbsoluteFill>
);
};
import { Config } from '@remotion/cli/config';
export default {
concurrency: 1, // 并发数量
chromiumPath: null, // 使用默认 Chromium
ffmpegExecutable: null, // 使用默认 FFmpeg
log: 'verbose', // 日志级别
overwrite: true, // 覆盖已存在的文件
ignore: [
'node_modules',
'.git'
]
} as Config;
# 启动开发服务器
npx remotion studio
# 渲染预览
npx remotion preview src/App.tsx
# 渲染 MP4
npx remotion render src/App.tsx out/video.mp4
# 指定分辨率
npx remotion render src/App.tsx out/video.mp4 --width=1920 --height=1080
# 渲染 GIF
npx remotion render src/App.tsx out/video.gif --codec=gif
# 渲染 PNG 序列
npx remotion render src/App.tsx out/video/ --sequence
# 使用配置文件
npx remotion render src/App.tsx out/video.mp4 --config=remotion.config.ts
| 框架 | 优点 | 缺点 |
|---|---|---|
| Remotion | React 编程,高性能,组件化 | 需要 React 知识 |
| Canvas | 简单,学习曲线平 | 性能一般,功能有限 |
| Three.js | 强大的 3D 能力 | 学习曲线陡峭 |
| P5.js | 脚本化,简单 | 功能有限 |
npm install remotion# 从数据生成产品宣传视频
npx create-video@latest product-video
cd product-video
# 从 API 获取产品数据
# 渲染每个产品的短视频
# 自动生成抖音/快手视频
npx create-video@latest social-video
cd social-video
# 根据热点生成视频
# 自动生成教学视频
npx create-video@latest education-video
cd education-video
# 从讲义生成视频
from openai import OpenAI
def generate_remotion_code(video_description):
"""用 AI 生成 Remotion 代码"""
client = OpenAI(api_key="your_key")
prompt = f"""
创建一个 Remotion 组件:
{video_description}
要求:
1. 使用 TypeScript
2. 导入 Remotion 必需组件
3. 代码简洁可读
4. 添加适当的样式
"""
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt}]
)
return response.choices[0].message.content
# 使用
code = generate_remotion_code("一个产品展示视频,展示旋转和缩放")
print(code)
| 版本 | 发布日期 | 变更 |
|---|---|---|
| 1.0.0 | 2026-02-19 | 初始版本,基础功能 |
| 1.1.0 | 待定 | 集成 AI 代码生成 |
MIT
版本: 1.0.0 框架: Remotion (React 视频创建) 适配: 中文环境和社区