Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

React
  • Backend vs Frontend: What Runs Where, and Why the Server Is the One You Trust
  • One Request, Two Answers: the Same Post as an HTML Page and as JSON
  • A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx
  • How a Web Page Works: HTML Tags, Elements and Attributes
  • Semantic HTML: header, nav, main, aside and footer as Page Landmarks
  • HTML Forms: Labels, Names, Input Types and Where the Data Goes (GET vs POST)
  • CSS Basics: Selectors, Which Rule Wins, and the Box Model
  • CSS Flexbox vs Grid: A Nav Bar, a Card Row and a Dashboard
  • Responsive CSS: Viewport, Mobile-First Media Queries, clamp() and Dark Mode with Tokens
  • JavaScript for People Who Already Code: Syntax, Modules and Five Surprises
  • JavaScript Arrays the Functional Way: map, filter, reduce, find, sort and Object.entries
  • Async JavaScript: Promises, async/await, fetch and Promise.all
  • JavaScript in the Page: the DOM, querySelector and Events
  • npm, package.json and Vite: What npm install Fetches and How Vite Serves and Builds Your Page
  • TypeScript Essentials: Types Checked, Then Erased (Interfaces, Unions, Generics)
  • Why React, JSX and Components: The Page as a Function of Data
  • React Props and Composition: Data Down, Calls Up, Children in the Slot
  • Routing With React Router: One Page, Many Addresses
  • React Component Tests With Vitest and Testing Library: Test What the User Sees
  • End-to-End Tests for a React App With Playwright: A Full Dress Rehearsal
  • Why AI-Built Websites All Look the Same, and Four Levels That Fix It
  • Visual Hierarchy, Spacing and the 8-Point Grid: Tell the Eye What to Read First
  • Colour, Contrast and Dark Palettes: 60-30-10, Semantic Tokens and Ratios You Can Compute
  • Typography That Sells: Type Scale, Line Length and Free Font Pairings
  • The UI Element Catalogue: Buttons to Toasts, Their Jobs, States and shadcn/ui Names
  • Design Tokens: Primitive and Semantic Tokens, from Figma to CSS to Tailwind
  • Tailwind CSS 4 in React: Utility Classes, Responsive Prefixes, Hover and Dark Mode
  • shadcn/ui in React: Components You Own, Edit and Commit
  • Design Tokens to a Tailwind Theme: Light and Dark Mode with @theme inline
  • Motion in React: Entrance, Hover, Exit and Layout Animations
  • A React Dashboard: Stat Cards, a Recharts Line Chart and a Sortable Table
  • Accessibility in Practice: Dialogs, Menus and the Keyboard in React
  • Reference-Driven Design: Extract a DESIGN.md From a Site You Admire and Build From It
  • Components, Variants and Variables: One Design System in Figma and in CSS
  • Figma MCP Server: Build a React Component From a Frame, Then Write It Back
  • Claude Design: From a Brief to a Clickable Prototype, Then Hand It Off to Claude Code
  • Critiquing AI-Generated UI: Six Checks for Every Screen
  • The AI Design Landscape: Prompt to UI, Prompt to App, and Design to Code
  • Your Brand Rules Folder: One Folder Every AI-Built Page Follows
  • The Best-Practice UI Prompt: Plain Sentences That Beat the Average AI Page
  • UI Ideas From Figma Make, Google Stitch and ChatGPT: One Prompt, Three Designs
  • Google Stitch From a Sketch or Screenshot: Show the Layout, Say What to Keep
  • Stitch to Figma to Code: Turn a Stitch Screen Into Code That Uses Your Tokens
  • Figma Make: Prompt to Prototype With a Four-Part Prompt
  • Upgrade a Dated UI From One Screenshot (or a Reference Image)
  • States and Feedback: Make Every Click Get an Answer
  • A Design-Loop Skill: Claude Screenshots, Scores and Fixes Its Own UI
  • Copy Without the AI Tells: A Copy Pass on a Landing Page
  • Running a Next.js Admin Starter Kit: Route Groups, Theme Tokens and npm run dev
  • Remotion Basics: A Video as One Composition Object, Frames, Sequences and the Player
  • Spline: Put a 3D Scene on a Landing Page Without Writing 3D Code
  • Framer: A Launch Page Without Code, From a Free Animated Template
  • Three.js: What It Can Do on Real Sites, and How to Let Your AI Agent Use It
  • Animated Component Libraries (Magic UI, Aceternity UI): Copy-In Motion and When It Becomes Noise
  • WebGPU and Three.js Shaders in TSL: A Living Gradient, 4,500 Particles and a Hover Ripple
  • Deploy Many Vite Demos as One Static Site: A Gallery Page, One Build Command and import.meta.env.BASE_URL
  • React State, Events, Lists and Conditional Rendering: Follow One Click
  • React useEffect: When It Runs, What Cleanup Is For, and When You Don't Need One
  • Lifting State Up, Refs and React DevTools: Put State Where It Is Needed
  • Forms and Actions in React 19: Controlled Inputs, Form Actions, useActionState and useFormStatus
  • React Context and Custom Hooks: Share One Value, Reuse the Logic
  • Finishing a Remotion Video Editor: Timeline Sync, Track Order, Trims and Fades, and the Server MP4 Render
  • A 3D Product Page in React and Three.js: Scroll Becomes a Number, One Camera Shot per Panel, One Choice Drives Everything
  • A Personal 3D Portfolio Room in React Three Fiber: Hover Glow, Click to Open, Pointer Drift and a Contact Form to FastAPI
  • Server State With TanStack Query: One Key, One Request, One Cache
  • Mutations and Optimistic Updates in TanStack Query: Change Data, Then Tell the Cache
  • Generate TypeScript Types, Query Hooks and Zod From an OpenAPI Spec With Orval
  • A Mock Backend in the Browser With Mock Service Worker, Generated From the Spec
  • A React Client for a FastAPI API: The CORS Wall, CORSMiddleware and the Vite Proxy
  • Forms With React Hook Form and Zod: The API's Rules in the Browser, the Server's Errors Under the Field
  • JWT Auth in a React Client With a FastAPI Backend: Log In, Carry the Token, Let the Server Decide
  • Supabase as a Backend: Postgres, Instant APIs, Row Level Security and the Two Keys
  • Email Login With Supabase in Next.js: Three Clients, Server Actions, the Callback Route and Middleware
  • Google Sign-In With Supabase in Next.js: Which Address Goes Where
  • hCaptcha on a Supabase Login Page: Site Key in the Browser, Secret in Supabase
  1. Blog
  2. /
  3. React
  4. /
  5. Hooks

Finishing a Remotion Video Editor: Timeline Sync, Track Order, Trims and Fades, and the Server MP4 Render

Three prompt rounds turn a first-draft Remotion editor into a usable one: grid/list projects with Delete, a playhead that follows the player, resizable panels, z-index from track numbers, trims and fades, then an export that renders H.264 on the server (65 s the first time, 32 s after). Ends with a full promo made in the finished editor.

Chaand Sheikh

·27 November 2026·Updated 29 November 2026Hooks

What you will learn

  • Keep a timeline playhead in sync with a Remotion Player using requestAnimationFrame and seekTo
  • Turn track numbers into zIndex so track 1 is always the front layer
  • Map fit, scale, trim and audio fades onto Remotion props
  • Follow the export route: bundle once, selectComposition, renderMedia to H.264, upload to storage

Before you start

  • Remotion basics: Composition, Sequence and Player
  • React useEffect and useRef

The first version of the editor could already export a video, but a few things weren't right. This article follows three rounds of fixes, then uses the finished editor from start to end. Every round starts the same way: test the app, write down what's wrong, and ask the agent again.

Round 1: projects page and a playhead that follows

Two problems from the first test. On the projects page there was no way to delete a project, because Delete didn't show in the menu. And the timeline and the viewer weren't connected: the viewer played from the beginning, and the playhead didn't follow.

We took a screenshot of the page and pasted it into the agent with the prompt. A screenshot helps a lot, because the agent sees exactly what you see. Role: a senior front-end developer on a Next.js and Remotion video editor. Context: the projects page and the editor screen, screenshot attached. Task: a grid view and a list view for projects, Delete easy to find in the three-dots menu, and the timeline linked to the viewer so the playhead and picture always show the same moment. Format: audit the whole project, fix what you find, list every change.

Grid or list, remembered

projects-view.tsx keeps one value, view, either grid or list, and saves it in local storage:

  const [view, setView] = React.useState<ViewMode>("grid");
  // on mount:
    const saved = window.localStorage.getItem(STORAGE_KEY);
    if (saved === "grid" || saved === "list") setView(saved);
  // on click:
    setView(next);
    window.localStorage.setItem(STORAGE_KEY, next);

The three-dots menu in project-actions-menu.tsx lists Edit, Rename, Duplicate and Delete, with Delete in red. It's now drawn in a fixed position above everything else, so no card can cut it off, and Delete asks first because it can't be undone.

The playhead follows the player

In timeline.tsx, on every screen refresh the timeline asks the player for its current frame and moves the playhead when it changes:

    let raf = 0;
    let last = -1;
    const tick = () => {
      const f = playerRef.current?.getCurrentFrame();
      if (typeof f === "number" && f !== last) {
        last = f;
        setCurrentFrame(f);
      }
      raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, [playerRef]);

A second effect scrolls the timeline to keep the playhead in view. The other direction still works: drag the playhead and the player seeks.

  function beginScrub(e: React.PointerEvent) {
    scrubbingRef.current = true;
    const frame = frameFromClientX(e.clientX);
    playerRef.current?.seekTo(frame);
    setCurrentFrame(frame);
  }
Player and timeline sync Remotion Player playerRef Timeline playhead at currentFrame getCurrentFrame() every rAF drag: seekTo(frame)
Read the frame on every refresh; seek when the user drags.

Fit, scale, trim and fades

With a test project, the image was far too big at first. Every image and video clip has a Fit setting: cover fills the frame and may crop the edges, contain shows the whole picture. Scale makes it smaller or bigger, and X and Y offsets move it. In MainVideo.tsx these become plain styles:

      <OffthreadVideo
        src={clip.src}
        volume={clipVolume(clip)}
        startFrom={clip.trimStart}
        style={{
          width: "100%",
          height: "100%",
          objectFit: clip.fit,
          transform: `translate(${clip.x}%, ${clip.y}%) scale(${clip.scale})`,
        }}
      />

Trim start is entered in seconds; one second at 30 fps is 30 frames, and that number goes to Remotion as startFrom, so the clip skips its first part. Mute, Volume, Fade in and Fade out live in the same panel. A fade is a small ramp on the volume:

  return (f: number) => {
    let v = base;
    if (fin > 0) {
      v *= interpolate(f, [0, fin], [0, 1], {
        extrapolateLeft: "clamp",
        extrapolateRight: "clamp",
      });
    }
    if (fout > 0) {
      v *= interpolate(f, [clip.durationInFrames - fout, clip.durationInFrames], [1, 0], {
        extrapolateLeft: "clamp",
        extrapolateRight: "clamp",
      });
    }
    return Math.max(0, Math.min(1, v));
  };

Text clips land at the playhead on the first free track, 3 seconds long, fading in, bold white on a transparent background. The properties panel changes the words, animation, size, weight, alignment, colours and offsets, and every change saves straight into the project.

Round 2: room to work

With a few clips in place, the viewer was large and the timeline had little room, and the side panels couldn't be closed. The second prompt: let the user close and open the media panel and the properties panel, and make the viewer smaller or bigger so the timeline gets more room; keep everything else working. While the app runs, the page picks up the new code by itself, so no restart.

In editor.tsx: two top-bar buttons fold the side panels, thin dividers between panels can be dragged within sensible limits, and the divider above the timeline shares space between viewer and timeline. The layout is saved in local storage, and clicking a clip reopens the properties panel by itself.

Round 3: which clip is in front?

The image was on the timeline but invisible in the viewer. Moving clips between tracks changed nothing; the full-screen video still covered it. The third prompt: number the tracks, and treat track 1 as the front layer, so an image on track 1 sits over a full-screen video on track 2; make the preview and the export follow the same order.

The agent's fix, in MainVideo.tsx:

  const maxRow = comp.clips.reduce((m, c) => Math.max(m, c.row), 0);
  // ...
          <ClipRenderer clip={clip} zIndex={maxRow - clip.row + 1} />

It finds the highest row (row 3, the audio track, in the test project). Each clip gets a z-index of highest row minus its own row, plus one. So text on track 1 (row 0) gets 4, the image on track 2 gets 3, the video on track 3 gets 2. The bigger number is drawn in front, so the order no longer depends on which clip was added first. The timeline now numbers every track, with a note that track 1 is the front layer.

zIndex = maxRow - row + 1 zIndex = maxRow - row + 1 (maxRow = 3) Track 1 (row 0): text zIndex 4, front Track 2 (row 1): image zIndex 3 Track 3 (row 2): video zIndex 2 Track 4 (row 3): audio no picture
Track 1 is always in front, whatever order the clips were added in.

Two exports prove it. Text on track 1, image on 2, video on 3: at two seconds, the image and text sit over the video. Move the video to track 1 and the text to track 3: the video fills the frame, and the image and text are hidden behind it. Exactly what the timeline says.

Export: what happens on the server

Export first saves the project, so the server renders the latest version. The window shows "saving your project", then "rendering your video", then "your video is ready" with a preview and a Download MP4 button. The first export took 65 seconds including a headless browser download; the second took 32 seconds.

The render route checks the user is signed in, loads the project, and bundles the Remotion project once per server process:

// Bundling the Remotion project is expensive, so do it once per server process.
let bundlePromise: Promise<string> | null = null;
function getServeUrl(): Promise<string> {
  if (!bundlePromise) {
    bundlePromise = bundle({
      entryPoint: path.join(process.cwd(), "remotion", "index.ts"),
      webpackOverride: (config) => config,
    });
  }
  return bundlePromise;
}

After ensureBrowser(), it renders and uploads:

    const composition = await selectComposition({
      serveUrl,
      id: COMPOSITION_ID,
      inputProps,
    });

    await renderMedia({
      composition,
      serveUrl,
      codec: "h264",
      outputLocation,
      inputProps,
    });

    // 5. Upload the MP4 to Storage and hand back a public URL.
    const fileBuffer = await fs.readFile(outputLocation);
    const storagePath = `${user.id}/${projectId}-${Date.now()}.mp4`;
    const { error: uploadError } = await admin.storage
      .from(RENDERS_BUCKET)
      .upload(storagePath, fileBuffer, {
        contentType: "video/mp4",
        upsert: true,
      });

selectComposition reads size, frame rate and length from the project (through calculateMetadata). renderMedia draws every frame and encodes them into H.264. The file goes to the renders bucket under the user's folder, and the route sends its link back. Ours came out at 1080p, 30 fps, 5 seconds, with sound.

The finished editor, start to end

After one more prompt (audio editing for audio clips and the sound of video clips), the lecture makes a short promo in the finished app, Reelix. npm run dev found port 3000 busy and used 3001. Sign out and back in with Google still works, from the starter kit.

  1. New project "Study Easy Promo", landscape canvas (16:9; portrait is for Reels and Shorts, square for feed posts), Create and edit.
  2. The starting text clip becomes "Welcome to Study Easy". Add an image (track 2, 3 s), a video (track 3, 6 s) and audio (track 4, 8 s). The project length follows the longest clip: 8 seconds.
  3. Drag the image below the video and it's hidden; drag it back and it shows. The track order decides what's in front.
  4. On the video clip, switch Mute on so the music plays and the video stays silent.
  5. Add "StudyEasy.org" on track 1 from 3 to 6 seconds, with fade in.

The plan: 0 to 3 s, the title in front of the image, video hidden. At 3 s the image and first text end, so the video shows with StudyEasy.org in front. At 6 s the video ends, so the last two seconds are only background, with music for all 8 seconds. The first export took about two minutes (Remotion downloaded a headless browser first), the next about 35 seconds. Preview and export both run on your machine, so speed depends on your hardware. The download showed exactly what we planned.

Common mistakes

  • Relying on array order for layers. Use an explicit z-index from the track number.
  • Re-bundling Remotion on every export. Cache the bundle promise per process.
  • Rendering an unsaved project. Save first, then send the project ID.
  • Describing a UI bug only in words. Paste a screenshot with the prompt.

Quick recap

FixKey code
Playhead follows playerrequestAnimationFrame + getCurrentFrame(); drag calls seekTo
Front layerzIndex = maxRow - row + 1
TrimstartFrom={clip.trimStart}
Fadesvolume as a function of frame with interpolate
Exportbundle once, selectComposition, renderMedia H.264, upload to renders

Try it yourself

Add a lock button to each track so its clips can't be dragged, or prompt your agent to add it, and then read every line it gives you.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in React · 62 of 75

Previous
React Context and Custom Hooks: Share One Value, Reuse the Logic
Next post
A 3D Product Page in React and Three.js: Scroll Becomes a Number, One Camera Shot per Panel, One Choice Drives Everything

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

React State, Events, Lists and Conditional Rendering: Follow One Click

Follow one click through a React counter, render by render: what useState hands back, why a plain variable never updates the page, ternaries and &&, map with keys, and the index-as-key bug that moves a typed note to the wrong task.

React useEffect: When It Runs, What Cleanup Is For, and When You Don't Need One

Watch useEffect on a timeline with real render counts: the dependency array deciding re-runs, a timer cleanup that keeps one timer alive, the leak StrictMode exposes, and two effects you should delete (a copied total and a click flag).

Lifting State Up, Refs and React DevTools: Put State Where It Is Needed

A task board where the filter is stuck in one component, fixed by lifting it to App. Then useRef as a box React does not watch (three clicks, zero renders), a ref that refocuses an input, and the tree React DevTools shows.

Forms and Actions in React 19: Controlled Inputs, Form Actions, useActionState and useFormStatus

Four versions of an add-task form, traced with real logs: a controlled input, a classic onSubmit, a form action that gets FormData and resets itself, and useActionState with a pending button from useFormStatus, plus the draft trick that keeps typed text after an error.

On this page

  • Round 1: projects page and a playhead that follows
  • Grid or list, remembered
  • The playhead follows the player
  • Fit, scale, trim and fades
  • Round 2: room to work
  • Round 3: which clip is in front?
  • Export: what happens on the server
  • The finished editor, start to end
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

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)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.