SkillsMar 29, 2026·2 min read

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.

TL;DR
Use @remotion/captions to parse .srt subtitle files and render them as timed captions in Remotion videos.
§01

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.

§02

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.

§03

How to use

  1. Install the Remotion skills collection:
npx skills add remotion-dev/skills
  1. Add the captions package to your project:
npx remotion add @remotion/captions
  1. Import and parse an SRT file in your Remotion project.
§04

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>
  );
};
§05

Related on TokRepo

§06

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

What SRT format does Remotion support?+

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.

Can I style captions individually?+

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.

Does this work with VTT files?+

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.

Do I need to install anything extra?+

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.

Can I generate SRT files from audio with Remotion?+

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)
🙏

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

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

Related Assets