# SRT

Canonical URL: https://encode.wiki/codecs/subtitles/srt/
Content version: ca42e61ede0a24f789d7287a0001244ad22f4abf
Status: current
License: CC BY-SA 4.0
Checksum (SHA-256): 4d08038a6add4bfc41fa8d79f9acc701b54a812295d0c252b412c425f182342b

SubRip (`.srt`) is the lowest common denominator of subtitle formats: plain text with timestamps. Almost every player, editor and platform reads it, so it is the format of choice for sharing dialogue-only subtitles. It has no formal specification; behaviour beyond the basics varies between players.

## Format

A file is a list of cues separated by blank lines. Each cue is a counter, a time range, and one or more lines of text:

```text
1
00:00:01,000 --> 00:00:03,500
The test begins here.

2
00:00:04,000 --> 00:00:07,000
<i>[A steady tone sounds]</i>
Check the picture and the sound together.
```

Timestamps are `HH:MM:SS,mmm` with a **comma** before the milliseconds (WebVTT uses a period). Save as UTF-8, which is what modern tools write and expect.

Basic HTML-style tags are widely accepted: `<i>`, `<b>`, `<u>`, and `<font color="#ffff00">`. Players that do not understand a tag print it literally. Positioning (`{\an8}` for top-centre) is an ASS override that mpv, VLC and most desktop players honour inside SRT; players that do not know it show it as text. There is no way to set fonts, outlines or animation, so use [ASS](/codecs/subtitles/ssa/) for typesetting and [WebVTT](/codecs/subtitles/webvtt/) for web players.

Because SRT times are in seconds, not frames, it is independent of the video's frame rate. Fixing a constant offset is a one-liner; the delay is applied by FFmpeg as an input timestamp offset:

```sh
ffmpeg -itsoffset 2 -i subs.srt -c copy delayed.srt
```

For a drifting subtitle (a different cut or frame rate), use an editor such as Subtitle Edit or Aegisub, or an automatic aligner like `ffsubsync`.

## Fix garbled characters

If accents or non-Latin letters show as `Ã©` or `?`, the file is in a legacy encoding. Find out which (`file -i subs.srt` guesses; the language usually tells you: CP1252 for Western European, CP1251 for Russian, CP1250 for Central European), then convert:

```sh
ffmpeg -sub_charenc CP1252 -i legacy.srt utf8.srt
iconv -f CP1252 -t UTF-8 legacy.srt > utf8.srt
```

`-sub_charenc` is an input option, so it goes before `-i`.

## Use SRT in containers

```sh
ffmpeg -i video.mkv -i subs.srt -map 0 -map 1 -c copy -metadata:s:s:0 language=eng output.mkv
mkvmerge -o output.mkv video.mkv --language 0:eng subs.srt
ffmpeg -i video.mkv -i subs.srt -map 0 -map 1 -c copy -c:s mov_text output.mp4
```

In Matroska SRT is stored as `S_TEXT/UTF8` and round-trips cleanly. MP4 stores it as `mov_text`, which keeps basic italics, bold and underline but not much else. [WebM](/containers/webm/) takes only WebVTT, so convert first: `ffmpeg -i subs.srt subs.vtt`.

Extract a track back out with `ffmpeg -i input.mkv -map 0:s:0 subs.srt`.

## Conversions

SRT to ASS or WebVTT keeps everything SRT has: text, italics and bold carry over. Going the other way, from a styled ASS file, loses everything ASS does and leaves FFmpeg's leftovers (`<font size="…">` wrappers, stray `{\an8}`); expect to clean up by hand. See the [subtitle formats overview](/codecs/subtitles/) for the rest, including how to burn SRT into the picture.
