# 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. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash npx skills add remotion-dev/skills ``` This rule activates automatically when working with import srt captions in a Remotion project. --- ## Intro Importing .srt subtitle files into Remotion using @remotion/captions. Part of the [Remotion AI Skill](https://tokrepo.com/en/workflows/57997ead-c8fa-409c-916f-28bbc0adc8d9) — the official Agent Skill for programmatic video creation in React. **Best for**: Developers using Remotion for import srt captions **Works with**: Claude Code, OpenAI Codex, Cursor --- ## Rule Content # Importing .srt subtitles into Remotion If you have an existing `.srt` subtitle file, you can import it into Remotion using `parseSrt()` from `@remotion/captions`. If you don't have a .srt file, read [Transcribing audio](transcribe-captions.md) for how to generate captions instead. ## Prerequisites First, the @remotion/captions package needs to be installed. If it is not installed, use the following command: ```bash npx remotion add @remotion/captions # If project uses npm bunx remotion add @remotion/captions # If project uses bun yarn remotion add @remotion/captions # If project uses yarn pnpm exec remotion add @remotion/captions # If project uses pnpm ``` ## Reading an .srt file Use `staticFile()` to reference an `.srt` file in your `public` folder, then fetch and parse it: ```tsx import { useState, useEffect, useCallback } from "react"; import { AbsoluteFill, staticFile, useDelayRender } from "remotion"; import { parseSrt } from "@remotion/captions"; import type { Caption } from "@remotion/captions"; export const MyComponent: React.FC = () => { const [captions, setCaptions] = useState(null); const { delayRender, continueRender, cancelRender } = useDelayRender(); const [handle] = useState(() => delayRender()); const fetchCaptions = useCallback(async () => { try { const response = await fetch(staticFile("subtitles.srt")); const text = await response.text(); const { captions: parsed } = parseSrt({ input: text }); setCaptions(parsed); continueRender(handle); } catch (e) { cancelRender(e); } }, [continueRender, cancelRender, handle]); useEffect(() => { fetchCaptions(); }, [fetchCaptions]); if (!captions) { return null; } return {/* Use captions here */}; }; ``` Remote URLs are also supported - you can `fetch()` a remote file via URL instead of using `staticFile()`. ## Using imported captions Once parsed, the captions are in the `Caption` format and can be used with all `@remotion/captions` utilities. --- ## Source & Thanks > Created by [Remotion](https://github.com/remotion-dev). Licensed under MIT. > [remotion-dev/skills](https://github.com/remotion-dev/skills) — Rule: `import-srt-captions` Part of the [Remotion AI Skill](https://tokrepo.com/en/workflows/57997ead-c8fa-409c-916f-28bbc0adc8d9) collection on TokRepo. --- Source: https://tokrepo.com/en/workflows/35ed666e-ab87-4ac0-9308-7ef73f9f0e9a Author: Skill Factory