Remotion Rule: Subtitles
Remotion skill rule: subtitles and caption rules. Part of the official Remotion Agent Skill for programmatic video in React.
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.
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.
How to use
- Add the Remotion subtitles rule to your project's AI configuration (e.g.,
.cursorrulesor CLAUDE.md). - Ask your AI assistant to add subtitles to your Remotion composition.
- The agent follows the rule to generate correct subtitle components with proper timing.
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>
);
};
Related on TokRepo
- AI Tools for Video -- video creation and editing tools for developers
- Featured Workflows -- discover popular developer tools and skills
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
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.
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.
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.
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.
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)
- Remotion GitHub— Official Remotion Agent Skill for programmatic video
- Remotion Sequence Docs— Sequence component for subtitle timing
- Remotion Fonts Docs— Font loading in Remotion render environment
Related on TokRepo
Source & Thanks
Created by Remotion. Licensed under MIT. remotion-dev/skills — Rule:
subtitles
Part of the Remotion AI Skill collection on TokRepo.
Discussion
Related Assets
Claude-Flow — Multi-Agent Orchestration for Claude Code
Layers swarm and hive-mind multi-agent orchestration on top of Claude Code with 64 specialized agents, SQLite memory, and parallel execution.
ccusage — Real-Time Token Cost Tracker for Claude Code
CLI that reads ~/.claude logs and breaks down Claude Code token spend by day, session, and project — pluggable into your statusline.
SuperClaude — Workflow Framework for Claude Code
Adds 16+ slash commands, 9 cognitive personas, and a smart flag system to Claude Code in one pipx install.