Remotion — React로 프로그래매틱 비디오 제작
React 컴포넌트를 사용하여 프로그래매틱 방식으로 비디오를 제작합니다. 코드 기반 비디오 제작을 위한 가장 성숙한 프레임워크입니다.
개요
- 저장소: github.com/remotion-dev/remotion (21K+ 스타)
- 언어: TypeScript / React
- 라이선스: 연 매출 100만 달러 미만의 개인 및 기업에게 무료
- 설치:
npm install remotion @remotion/cli @remotion/transitions - 문서: remotion.dev/docs
핵심 개념
Composition (구성)
<Composition>은 비디오의 해상도, 프레임 속도, 길이를 정의합니다:
import { Composition } from "remotion";
export const RemotionRoot: React.FC = () => {
return (
<Composition
id="MyVideo"
component={MyVideo}
durationInFrames={300} // 30fps 기준 10초
fps={30}
width={1920}
height={1080}
/>
);
};
애니메이션 기본 요소
useCurrentFrame() — 현재 프레임 번호(0부터 시작)를 반환합니다:
const frame = useCurrentFrame();
interpolate() — 프레임 범위를 출력 값에 매핑합니다:
import { interpolate, useCurrentFrame } from "remotion";
const opacity = interpolate(frame, [0, 30], [0, 1], {
extrapolateRight: "clamp",
});
spring() — 물리 기반 스프링 애니메이션:
import { spring, useCurrentFrame, useVideoConfig } from "remotion";
const { fps } = useVideoConfig();
const scale = spring({ frame, fps, config: { damping: 200 } });
시퀀싱
— 콘텐츠를 시간상으로 이동시킵니다:
<Sequence from={30} durationInFrames={60}>
<MyScene />
</Sequence>
— 자식 요소를 순서대로 배치합니다:
import { Series } from "remotion";
<Series>
<Series.Sequence durationInFrames={90}>
<IntroScene />
</Series.Sequence>
<Series.Sequence durationInFrames={150}>
<MainScene />
</Series.Sequence>
<Series.Sequence durationInFrames={60}>
<OutroScene />
</Series.Sequence>
</Series>
— 전체 프레임을 차지하는 컨테이너:
<AbsoluteFill style={{ backgroundColor: "#0a0a0a" }}>
<h1>Hello World</h1>
</AbsoluteFill>
전환 효과
import { linearTiming, TransitionSeries } from "@remotion/transitions";
import { fade } from "@remotion/transitions/fade";
import { slide } from "@remotion/transitions/slide";
<TransitionSeries>
<TransitionSeries.Sequence durationInFrames={90}>
<Scene1 />
</TransitionSeries.Sequence>
<TransitionSeries.Transition
presentation={fade()}
timing={linearTiming({ durationInFrames: 15 })}
/>
<TransitionSeries.Sequence durationInFrames={90}>
<Scene2 />
</TransitionSeries.Sequence>
</TransitionSeries>
사용 가능한 전환 효과: fade, slide, wipe, flip, clockWipe, none
미디어
import { Video, Audio, Img, staticFile } from "remotion";
// 정적 파일은 /public 디렉터리
<Video src={staticFile("demo.mp4")} />
<Audio src={staticFile("music.mp3")} volume={0.5} />
<Img src={staticFile("logo.png")} />
프로젝트 설정
# 새 프로젝트 생성
npx create-video@latest my-video
# 또는 수동으로:
mkdir my-video && cd my-video
npm init -y
npm install remotion @remotion/cli @remotion/transitions react react-dom
npm install -D typescript @types/react
필수 파일
src/index.ts (진입점):
import { registerRoot } from "remotion";
import { RemotionRoot } from "./Root";
registerRoot(RemotionRoot);
remotion.config.ts:
import { Config } from "@remotion/cli/config";
Config.setVideoImageFormat("jpeg");
Config.setOverwriteOutput(true);
명령어
# 브라우저에서 미리보기 (Remotion Studio)
npx remotion studio
# MP4로 렌더링
npx remotion render MyVideo out/video.mp4
# 특정 프레임만 렌더링
npx remotion render MyVideo out/video.mp4 --frames=0-90
# GIF로 렌더링
npx remotion render MyVideo out/video.gif --image-format=png
# 정지 이미지 렌더링
npx remotion still MyVideo out/thumbnail.png --frame=45
모범 사례
- 항상 보간을 제한하세요:
extrapolateRight: "clamp"를 사용하여 값이 범위를 벗어나지 않도록 하세요. - 자연스러운 움직임을 위해 spring() 사용: 스프링은 선형 보간보다 더 유기적인 느낌을 줍니다.
- 각 장면을 별도의 컴포넌트로 유지: 각 장면은 고유한 React 컴포넌트여야 합니다.
- 순차적 장면에는 사용: 수동 오프셋 계산보다 쉽습니다.
- 명시적인 지속 시간 설정: 모든 Sequence에는
durationInFrames가 있어야 합니다. - AbsoluteFill 사용: 전체 프레임 배경과 중첩 레이어에 유용합니다.
- 정적 에셋은 /public 디렉터리에:
staticFile()을 사용하여 참조하세요. - 다양한 프레임에서 테스트: Remotion Studio 스크러버로 애니메이션을 확인하세요.
- CSS transform 선호:
transform: scale()과translateX()는 GPU 가속을 받습니다. - 무거운 리렌더링 방지:
useMemo로 비용이 큰 계산을 메모이제이션하세요.
일반적인 패턴
페이드인 텍스트:
const frame = useCurrentFrame();
const opacity = interpolate(frame, [0, 20], [0, 1], { extrapolateRight: "clamp" });
const y = interpolate(frame, [0, 20], [20, 0], { extrapolateRight: "clamp" });
<div style={{ opacity, transform: `translateY(${y}px)` }}>
Hello World
</div>
순차적 리스트 아이템:
{items.map((item, i) => {
const delay = i * 8;
const opacity = interpolate(frame, [delay, delay + 15], [0, 1], {
extrapolateLeft: "clamp",
extrapolateRight: "clamp",
});
return <div key={i} style={{ opacity }}>{item}</div>;
})}
타자기 효과:
const charsShown = interpolate(frame, [0, text.length * 2], [0, text.length], {
extrapolateRight: "clamp",
});
<span>{text.slice(0, Math.floor(charsShown))}</span>
확장 패키지 (모두 오픈소스, npm install로 설치)
@remotion/transitions— 장면 전환 효과 (페이드, 슬라이드, 와이프)@remotion/three— React Three Fiber를 활용한 비디오 내 3D 장면@remotion/lottie— Lottie 애니메이션 삽입@remotion/gif— GIF 파일 삽입@remotion/media-utils— 오디오/비디오 메타데이터 유틸리티@remotion/noise— 유기적 효과를 위한 펄린 노이즈@remotion/paths— SVG 경로 애니메이션 유틸리티
상위 스킬 출처
- 공식 스킬: github.com/remotion-dev/skills
- 템플릿: github.com/reactvideoeditor/remotion-templates
- Superpowers 파이프라인: github.com/dojocodinglabs/remotion-superpowers