SkillsMar 29, 2026·1 min read

Remotion Rule: Subtitles

Remotion skill rule: subtitles and caption rules. Part of the official Remotion Agent Skill for programmatic video in React.

TL;DR
A Remotion agent rule that teaches AI assistants how to add subtitles to React-based videos.
§01

What it is

This Remotion rule defines how AI coding agents should generate subtitle and caption components in Remotion video projects. It is part of the official Remotion Agent Skill that teaches AI assistants the correct patterns for programmatic video creation in React.

The rule targets developers using AI code assistants (Claude Code, Cursor, etc.) to build Remotion video projects that include captions, subtitles, or text overlays.

§02

How it saves time or tokens

Without this rule, AI agents often generate incorrect subtitle timing, wrong component APIs, or deprecated Remotion patterns. The rule provides exact API signatures, timing calculations, and styling patterns so the agent produces working code on the first attempt, avoiding trial-and-error iterations.

§03

How to use

  1. Add the Remotion subtitles rule to your project's AI configuration (e.g., .cursorrules or CLAUDE.md).
  2. Ask your AI assistant to add subtitles to your Remotion composition.
  3. The agent follows the rule to generate correct subtitle components with proper timing.
§04

Example

import { useCurrentFrame, useVideoConfig, Sequence } from 'remotion';

const Subtitle: React.FC<{
  text: string;
  startFrame: number;
  durationInFrames: number;
}> = ({ text, startFrame, durationInFrames }) => {
  const frame = useCurrentFrame();
  const { fps } = useVideoConfig();
  const opacity = Math.min(1, (frame - startFrame) / (fps * 0.3));

  return (
    <Sequence from={startFrame} durationInFrames={durationInFrames}>
      <div style={{
        position: 'absolute',
        bottom: 80,
        width: '100%',
        textAlign: 'center',
        fontSize: 48,
        color: 'white',
        textShadow: '2px 2px 4px rgba(0,0,0,0.8)',
        opacity,
      }}>
        {text}
      </div>
    </Sequence>
  );
};
§05

Related on TokRepo

§06

Common pitfalls

  • Subtitle timing must use frame numbers, not seconds. Convert seconds to frames using Math.round(seconds * fps).
  • Always use the Sequence component for subtitle timing rather than conditional rendering based on frame count. Sequence handles cleanup and performance.
  • Font loading in Remotion requires explicit registration. Do not assume system fonts are available in the render environment.

Frequently Asked Questions

What is a Remotion rule?+

A Remotion rule is a configuration file that teaches AI coding assistants the correct patterns and APIs for Remotion video development. It prevents the AI from generating deprecated or incorrect code by providing exact signatures and best practices.

Does this rule work with any AI assistant?+

The rule works with any AI coding assistant that supports project-level instructions, including Claude Code (CLAUDE.md), Cursor (.cursorrules), and similar tools. The content is the same regardless of the assistant.

How do I sync subtitles with audio?+

Use a transcription service or manual timing to generate a list of text segments with start and end times in seconds. Convert these to frame numbers using the video's fps setting and pass them to the Subtitle component.

Can I style subtitles with custom fonts?+

Yes. Register custom fonts using Remotion's loadFont utility or the @remotion/google-fonts package. Apply the font family in the subtitle component's style object.

Does this rule handle multi-language subtitles?+

The rule provides the subtitle component pattern. Multi-language support is a data concern -- pass different text arrays for different languages to the same component structure.

Citations (3)
🙏

Source & Thanks

Created by Remotion. Licensed under MIT. remotion-dev/skills — Rule: subtitles

Part of the Remotion AI Skill collection on TokRepo.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets