Remotion Basics: A Video as One Composition Object, Frames, Sequences and the Player
Grow the Supabase starter kit into a browser video editor with one agent prompt, then read how Remotion works: a Composition object in frames, a Root that reads its size from props, a Sequence per clip that restarts the frame count, typewriter text at 0.6 characters per frame, and the Player preview.
What you will learn
- Explain how Remotion turns a React component and a frame number into video
- Describe a whole project as one serializable Composition object, stored in frames
- Register a dynamic composition with calculateMetadata so one entry renders any size
- Use Sequence, useCurrentFrame and interpolate for per-clip animation, and Player for the preview
Before you start
- React components and props
- The Supabase starter kit (sign-in, storage)
In this part we build our own video editor in the browser, with Remotion and vibe coding. We start from the starter kit we built earlier and let a coding agent grow it into an editor. Then we open up what it built, so you understand how Remotion turns code into a video.
Start from the starter kit
The Supabase starter kit already has login, sign-up, password reset and Google sign-in, plus the middleware that protects pages. It also has sample pages (dashboard, customers, users, settings) that an editor doesn't need. So the plan is simple: keep the authentication exactly as it is, remove the sample pages, and build the editor on top. The sign-in part is done and tested, so we spend our time on the new idea.
What Remotion is
Remotion is a library for making videos with code, in React. A video is a lot of still pictures shown quickly one after another. Each picture is a frame. In Remotion you write a normal React component, and it asks one question: which frame am I on right now? From that number it decides what to draw, where the text sits, how faded it is, how big it is. Play those frames at 30 a second, and you have a video. That's why many AI video tools use Remotion behind the scenes: a video becomes code you can write, save and change.
One prompt, and the questions it asked
We open the project folder in the coding agent with a four-part prompt. Role: a full stack Next.js developer. Context: our starter kit with Supabase sign-in. Task: remove the sample pages, keep the authentication, and turn the app into a video editor with Remotion, where a user signs in, creates projects, uploads video, audio and images, edits, saves and deletes projects, and renders the video from the page. Format: plan first, ask before big decisions, and give us the SQL to run in Supabase ourselves.
Before building, the agent asked:
- An MP4 export on the server? Yes.
- Where should uploads go? Supabase Storage, one folder per user.
- Who runs the SQL? We do.
That's vibe coding done well: you describe the outcome, answer the questions, and stay in charge of the decisions.
The storage answer is a real decision. Every time a file moves between providers there can be a transfer cost, called egress. With a few users you won't notice; with a lot of video traffic it adds up quickly. Keep files close to where the app runs: R2 on Cloudflare, S3 on AWS, Cloud Storage on Google Cloud. Supabase Storage is enough for testing. On the free plan one file can be up to 50 MB, so keep test videos small.
We create a new Supabase project for this app so the tables don't clash with the starter kit's, and copy its URL, anon key and service role key into the env file the same way as before. Then we run the agent's schema.sql once in the SQL editor. It creates two tables, projects and renders, with row level security so every user sees only their own rows, and two storage buckets, media for uploads and renders for finished videos, with a folder per user.
What the agent added
- A
remotionfolder with the video itself. lib/composition.ts, which describes a project.- The projects page, and the editor page with its components: preview player, timeline, properties panel.
- An API route,
render, that turns a project into an MP4 on the server.
The authentication folders are untouched.
The whole project is one object
From lib/composition.ts:
export interface BaseClip {
id: string;
type: ClipType;
/** Start frame on the project timeline. */
from: number;
/** Length of the clip, in frames. */
durationInFrames: number;
/** Track lane index (0 = top). */
row: number;
}
export type Clip = TextClip | ImageClip | VideoClip | AudioClip;
export interface Composition {
width: number;
height: number;
fps: number;
durationInFrames: number;
background: string;
clips: Clip[];
}
A clip can be text, an image, a video or audio. Every clip has a start frame (from), a length in frames, and a row, its track on the timeline. This one object goes to three places: the preview in the browser reads it, the render on the server reads it, and Supabase stores it as JSON in the projects table. One description of the video, and everything else just reads it.
Here's the default project the editor starts with:
width,
height,
fps: 30,
durationInFrames: 150, // 5s @ 30fps
background: "#0b1020",
clips: [
{
id: uid(),
type: "text",
from: 0,
durationInFrames: 90,
row: 0,
text: "Your title here",
fontSize: 96,
color: "#ffffff",
// ...
animation: "slide-up",
},
],
1920 by 1080 for the landscape preset, 30 frames per second, 150 frames long: 150 divided by 30 is 5 seconds. One text clip, "Your title here", from frame 0 for 90 frames (3 seconds), sliding up. The editor shows you seconds, but the file always stores frames.
Root: one entry renders any size
export const RemotionRoot: React.FC = () => {
const fallback = defaultComposition();
return (
<Composition
id="MainVideo"
component={MainVideo}
durationInFrames={fallback.durationInFrames}
fps={fallback.fps}
width={fallback.width}
height={fallback.height}
defaultProps={{ comp: fallback }}
calculateMetadata={({ props }) => {
const comp = props.comp as Comp;
return {
durationInFrames: comp.durationInFrames,
fps: comp.fps,
width: comp.width,
height: comp.height,
};
}}
/>
);
};
Root.tsx is the list of videos Remotion can render. It registers one Composition, MainVideo. The interesting part is calculateMetadata: it reads the comp prop and takes the size, frame rate and length from it. So a square project renders square and a portrait project renders portrait.
Sequence: each clip gets its own clock
MainVideo.tsx wraps each clip in a Remotion Sequence:
export const MainVideo: React.FC<{ comp: Composition }> = ({ comp }) => {
const maxRow = comp.clips.reduce((m, c) => Math.max(m, c.row), 0);
return (
<AbsoluteFill style={{ backgroundColor: comp.background }}>
{comp.clips.map((clip) => (
<Sequence
key={clip.id}
from={clip.from}
durationInFrames={clip.durationInFrames}
layout="none"
>
<ClipRenderer clip={clip} zIndex={maxRow - clip.row + 1} />
</Sequence>
))}
</AbsoluteFill>
);
};
Before its start the clip isn't drawn, and after its length it's gone. The clever part: inside a Sequence the frame count starts again from zero, so every clip can animate as if it's the only thing in the video. The row decides which clip sits on top; track 1 is the front layer. (This is the finished version, with the explicit zIndex the agent added in a later round; see the editor, continued.)
A frame number goes in, a picture comes out
The text layer reads the current frame, and each animation is a small bit of maths on that number:
const frame = useCurrentFrame();
// ...
switch (clip.animation) {
case "fade":
opacity = interpolate(frame, [0, 12], [0, 1], { extrapolateRight: "clamp" });
break;
case "slide-up":
opacity = interpolate(frame, [0, 12], [0, 1], { extrapolateRight: "clamp" });
translateY = interpolate(frame, [0, 16], [40, 0], { extrapolateRight: "clamp" });
break;
case "typewriter": {
const charsPerFrame = 0.6;
const shown = Math.floor(frame * charsPerFrame);
visibleText = clip.text.slice(0, shown);
break;
}
}
Fade takes opacity from 0 to 1 over the first 12 frames. Slide up does the same and moves the text up into place over 16 frames. Typewriter shows 0.6 characters per frame. In the lecture's render, the subtitle starts at frame 30, so at frame 45 of the video it's 15 frames into its own Sequence. 15 times 0.6 is 9, so you see nine characters, "built wit", and that's exactly what the rendered frame shows. No hidden trick.
The preview uses the same component
<Player
ref={playerRef}
component={MainVideo}
inputProps={{ comp }}
durationInFrames={Math.max(1, Math.round(comp.durationInFrames))}
fps={comp.fps}
compositionWidth={comp.width}
compositionHeight={comp.height}
style={{ width: "100%", height: "100%" }}
controls
acknowledgeRemotionLicense
/>
preview-player.tsx passes MainVideo as the component and the project as the input props, with length, fps and size from the same project. controls gives play, pause and the seek bar. The render route on the server bundles the same MainVideo with the same project, so what you see in the preview is what you get in the file.
The editor, first version
On the left, the add panel for text, image, video and audio. In the middle, the player. At the bottom, the timeline with one row per track and a red playhead. On the right, the properties of the selected clip, with start and duration in seconds (the editor converts to frames). At the top, the project's size, fps, length and the export button.
With the playhead at 1.5 seconds, clicking Text makes a new 3-second text clip starting at the playhead. Tracks 1 to 3 were busy at that moment, so it went on the first free track, track 4. The top bar says saving: the editor waits a little over a second after your last change, then saves the project to Supabase.
Then we tested it. Sign-in worked, with the captcha and with Google. We made a landscape project, changed the title colours, uploaded a 12 MB sample video (under the 50 MB limit) and added a text overlay. But on play, the title didn't show before the video, and the timeline didn't keep up with the playback. The export did render, with our edits. A good first try, not a finished editor. Test, find the gaps, ask again.
Quick recap
| Piece | Job |
|---|---|
Composition object | The whole video in frames; shared by preview, render and database |
Root.tsx + calculateMetadata | One entry, size and length from props |
Sequence | Start and length per clip; frame count restarts at zero inside |
useCurrentFrame + interpolate | Animation as maths on the frame number |
Player | The browser preview of the same component |
Try it yourself
Add a new text animation, like a slide in from the left, or prompt your agent to add it. Then read every line it gives you: it should be one more case with an interpolate on translateX.
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
Backend vs Frontend: What Runs Where, and Why the Server Is the One You Trust
Every web app has two halves. The front end runs on the user's device and is trusted with nothing; the back end holds the data, the secrets and the rules. Checked with real requests to a Django blog.
One Request, Two Answers: the Same Post as an HTML Page and as JSON
Ask a Django blog for the same post twice: once as a 12,731-byte HTML page built by a template, once as 2,976 bytes of JSON built by a serializer. Compare the headers, see who builds the page, and why the server still owns every write.
A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx
Make a blog design from a prompt in Figma Make, download src.zip, unzip it with Python's zipfile module, and read the two files that matter: App.tsx with its selectedPost state and BlogCard.tsx with its props.
How a Web Page Works: HTML Tags, Elements and Attributes
A web page is a text file full of labelled pieces. Learn tags, attributes and nesting with three tiny pages, and see what breaks when an attribute or a closing tag is wrong.
