--- name: import-srt-captions description: Importing .srt subtitle files into Remotion using @remotion/captions metadata: tags: captions, subtitles, srt, import, parse --- # 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