Remotion Rule: Import Srt Captions
Remotion skill rule: Importing .srt subtitle files into Remotion using @remotion/captions. Part of the official Remotion Agent Skill for programmatic video in React.
What it is
This is a Remotion skill rule for importing .srt (SubRip) subtitle files into Remotion video projects. It uses the @remotion/captions package to parse SRT files and convert them into timed caption data that can be rendered as text overlays in your video composition.
The rule is part of the official Remotion Agent Skill collection, designed for developers using AI coding assistants (Claude Code, Cursor, OpenAI Codex) to build React-based programmatic videos with subtitles.
How it saves time or tokens
Parsing SRT files manually requires handling timestamp formats, multi-line text, and sequence numbering. The @remotion/captions package handles all parsing details and returns structured caption data ready for rendering. Without this rule, an AI assistant might generate custom SRT parsers or suggest incompatible libraries. The rule ensures the assistant uses the official Remotion package directly.
How to use
- Install the Remotion skills collection:
npx skills add remotion-dev/skills
- Add the captions package to your project:
npx remotion add @remotion/captions
- Import and parse an SRT file in your Remotion project.
Example
import { parseSrt } from '@remotion/captions';
import { useCurrentFrame, useVideoConfig } from 'remotion';
import fs from 'fs';
// In a Node.js script or getStaticProps
const srtContent = fs.readFileSync('subtitles.srt', 'utf-8');
const captions = parseSrt({ input: srtContent });
// In a Remotion component
export const SubtitleOverlay: React.FC<{ captions: Caption[] }> = ({ captions }) => {
const frame = useCurrentFrame();
const { fps } = useVideoConfig();
const currentTime = frame / fps;
const activeCaption = captions.find(
c => currentTime >= c.startMs / 1000 && currentTime <= c.endMs / 1000
);
if (!activeCaption) return null;
return (
<div style={{ position: 'absolute', bottom: 50, textAlign: 'center', width: '100%' }}>
<span style={{ background: 'rgba(0,0,0,0.7)', color: 'white', padding: '4px 12px' }}>
{activeCaption.text}
</span>
</div>
);
};
Related on TokRepo
- AI Tools for Video — Video production and editing tools
- Featured Workflows — Top-rated skills and workflows
Common pitfalls
- SRT files must use UTF-8 encoding; files with other encodings (e.g., ISO-8859-1) will produce garbled characters. Convert to UTF-8 before parsing.
- The parseSrt function returns timestamps in milliseconds; convert to seconds (divide by 1000) when comparing with Remotion's frame-based timing.
- Large SRT files with hundreds of entries are fine for parsing but may need optimization for rendering; avoid re-searching the full array on every frame by pre-computing frame-to-caption mappings.
Frequently Asked Questions
Remotion's parseSrt function supports standard SubRip (.srt) format with sequence numbers, timestamps (HH:MM:SS,mmm), and text content. It handles multi-line captions and common formatting variations.
Yes. The parsed caption data is plain objects with text and timing. You control all rendering in your React component, so you can apply any CSS styles, animations, or effects to individual captions.
The parseSrt function is specifically for SRT files. For WebVTT (.vtt) files, check if @remotion/captions provides a separate parser, or convert VTT to SRT before importing.
Run npx skills add remotion-dev/skills for the AI skill rule, and npx remotion add @remotion/captions for the caption parsing package. Both are needed for full functionality.
Yes. Use the @remotion/install-whisper-cpp package to transcribe audio to captions, then export as SRT. This pairs well with the import SRT rule for round-trip caption workflows.
Citations (3)
- Remotion Captions Docs— Remotion captions package for parsing SRT files
- Remotion Skills GitHub— Remotion Agent Skill for AI-assisted video development
- Remotion SRT Documentation— SubRip SRT subtitle format specification
Related on TokRepo
Source & Thanks
Created by Remotion. Licensed under MIT. remotion-dev/skills — Rule:
import-srt-captions
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.