
🚩 2026 年「术哥无界」系列实战文档 X 篇原创计划 第 17 篇,Skills 最佳实战「2026」系列第 8 篇 大家好,欢迎来到 术哥无界 | ShugeX | 运维有术。 我是术哥,一名专注于 AI 编程、AI 智能体、Agent Skills、MCP、云原生、Milvus 向量数据库的技术实践者与开源布道者! Talk is cheap, let's explore。无界探索,有术而行。
前两期我们已经分享过:
今天继续分享排名第三的技能: remotion-best-practices。
说实话,我第一次听说 Remotion 的时候,心里想的是:用代码做视频?这不是闲得慌吗?直到上个月,我看到一个朋友用 Remotion 三天就做出了 50 条个性化营销视频,每条还都不一样,我才意识到这玩意儿有多猛。
今天我们就来聊聊这个技能库里的宝藏工具: Remotion,以及它的最佳实践。

Remotion 是一个基于 React 的视频制作框架,允许开发者用代码创建视频。GitHub 上有 34.9k stars,NPM 月下载量超过 400k,在 skills.sh 平台上每周安装量达到 65.0K,排名第三。
听起来很玄?其实核心概念很简单:你写 React 组件,Remotion 把每一帧渲染出来,最后合成视频。就这么简单。
核心特性:
为什么这么火?
我觉得关键在于三点:
上周我试了一下,用 Remotion 做了一个数据可视化视频,从写代码到导出,只用了两个小时。换成 After Effects,估计一天都不够。
remotion-best-practices 技能由 remotion-dev 官方维护,包含 28 条规则,覆盖从基础到高级的所有场景。让我按功能分类给你梳理一下:

规则分类图
基础概念(4条):
媒体处理(4条):
动画与过渡(5条):
高级功能(4条):
可视化(4条):
工具与实用(4条):
媒体解析(7条):
说实话,28 条规则看着多,但实际常用的也就 10 条左右。掌握了核心的动画、过渡、媒体处理,就能应付 90% 的场景。
这是 Remotion 的核心,也是和其他视频工具最大的区别。
基本原则:所有动画必须由 useCurrentFrame() hook 驱动。禁止使用 CSS 过渡或动画,否则渲染时会闪烁。
让我给你看个例子:
import { useCurrentFrame, interpolate } from "remotion";
export const FadeIn = () => {
const frame = useCurrentFrame();
const { fps } = useVideoConfig();
const opacity = interpolate(frame, [0, 2 * fps], [0, 1], {
extrapolateRight: 'clamp',
});
return <div style={{ opacity }}>Hello World!</div>;
};
这个组件会在前 2 秒内淡入。interpolate 是插值函数,从 0 到 2 秒,透明度从 0 到1。
弹簧动画是另一个强大的工具,能让动画更自然:
const scale = spring({
frame,
fps,
config: { damping: 200 },
});
推荐配置:
{ damping: 200 } - 平滑,无弹跳(微妙揭示){ damping: 20, stiffness: 200 } - 快速,最小弹跳(UI 元素){ damping: 8 } - 弹性入场(有趣动画)我刚用的时候,觉得弹簧动画很复杂,调参数调了半天。后来发现官方推荐的几个配置够用了,别瞎折腾。
过渡效果让视频切换更流畅。使用前需要安装:
npx remotion add @remotion/transitions
然后就可以用 TransitionSeries 组件了:
import { TransitionSeries, linearTiming } from "@remotion/transitions";
import { fade } from "@remotion/transitions/fade";
<TransitionSeries>
<TransitionSeries.Sequence durationInFrames={60}>
<SceneA />
</TransitionSeries.Sequence>
<TransitionSeries.Transition
presentation={fade()}
timing={linearTiming({ durationInFrames: 15 })}
/>
<TransitionSeries.Sequence durationInFrames={60}>
<SceneB />
</TransitionSeries.Sequence>
</TransitionSeries>
可用过渡类型:
fade() - 淡入淡出slide() - 滑动(支持方向:from-left, from-right, from-top, from-bottom)wipe() - 擦除flip() - 翻转clockWipe() - 时钟擦除注意事项:过渡会重叠相邻场景,总组合长度短于所有序列持续时间之和。比如两个 60 帧序列和 15 帧过渡,总长度是 105 帧,不是 120 帧。
时间控制是动画的灵魂。Remotion 提供了 interpolate 和 spring 两个核心函数。
插值函数:
// 线性插值
const opacity = interpolate(frame, [0, 100], [0, 1]);
// 带缓动的插值
const value = interpolate(frame, [0, 100], [0, 1], {
easing: Easing.inOut(Easing.quad),
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
});
缓动类型:
Easing.linear - 线性(默认)Easing.in - 开始慢,加速Easing.out - 开始快,减速Easing.inOut - 开始慢,中间快,结束慢曲线类型(从最线性到最弯曲):
Easing.quadEasing.sinEasing.expEasing.circle以秒为单位编写动画:
// ✅ 正确
const { fps } = useVideoConfig();
const opacity = interpolate(frame, [0, 1 * fps], [0, 1]);
// ❌ 错误(假设 fps=30)
const opacity = interpolate(frame, [0, 30], [0, 1]);
这点很重要,别硬编码 fps 值,不然换了帧率全得改。
public 文件夹是存放资源的地方,使用 staticFile() 引用:
import { Img, staticFile } from 'remotion';
// 图片
<Img src={staticFile('photo.png')} />;
// 视频(来自 @remotion/media)
import { Video } from "@remotion/media";
<Video src={staticFile('clip.mp4')} />;
// 音频(来自 @remotion/media)
import { Audio } from "@remotion/media";
<Audio src={staticFile('music.mp3')} />;
远程 URL 也支持:
<Img src="https://example.com/image.png" />
<Video src="https://remotion.media/video.mp4" />
视频裁剪功能很实用:
<Video
src={staticFile("video.mp4")}
trimBefore={2 * fps} // 跳过前 2 秒
trimAfter={10 * fps} // 结束于第 10 秒
/>
还有音量、速度、循环、音调调整等功能,这里就不一一展开了。
Remotion 不是万能的,但它有自己的适用场景。我给你分析一下:
最适合的场景:
不太适合的场景:
一句话总结:如果你会写 React,需要批量生成或者参数化视频,用 Remotion 准没错。如果只是简单剪辑,用 Premiere 或 Final Cut Pro 吧。
安装很简单,一行命令搞定:
npx create-video@latest
或者用其他包管理器:
bunx create-video@latest
yarn create video@latest
pnpm create video@latest
安装完成后,项目结构大概是这样:
my-video/
├── public/ # 静态资源
├── src/
│ ├── Root.tsx # 根组件,定义所有组合
│ ├── MyComp.tsx # 视频组件
│ └── index.ts # 入口文件
├── package.json
└── remotion.config.ts # 配置文件
验证安装:
npm start
浏览器会自动打开 Remotion Studio,你就能看到你的第一个视频了。
配置文件remotion.config.ts:
import { Config } from '@remotion/cli/config';
Config.setVideoImageFormat('jpeg');
Config.setOverwriteOutput(true);
说实话,默认配置就够用了,别瞎折腾。等熟悉了再根据需要调整。
场景:制作一个 15 秒的 TikTok 风格短视频,包含文字动画和背景音乐。
import { AbsoluteFill, useCurrentFrame, useVideoConfig, Audio, staticFile } from 'remotion';
import { spring } from 'remotion';
export const TikTokVideo = () => {
const frame = useCurrentFrame();
const { fps } = useVideoConfig();
const scale = spring({
frame,
fps,
config: { damping: 8 },
});
const opacity = spring({
frame,
fps,
config: { damping: 200 },
});
return (
<AbsoluteFill style={{ backgroundColor: '#000' }}>
<Audio src={staticFile('music.mp3')} />
<AbsoluteFill
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
transform: `scale(${scale})`,
opacity,
}}
>
<div style={{
fontSize: '80px',
color: '#fff',
fontWeight: 'bold',
textAlign: 'center',
}}>
Hello Remotion!
</div>
</AbsoluteFill>
</AbsoluteFill>
);
};
在 src/Root.tsx 中注册:
import { Composition } from 'remotion';
import { TikTokVideo } from './TikTokVideo';
export const RemotionRoot: React.FC = () => {
return (
<>
<Composition
id="TikTok"
component={TikTokVideo}
durationInFrames={450} // 15 秒 * 30 fps
fps={30}
width={1080}
height={1920} // 9:16 竖屏
/>
</>
);
};
场景:制作一个年度销售数据的柱状图动画。
import { useCurrentFrame, useVideoConfig, spring } from 'remotion';
const data = [
{ label: 'Q1', value: 100 },
{ label: 'Q2', value: 150 },
{ label: 'Q3', value: 120 },
{ label: 'Q4', value: 200 },
];
export const BarChart = () => {
const frame = useCurrentFrame();
const { fps, width, height } = useVideoConfig();
const STAGGER_DELAY = 5;
const bars = data.map((item, i) => {
const delay = i * STAGGER_DELAY;
const barHeight = spring({
frame,
fps,
delay,
config: { damping: 200 },
}) * item.value * 2;
return (
<div
key={i}
style={{
position: 'absolute',
left: `${100 + i * 200}px`,
bottom: '100px',
width: '100px',
height: `${barHeight}px`,
backgroundColor: '#4a9eff',
borderRadius: '8px',
}}
>
<div
style={{
position: 'absolute',
top: '-30px',
left: '50%',
transform: 'translateX(-50%)',
color: '#fff',
fontSize: '24px',
fontWeight: 'bold',
}}
>
{item.value}
</div>
<div
style={{
position: 'absolute',
bottom: '-40px',
left: '50%',
transform: 'translateX(-50%)',
color: '#fff',
fontSize: '24px',
fontWeight: 'bold',
}}
>
{item.label}
</div>
</div>
);
});
return (
<div style={{ width, height, backgroundColor: '#1a1a2e' }}>
<h1 style={{
position: 'absolute',
top: '50px',
left: '50%',
transform: 'translateX(-50%)',
color: '#fff',
fontSize: '48px',
fontWeight: 'bold',
}}>
2024 年度销售数据
</h1>
{bars}
</div>
);
};
场景:制作一个 SaaS 产品的功能演示视频。
import { useCurrentFrame, useVideoConfig, spring, interpolate, AbsoluteFill, Img, staticFile } from 'remotion';
export const ProductDemo = () => {
const frame = useCurrentFrame();
const { fps } = useVideoConfig();
const opacity = spring({
frame,
fps,
config: { damping: 200 },
});
const y = interpolate(frame, [0, 2 * fps], [100, 0], {
extrapolateRight: 'clamp',
});
return (
<AbsoluteFill style={{ backgroundColor: '#fff' }}>
<Img
src={staticFile('product-screenshot.png')}
style={{
position: 'absolute',
top: '200px',
left: '50%',
transform: `translateX(-50%) translateY(${y}px)`,
width: '800px',
opacity,
borderRadius: '16px',
boxShadow: '0 10px 40px rgba(0,0,0,0.1)',
}}
/>
<h1 style={{
position: 'absolute',
top: '50px',
left: '50%',
transform: 'translateX(-50%)',
fontSize: '48px',
fontWeight: 'bold',
color: '#333',
textAlign: 'center',
}}>
新功能上线
</h1>
<p style={{
position: 'absolute',
top: '120px',
left: '50%',
transform: 'translateX(-50%)',
fontSize: '24px',
color: '#666',
textAlign: 'center',
}}>
让你的工作更高效
</p>
</AbsoluteFill>
);
};

效果对比图
这三个案例覆盖了短视频、数据可视化和产品演示三个常见场景,你可以直接拿去改。
Remotion 的商业价值已经得到验证,不少公司用它赚了钱。
Submagic:AI 短视频工具,发布 3 个月后达到 $1M ARR(年经常性收入),拥有超过 300 万用户。用 Remotion 进行视频渲染,参数化视频模板,高度自动化。
AIVideo.com:AI 视频创作平台,不到一年内达到 $100 万年收入。不仅关注短视频,还注重视频质量,使用 Remotion 作为渲染引擎。
Icon.me:病毒级广告制作工具,发布后 30 天内达到 $5M ARR,创造了 Remotion 产品增长的记录。使用 Remotion 作为核心渲染引擎。
Crayo.ai:视频故事生成器,年收入超过 600 万美元。由青少年创始人创建,拥有超过 200 万用户。
Typeframes:产品视频制作工具,创始人 Tibo (Thibault Louis-Lucas)。帮助用户为 SaaS 产品创建精美的产品介绍视频,将文本转换为视频。使用 Remotion Player 提供实时预览,使用 Remotion Lambda 处理渲染。
Shortvid.io:会议资产生成工具,为事件沟通资产创建视频,为聚会、会议和协会提供免费的现成模板。
YARX:个性化视频服务,为数百名参加活动的人创建个性化视频,为滑雪比赛或马拉松等活动的参加者创建个性化视频。
MakeStories:Web Stories 工具,Web 内容创作者的工具,将 Web Stories 导出为 MP4。将渲染时间最小化到一分钟以内。

成功案例图
这些案例说明一个道理:Remotion 不仅能做视频,还能赚钱。如果你有技术能力,可以考虑基于 Remotion 做个产品。
渲染闪烁:使用 CSS 动画或过渡导致。解决方案:所有动画必须由 useCurrentFrame() 驱动。
性能问题:不必要地重新渲染组件、过多的 DOM 节点。解决方案:使用 useMemo() 和 useCallback(),批量更新状态。
内存问题:加载过多大资产。解决方案:使用 prefetch() 预加载资产,使用 continueRender() 和 cancelRender(),分批渲染长视频。
音频拼接:AAC 音频流包含 1024 个样本的包,拼接时需要填充静音。解决方案:每个音频段需要样本数可被 1024 整除,每个段应该在开头和结尾有额外的包。
1. 使用 useCurrentFrame() 驱动所有动画
// ✅ 正确
const frame = useCurrentFrame();
const opacity = interpolate(frame, [0, 30], [0, 1]);
// ❌ 错误
<div style={{ animation: 'fadeIn 1s' }} />
2. 以秒为单位编写动画
// ✅ 正确
const { fps } = useVideoConfig();
const opacity = interpolate(frame, [0, 1 * fps], [0, 1]);
// ❌ 错误(假设 fps=30)
const opacity = interpolate(frame, [0, 30], [0, 1]);
3. 使用 staticFile() 引用 public 文件夹中的文件
// ✅ 正确
<Img src={staticFile('photo.png')} />
// ❌ 错误
<Img src="/photo.png" />
4. 使用 TypeScript 和 Zod schema
// ✅ 正确
export const MyCompositionSchema = z.object({
title: z.string(),
color: zColor(),
});
<Composition
id="MyComposition"
component={MyComponent}
schema={MyCompositionSchema}
/>
5. 使用 calculateMetadata() 动态化组合
const calculateMetadata: CalculateMetadataFunction = async ({ props }) => {
const data = await fetch(`https://api.example.com/data`).then(r => r.json());
return {
durationInFrames: Math.ceil(data.duration * 30),
};
};
使用 useMemo() 和 useCallback():避免不必要的重新渲染。
批量更新状态:减少渲染次数。
使用 <OffthreadVideo> 代替 <Video>:提高视频渲染性能。
启用 WebCodecs 加速:加快视频编码速度。
说实话,性能优化是个无底洞,别太纠结。遇到问题再优化,先保证代码能跑。
Remotion 是一个强大的程序化视频制作框架,基于 React,使用代码创建视频,支持参数化、可扩展渲染,有活跃的社区和生态系统。
remotion-best-practices 技能提供了 28 条全面的最佳实践规则,涵盖从基础到高级的各个方面,包含详细的代码示例和说明,由 remotion-dev 官方维护。
多个成功案例证明了 Remotion 的商业价值:
未来趋势:
Remotion 4.0 已经引入了 Rust 架构,更快的渲染性能,更好的开发体验(Remotion Studio),WebP 和 PDF 支持。
计划中的功能:
AI 集成是另一个重要方向。当前 AI 视频生成工具的兴起,Submagic、AIVideo.com、Revid.ai 等成功案例,参数化视频的自动化,预示着更好的 AI 集成、AI 驱动的视频创作和自动化工作流程。
如果你是开发者,想批量生成视频或者做个性化视频,Remotion 值得一试。如果你是产品经理,想做个视频 SaaS 产品,Remotion 是个不错的选择。
最后说一句:Remotion 的商业模式对独立黑客非常友好。免费:个人和最多 3 人的公司。公司许可证:4+ 人,根据使用情况付费。Typeframes 的创始人 Tibo 虽然不需要购买 Remotion 许可证,但为了支持 Remotion 而购买。这说明什么?说明产品做得好,用户愿意付费支持。
别犹豫了,赶紧试试吧。
好啦,谢谢你观看我的文章,如果喜欢可以点赞转发给需要的朋友,我们下一期再见!敬请期待。