What Is an SRT File? The Plain Text Subtitle File, and How to Check, Fix and Convert One
An SRT file is a plain text subtitle file that stores captions as numbered cues with times. Four readers agreed on only 14 of the 21 damaged copies we made of one. Jump to your question below, or work through it in order.
What Is an SRT File? The plain text subtitle file with numbered cues
Short answer
An SRT file is a plain text subtitle file that stores captions as numbered cues with start and end times. SubRip made the format in 1999, per Wikipedia, and most subtitles shared online use it. Nothing inside the file names its text encoding, so players have to guess.
We tested 53 public SRT files with four readers, ffmpeg, pysrt, srt and pysubs2. All four passed 35 of them. We then damaged one SRT file in 21 ways, and the four readers agreed with the original on 10 copies.
To open one, see the open steps. To check one, see the check steps. If your SRT file will not load, begin with the eight causes.
An SRT file is a plain text subtitle file. Every cue has a number, a start and end time and one or more lines of text. SubRip made the format in 1999, and the file has no header and no declared encoding.
Picture a friend who sends movie.srt and says the captions come late. You open it in a text editor and see numbers, times and sentences. Picture a second file that shows broken letters where the accents should be. Both files share one layout and differ only in how their bytes were saved.
Wikipedia describes SubRip as a free Windows program that a user called Brain made in 1999. The program gave the format its name and its .srt ending. Wikipedia quotes Matroska and calls it perhaps the most basic of all subtitle formats.
An SRT file holds one cue after another. A cue is a number, a time line, one or more lines of text and a blank line. Times use hours, minutes, seconds and milliseconds, with a comma before the milliseconds.
SRT has no official standard for text encoding. Wikipedia says parsers have to detect it, and that a byte order mark helps. ffmpeg assumes UTF-8, per the same page, and our Latin-1 copy showed what that costs.
Wikipedia gives the media type as application/x-subrip and adds that IANA has not approved it. The file command printed the same type for our example. Players also accept simple tags like italics, but Wikipedia calls that support unofficial.
Where our SRT files come from
We read 53 files from 14 public projects. The largest are pysrt with 11 files, webvtt-py with 10, Subtitle Edit with 7 and whisper-ctranslate2 with 6. The srt library adds 2. All 53 end in .srt.
They are test files, and some exist to break readers on purpose. They are 0 to 165,900 bytes long and 1,431,740 bytes in total, and the median is 601 bytes. One file is empty.
So this page studies how readers treat the SRT layout, and not a sample of subtitles from everyday downloads. We also made one file of 5 cues and damaged it in 21 ways. We opened nothing in a video player, and we tested no player.
SRT file facts at a glance
| Property | Value |
|---|---|
| Meaning | SubRip text. It stores captions as numbered cues with a start and an end time. |
| Ending | .srt, per Wikipedia. |
| Maker | A user named Brain made SubRip in 1999, per Wikipedia. |
| Layout | A number, a time line, text lines and a blank line, repeated for every cue. |
| Time format | hh:mm:ss,mmm --> hh:mm:ss,mmm, with a comma before the milliseconds. |
| Encoding | Not declared in the file. Wikipedia says no official standard exists. 35 of our files start with a number, 9 with a BOM and 4 with a UTF-16 or UTF-32 mark. |
| Type | Wikipedia gives application/x-subrip and says IANA has not approved it. The file command printed the same type for our example. |
| Our tests | 53 files, 21 damaged copies, 4 readers, 1 repair route and a script of 32 lines. |
Wrong page? A WebVTT file starts with the word WEBVTT and uses a dot in its times. See how VTT and ASS files differ.
Which Kind of SRT File Do You Have? Four starts, and the first bytes name the kind
Four starts name the kind of an SRT file. In our 53 files, 35 start with a number, 9 with a UTF-8 BOM, 4 with a UTF-16 or UTF-32 mark and 5 with something else. All of them end in .srt, so the ending names none of the odd ones.
Look at the first bytes and follow the figure. We tested all four starts with four readers. The ending helps less than you think, because 5 of our 53 .srt files are not numbered cue lists.
The four starts in detail
| Start | Files and results |
|---|---|
| A number, then a line end | 35 files. This is a plain SRT file. ffmpeg passed 31, pysrt 27, srt 29 and pysubs2 27. |
| EF BB BF | 9 files. This is UTF-8 with a byte order mark. ffmpeg passed 8, and pysrt, srt and pysubs2 passed all 9. |
| FF FE or FE FF | 4 files. This is UTF-16 or UTF-32. pysrt passed all 4, ffmpeg 2, and srt and pysubs2 none. |
| Anything else | 5 files. They are empty, very short or plain text without a cue list. pysrt passed 1, pysubs2 1, and ffmpeg and srt none. |
Start with the first bytes
Open the file in a hex viewer, or use xxd -l 16 example.srt on Linux or Mac. Our file starts with 31 0a, which is the number 1 and a line end. A BOM would put ef bb bf in front of the 1.
xxd -l 16 example.srt
00000000: 310a 3030 3a30 303a 3031 2c30 3030 202d 1.00:00:01,000 -
file -b example.srt
SubRip, Unicode text, UTF-8 text
file -b --mime-type example.srt
application/x-subrip
The file command reads the contents and not the ending. It printed SubRip for 35 of our 53 files. It called the rest ASCII text 8 times, Unicode text 6 times, ISO-8859 text 2 times, empty once and very short file once.
cat -A makes the line ends visible. A dollar sign marks every LF, and a CRLF file shows ^M$ instead. Our example uses LF, and 7 of our 53 files use CRLF.
ef bb bf means a BOM. ff fe or fe ff means UTF-16.
Not sure your SRT file is an SRT file at all? Check it with our script.
What Is Inside an SRT File? Four lines in a cue, repeated
An SRT file is a list of cues. Every cue has a number line, a time line, one or more text lines and a blank line. Our example file is 302 bytes long and has 5 cues.
We looked inside an SRT file because its layout explains every result later on this page. We wrote example with five cues, two lines in one of them, an italic tag, an accent and a dialog dash. The first lines show what a reader sees.
cat -A example.srt | head -9
1$
00:00:01,000 --> 00:00:03,500$
Hello, and welcome.$
$
2$
00:00:04,000 --> 00:00:06,200$
<i>This is the second cue.</i>$
It has two lines.$
$
Every dollar sign is a line end. The blank line after the first cue is only a $ on its own. A reader uses that blank line to find where the next cue begins.
The parts, one by one
The number line counts cues from 1. The time line holds the start and the end, with an arrow between them. The arrow is two dashes and a greater than sign. Wikipedia gives every time unit two digits, except milliseconds, which take three.
The text follows the time line. It can span several lines, and the blank line ends it. Tags like <i> appear in some files, and Wikipedia calls them unofficial.
What every part stores
| Part | What it stores |
|---|---|
| Number line | A single number on its own line. Ours counts from 1 to 5. All four readers read copies with a wrong or repeated number. |
| Time line |
Start, then -->, then end. Ours is 00:00:01,000 --> 00:00:03,500 for the first cue.
|
| Text lines | One or more lines. Cue 2 has two lines and an italic tag, and cue 3 has an accent. |
| Blank line | Ends the cue. Copy B1 has none, and pysrt joined two cues. |
| Encoding | Not stored. Ours is UTF-8 with no BOM, and the file command says so. |
| Line ends | LF in ours. CRLF and lone CR copies also read in all four readers. |
| Size | Ours is 302 bytes. A typical subtitle for a film has hundreds of cues, and our largest test file is 165,900 bytes. |
What the sources say
Wikipedia describes the layout as a sequential number, a time line with an arrow, the text and a blank line. It says milliseconds use a comma. We found no standards document for SRT, so the page names none.
We read the layout from our own files and from Wikipedia. We make no claim about how every player treats tags, positions or encodings.
The map is small. Our script checks the encoding, the number line, the time line and the text. It cannot know what the words should be, so a lost word can pass it, as the 21 copies show.
What Did We Find in 53 Test SRT Files? Four readers, and they did not agree
We read 53 public test files with four readers and a 32 line script. ffmpeg passed 41, pysrt 41, srt 38 and pysubs2 37. All four passed 35 files, and none passed 6.
All 53 files come from 14 public projects, so this is a study of those projects and not of subtitles in general. Many files exist to break readers, and a refusal on them is the right answer. A pass means exit code 0 and at least one cue, and a list with no cues counts as a fail.
Readers were ffmpeg 6.1.1, pysrt 1.1.2, srt 3.5.3 and pysubs2 1.9.1, all on Linux. We tested every file alone, in a fresh folder. The srt library reads the file as UTF-8 in our wrapper, so its UTF-16 results show that wrapper and not the library alone.
| Test | Result |
|---|---|
| ffmpeg 6.1.1 | Passed 41 files and refused 12. It never returned an empty list with exit code 0. It passed 8 of 9 BOM files and 2 of 4 UTF-16 or UTF-32 files. |
| pysrt 1.1.2 | Passed 41 files and gave exit code 0 with no cues on 7 more. It passed all 4 UTF-16 or UTF-32 files. |
| srt 3.5.3 | Passed 38 files and gave exit code 0 with no cues on 2 more. It passed none of the 4 UTF-16 or UTF-32 files in our wrapper, which forces UTF-8. |
| pysubs2 1.9.1 | Passed 37 files and gave exit code 0 with no cues on 7 more. It passed none of the 4 UTF-16 or UTF-32 files. |
| Our script | Printed OK for 11 files, WARN for 13 and FLAG for 29. 23 of the 29 flagged files passed in at least one reader. |
| The file command | Named 35 files SubRip and 18 files something else, including 1 empty file and 1 very short file. |
| Sizes | 0 to 165,900 bytes, with a median of 601 and a total of 1,431,740. 9 files are under 100 bytes and 6 are 100,000 bytes or more. |
| Starts and line ends | 9 files start with a BOM and 7 use CRLF. |
Four starts, four outcomes
35 files start with a number, 9 with a BOM, 4 with a UTF-16 or UTF-32 mark and 5 with something else. The four starts predict how readers do. ffmpeg passed 31 of the 35 numbered files, and pysrt, srt and pysubs2 passed 27, 29 and 27.
The BOM files were easy for three readers. pysrt, srt and pysubs2 passed all 9, and ffmpeg passed 8. UTF-16 and UTF-32 split the field, because pysrt passed all 4 and srt and pysubs2 passed none.
Where the four readers split
The four readers gave one answer on 41 of 53 files. They all passed 35 and all refused 6. They split on the other 12. ffmpeg alone passed 4 files, pysrt alone passed 2 and srt alone passed 2. pysubs2 passed none alone.
Exit code 0 with no cues is the quiet failure. pysrt and pysubs2 did it on 7 files apiece and srt on 2. ffmpeg did it on none. If you test a file in code, check the cue count and not only the exit code.
Passing does not mean the same cues
Of the 35 files that all four passed, the four readers found the same number of cues in 32. They differed on 3. We did not find out which reader is right, because the files have no answer sheet. So a pass shows that a reader found cues, and you should compare two readers when the count matters.
Our script on the 53 files
Our script printed OK for 11 files, WARN for 13 and FLAG for 29. 23 of the flagged files still passed in at least one reader. So a flag is a reason to look closer and not a verdict.
Read the study with care. It shows what four open readers do with 53 files from 14 projects. A video player, an editor or a website can be stricter or more lenient than any of them, and we had none of those. Files from other sources can differ from ours.
What Happens When an SRT File Is Damaged? 21 broken copies, and the four readers agreed on 14
We damaged one SRT file in 21 ways. The four readers agreed on 14 copies and split on 7. Our script flagged or warned on 18. Our own script restored 6 of the 11 copies that needed a repair, and all four readers returned a changed list on 3 copies.
The 21 copies come in three groups of 7. Group A changes the bytes around the text, like the encoding and the line ends. Group B changes the layout, like numbers, blank lines and the arrow. Group C changes the content, like times and text. Every copy changes one thing in example.
We asked three questions about every copy. Did a reader return the same cues as on the original? Did our script flag it? Did one script bring back the original for all four readers?
Copies that split the readers
A4 saves the file as UTF-16 with a BOM. ffmpeg and pysrt read it and returned the original cues. srt and pysubs2 refused it. A5 saves the file as Latin-1. pysrt, srt and pysubs2 refused it, and ffmpeg exited with 0 and dropped the Café cue.
B1 removes one blank line. pysrt and pysubs2 returned a changed list, and ffmpeg and srt did not. B5 writes the arrow with one dash. ffmpeg and pysrt returned 4 cues instead of 5, srt refused the file, and pysubs2 read it as the original.
B6 removes the first number. ffmpeg refused it, and the other three read it the same. C6 sets an hour to 100. ffmpeg, pysrt and srt returned a changed list, and pysubs2 did not. C7 puts a blank line inside a cue, and only pysrt returned a changed list.
Copies every reader accepted
Ten copies read the same in all four readers. Group A gave four of them. A1 has a BOM, A2 uses CRLF, A3 uses lone CR and A6 has no final line end. Group B gave four more. B2 has a wrong number, B3 repeats one, B4 uses dots for commas and B7 adds blank lines. Group C gave two. C3 has short digits and C5 leaves an italic tag open.
So the numbers, the comma and the line ends are not checked hard by these readers. Players that rely on them may act differently, and we did not test one.
The copy every reader refused
A7 saves the text as UTF-16 with no BOM. All four readers refused it. The readers cannot guess that encoding, and they should not guess.
The 3 copies that changed the content
C1 puts an end time before the start, C2 makes two cues overlap and C4 removes the word Home. All four readers returned a changed list for all three, because the file itself changed. No reader can know that a word is missing.
That is why a pass proves little. Our script flagged C1 and C2, but it printed OK for C4. A script cannot know what the words should be, so a lost word needs a second copy of the file or a quick look.
Repairs that worked
Our script of 28 lines restored 15 copies byte for byte. They are A1 to A7, B1 to B7 and C3. Of those, 6 needed a repair to help a reader. They are A4, A5, A7, B1, B5 and B6.
It converts UTF-16 to UTF-8 and removes the BOM. It writes LF line ends, numbers the cues from 1, fixes the arrow and the comma and adds the final line end. For a file that is not UTF-8, it guesses Windows-1252. That guess fits our Café, and it can be wrong for your file.
We found no official repair command. ffmpeg, pysrt, srt and pysubs2 only read and convert. We did not test the repair features of any editor or player.
What no command repaired
C1, C2, C4, C6 and C7 change times or text. No rule shows what the original values were, so ask for the file again. Our script restored none of these 5 copies, which leaves 5 of the 11 that needed a repair.
Read the grid with care. Every copy changes one thing in one small file. Damage in the wild changes many things at once. We opened no copy in a player, and our repairs rely on rules that fit the file we made.
What Does Our Expert Say About SRT Files? A note from Neeraj Singh on trying a second reader
Check an SRT file with two readers before you trust it. Our four readers disagreed on 7 of 21 damaged copies. ffmpeg dropped a cue from a Latin-1 copy and still gave an exit code of 0.
Expert insight
“An SRT file can pass a quick test and still lose a cue. Our four readers agreed on only 14 of 21 damaged copies, and ffmpeg dropped a line from a Latin-1 copy with exit code 0. Save subtitles as UTF-8, count the cues in a second reader and ask for a new file when words or times are missing.”
Why one reader is not enough
A reader can return fewer cues without an error. ffmpeg did that for A5, and pysrt did it for B1 and B5. A refusal at least warns you that something is wrong. A silent result does not.
If your SRT file loads in the player you trust and the words match the audio, treat that as the best test. Use the readers on this page when it does not. pysrt and ffmpeg passed the most files, so they make a good pair.
Copy your SRT file before you repair it. Work on the copy and keep the original untouched. Write down its SHA-256 hash first, so you can show later that the copy came back as it was.
How Do You Open an SRT File? A text editor, four readers, and what we tested
A text editor opens an SRT file, because the file is plain text. We also tested four readers on Linux. ffmpeg and pysrt passed the most files, 41 of 53 apiece, and srt passed 38.
The table lists the ways to open an SRT file. Rows with version numbers are tools we tested on Linux. We tested no player and no editor, and we opened nothing on Windows or macOS.
| Program | What it does |
|---|---|
| Any text editor | An SRT file is plain text, so an editor shows the numbers, the times and the words. Choose UTF-8 when it asks for an encoding. |
| ffmpeg 6.1.1 | A command line tool. It passed 41 of our 53 files and never returned an empty list with exit code 0. |
| pysrt 1.1.2 | A Python library. It passed 41 files and 4 of 4 UTF-16 or UTF-32 files. It gave no cues with exit code 0 on 7 more. |
| srt 3.5.3 | A Python library. It passed 38 files and refused the most damaged copies, 4 of 21. |
| pysubs2 1.9.1 | A Python library that also saves other subtitle formats. It passed 37 files and gave no cues with exit code 0 on 7 more. |
| The file command | It named 35 of our 53 files SubRip and gave application/x-subrip for our example. |
| Video players and editors | We tested none, so we make no claim about how they treat tags, positions or encodings. |
Open an SRT file as text
If you want to see the words and the times, a text editor is enough. Our example shows a number, a time line, the words and a blank line for every cue. Edit it, save it as UTF-8 and keep the .srt ending.
Broken letters mean the editor guessed the wrong encoding. Three of four readers refused our Latin-1 copy because of the letter é, and ffmpeg dropped that cue. Reopen the file and choose the other encoding, or use our script to see what is wrong.
Open an SRT file with Python or ffmpeg
Four lines of Python load the file and count the cues. The ffprobe command names the format and the codec. These are the actual outputs for example.
import pysrt
s = pysrt.open('example.srt')
print(len(s))
print(s[1].text)
5
<i>This is the second cue.</i>
It has two lines.
ffprobe -v error -show_entries stream=codec_name,codec_type -of csv=p=0 example.srt
subrip,subtitle
ffprobe -v error -show_entries format=format_name -of csv=p=0 example.srt
srt
The count of 5 matches the five cues in the file. The tag stays in the text, so a reader gives you the characters and a player decides how to show them.
Open an SRT file that one reader refuses
Try a second reader. The four readers split on 12 of our 53 files. ffmpeg alone passed 4 files, and pysrt and srt alone passed 2 apiece. The same file can load in one reader and fail in another.
What to use for every task
Read the words. Use a text editor. Count the cues. Use pysrt and check that the count is not 0. Test a file that one reader refuses. Use ffmpeg and pysrt together, because they passed the most files. ffmpeg alone passed 4 files and pysrt alone passed 2.
Install programs from their makers. Take ffmpeg from its own site and libraries from their own pages. A free web tool receives your subtitles, so try the steps on this page first.
How Do You Check an SRT File? Six steps and a script of 32 lines
Check an SRT file in six steps. Look at the first bytes, name the kind, use a script and compare two readers. Our 32 line script printed OK for 11 of 53 files and flagged or warned on 18 of 21 damaged copies.
The first looks at an SRT file need no Python. The file command names the layout, cat -A shows the line ends and xxd shows the first bytes. We used all three on example.
file -b example.srt
SubRip, Unicode text, UTF-8 text
file -b --mime-type example.srt
application/x-subrip
A healthy file starts with a number and has a comma in every time. Wikipedia gives the same layout, so a file that breaks these points is damaged, or it is a test file made to break readers.
Check SRT files with Python
The script decodes the file and follows it block by block. It checks the number, the time line and the text of every cue. It warns about a BOM, CRLF line ends and a missing final line end.
It prints OK, WARN or FLAG, and it never changes a file.
import sys, re
T = re.compile(r'^(\d{1,3}):(\d\d):(\d\d)([,.])(\d{3}) --> (\d{1,3}):(\d\d):(\d\d)([,.])(\d{3})\s*$')
def ms(h, m, s, f): return ((int(h) * 60 + int(m)) * 60 + int(s)) * 1000 + int(f)
def peek(b):
notes = []
if b[:3] == b'\xef\xbb\xbf': notes.append('BOM'); b = b[3:]
if b[:2] in (b'\xff\xfe', b'\xfe\xff') or b'\x00' in b[:40]: return 'FLAG UTF-16 or UTF-32 text, readers may refuse it'
try: t = b.decode('utf-8')
except UnicodeDecodeError as e: return 'FLAG not valid UTF-8, bad byte at %d' % e.start
if '\r\n' in t: notes.append('CRLF line ends'); t = t.replace('\r\n', '\n')
if '\r' in t: return 'FLAG lone CR line ends'
blocks = [x for x in re.split(r'\n{2,}', t.strip('\n')) if x.strip()]
if not blocks: return 'FLAG no cues'
prev_end, n, idx = -1, 0, 0
for i, blk in enumerate(blocks, 1):
l = blk.split('\n')
if not re.fullmatch(r'\d+', l[0].strip()): return 'FLAG block %d has no number line' % i
if len(l) < 2: return 'FLAG block %d has no time line' % i
m = T.match(l[1])
if not m: return 'FLAG block %d time line is not hh:mm:ss,mmm --> hh:mm:ss,mmm' % i
g = m.groups(); a, z = ms(*g[0:3], g[4]), ms(*g[5:8], g[9])
if g[3] == '.' or g[8] == '.': return 'FLAG block %d uses a dot, not a comma' % i
if int(g[0]) > 99 or int(g[5]) > 99: return 'FLAG block %d has hours above 99' % i
if z <= a: return 'FLAG block %d ends before it starts' % i
if a < prev_end: return 'FLAG block %d starts before block %d ends' % (i, i - 1)
if len(l) < 3 or not ''.join(l[2:]).strip(): return 'FLAG block %d has no text' % i
if int(l[0]) != i: return 'FLAG block %d is numbered %s' % (i, l[0].strip())
prev_end = z
if not t.endswith('\n'): notes.append('no final line end')
return ('WARN ' + ', '.join(notes) + ', OK ' if notes else 'OK ') + '%d cues' % len(blocks)
for p in sys.argv[1:]:
print(p.split('/')[-1], peek(open(p, 'rb').read()))
Here is what it printed for our example and for four damaged copies.
python3 srt_peek.py example.srt
example.srt OK 5 cues
python3 srt_peek.py A1.srt A5.srt B1.srt C4.srt
A1.srt WARN BOM, OK 5 cues
A5.srt FLAG not valid UTF-8, bad byte at 170
B1.srt FLAG block 3 is numbered 4
C4.srt OK 5 cues
A healthy answer gives the cue count. A1 has a BOM and gets a warning. A5 holds a byte that is not UTF-8 and gets a flag. B1 lost a blank line, and the script says block 3 is numbered 4. C4 prints OK, and it still lost a word.
What the script found in our files
| Result | Cases |
|---|---|
| Printed OK (11 of 53 files) | The encoding, every number, every time line and every text block fit. 3 of 21 damaged copies also print OK. |
| Printed FLAG (29 of 53 files) | 23 of these files passed in at least one reader, so a flag is a reason to look closer. |
| Encoding (A3, A4, A5, A7) | The script names UTF-16 or UTF-32 text, a byte that is not valid UTF-8 or a lone CR line end. |
| Numbers (B1, B2, B3, B6) | The script names the block with the wrong number, like block 3 numbered 4, or the block with no number line. |
| Time lines (B4, B5, C1, C2, C3, C6) | The script names a dot instead of a comma, a bad arrow, an end before a start, an overlap, short digits or hours above 99. |
| Text (C7) | The script names the block that has no text. |
| Warned (A1, A2, A6) | A BOM, CRLF line ends or no final line end. All four readers read all three the same as the original. |
| Printed OK but changed (B7, C4, C5) | B7 and C5 read the same in all four readers. C4 lost the word Home and every reader returned a changed list. |
The script has limits. It cannot know what the words should be, and it cannot see that C4 lost one. It flagged 23 files that at least one reader passed, so flags are reasons to look closer and not verdicts. The repair routes fix the kinds of damage we tested.
Check order for any SRT file
- Copy your SRT file, write its SHA-256 hash and work on the copy.
-
Look at the first bytes with
xxd -l 16. A number is a plain file,ef bb bfis a BOM andff feorfe ffis UTF-16. See the start table. -
Name the kind with
file -band look at the line ends withcat -A. - Use our script. The first word is OK, WARN or FLAG, and a flag names the problem.
- Count the cues in two readers and compare the numbers. The open steps show how.
- Play the subtitles against the video. We opened nothing in a player, so passes show a sound layout for four readers only.
Is an SRT File Safe to Open? Looking is safe, and repairs need care
An SRT file is text, so looking at one starts nothing. The risks come after. A wrong encoding can garble the words, a repair can lose cues and a free tool keeps your file. We scanned none of our files for malware.
Our readers loaded files and printed cues in empty folders, and the test files are public. We started no file as a program, we scanned none for malware and we opened none in a player.
The Wikipedia page on SubRip describes it as plain text with tags that are unofficial. It gives the media type application/x-subrip and says IANA has not approved it. So we make no claim about how any player treats tags or links, and you should treat a subtitle file from a stranger like any other file from a stranger.
xxd, file and our script read bytes and start nothing inside the file.
Look at the file before you load it
Open the file in a text editor and scroll through it. A proper SRT file shows numbers, times and words. If you see something else, check it with file -b and do not open it in a player until you know what it is.
Our biggest test file is 165,900 bytes, which is small. We did not test huge files, so we give no size limit.
An SRT file from someone else
Read the first bytes and use the script. Count the cues in two readers, and watch the subtitles against the video. Work on a copy.
Share an SRT file with a helper
Send the SRT file and the output of our script. The first word of the output shows a helper whether the layout is sound. Keep the original, and send a copy.
Not sure? Check it first. Copy the hash, look at the first bytes with our check steps and ask the sender for a fresh file if anything looks wrong. Open it last, on a copy.
Why Will Your SRT File Not Load? Eight causes, and what to do about every one
Most SRT files that will not load fail for one of eight reasons. Look at the first bytes, use the script and try a second reader. Our script flagged or warned on 18 of 21 damaged copies, and our own script restored 6 of the 11 that needed a repair.
We damaged one SRT file in 21 ways and tested a repair script on the copies that needed one. The table groups what we saw into eight causes.
Every row says what happens to your SRT file and what to try next. Fixes work on copies, and none changes the original. We opened no repaired file in a player, so a repaired file shows only that four Linux readers can read it.
| Cause | Result and fix |
|---|---|
| UTF-16 or UTF-32 text (1) | A4 is UTF-16 with a BOM. ffmpeg and pysrt read it, and srt and pysubs2 refused it. A7 is UTF-16 with no BOM, and all four readers refused it. Fix: Convert the text to UTF-8 with our script. Both came back byte for byte. |
| Bytes that are not UTF-8 (2) | A5 saves the file as Latin-1. pysrt, srt and pysubs2 refused it, and ffmpeg exited with 0 and dropped the Café cue. Fix: Our script decodes the bytes as Windows-1252 and writes UTF-8. It came back byte for byte, and the guess can be wrong for your file. |
| Line ends and BOM (3) | A1 adds a BOM, A2 uses CRLF, A3 uses a lone CR and A6 drops the final line end. All four readers returned the original cues for all four. Fix: None needed for these readers, and our script writes LF with no BOM. |
| A missing blank line (4) | B1 removes the blank line between two cues. pysrt and pysubs2 returned a changed list, and ffmpeg and srt did not. C7 puts a blank line inside a cue, and pysrt emptied that cue. Fix: Our script rebuilt B1. It did not restore C7. |
| Wrong or missing numbers (5) | B2 sets a number to 7 and B3 repeats one. All four readers returned the original cues for both. B6 loses the first number, and ffmpeg refused it. Fix: Our script numbers the cues from 1 again, and it restored all three. |
| A bad arrow or time format (6) | B4 uses dots for commas and C3 uses short digits, and all four readers read both as the original. B5 writes the arrow with one dash. ffmpeg and pysrt lost a cue, srt refused it and pysubs2 read it. Fix: Our script writes a tidy time line, and it restored all three. |
| Times that are wrong (7) | C1 puts an end before its start and C2 makes two cues overlap. All four readers returned a changed list for both. C6 sets an hour to 100, and three readers returned a changed list. Fix: None of ours worked. Ask for the file again. |
| Lost words or an open tag (8) | C4 removes the word Home, and all four readers returned a changed list. C5 leaves an italic tag open, and all four read it as the original. Fix: None for C4. Ask for the file again. |
When the file is not damaged
Three things look like a damaged SRT file and are not. A reader may return no cues and still exit with 0. A file that ends in .srt can hold something else. The times can be right for the file and wrong for your video.
Shift the times of an SRT file
If every line comes late by the same amount, change every time by that amount. Four lines of pysrt moved example earlier by half a second. The first cue now starts at 0.5 seconds and not at 1.
import pysrt
s = pysrt.open('example.srt')
s.shift(milliseconds=-500)
s.save('early.srt', encoding='utf-8')
1
00:00:00,500 --> 00:00:03,000
Hello, and welcome.
A shift that pushes a time below zero clamps it to zero. pysubs2 printed an underflow warning when we moved the first cue 2 seconds earlier, and the cue then started at 00:00:00,000. If the delay grows through the video, a single shift cannot fix it, and we did not test that case.
Repairs we tested
A script of 28 lines covers the fixes that need our own code. It takes the damaged SRT file and a name for the new file. It removes the BOM and decodes the text. It writes LF line ends, finds every time line, numbers the cues from 1 and saves the file as UTF-8.
import sys, re
def fix(b):
if b[:3] == b'\xef\xbb\xbf': b = b[3:]
if b[:2] in (b'\xff\xfe', b'\xfe\xff'): t = b.decode('utf-16')
elif b'\x00' in b[:40]: t = b.decode('utf-16-le')
else:
try: t = b.decode('utf-8')
except UnicodeDecodeError: t = b.decode('cp1252')
t = t.replace('\r\n', '\n').replace('\r', '\n')
T = re.compile(r'^(\d{1,3}):(\d{1,2}):(\d{1,2})[,.](\d{3})\s*-{1,2}>\s*(\d{1,3}):(\d{1,2}):(\d{1,2})[,.](\d{3})\s*$')
out, cue = [], None
for line in t.split('\n'):
m = T.match(line.strip())
if m:
g = m.groups()
cue = ['%02d:%02d:%02d,%s --> %02d:%02d:%02d,%s' % (int(g[0]), int(g[1]), int(g[2]), g[3], int(g[4]), int(g[5]), int(g[6]), g[7]), []]
out.append(cue)
elif cue is not None:
cue[1].append(line)
res = []
for i, (tm, tx) in enumerate(out, 1):
while tx and not tx[-1].strip(): tx.pop()
if tx and re.fullmatch(r'\d+', tx[-1].strip()) and i < len(out): tx.pop()
while tx and not tx[-1].strip(): tx.pop()
res.append('%d\n%s\n%s\n' % (i, tm, '\n'.join(tx)))
return '\n'.join(res).encode('utf-8')
if __name__ == '__main__':
open(sys.argv[2], 'wb').write(fix(open(sys.argv[1], 'rb').read()))
# 1 BOM (A1), UTF-16 (A4), Latin-1 (A5), blank line (B1), first number (B6)
python3 srt_fix.py A1.srt A1_fixed.srt
python3 srt_fix.py A4.srt A4_fixed.srt
python3 srt_fix.py A5.srt A5_fixed.srt
python3 srt_fix.py B1.srt B1_fixed.srt
python3 srt_fix.py B6.srt B6_fixed.srt
# compare with the original
sha256sum example.srt A1_fixed.srt A4_fixed.srt A5_fixed.srt B1_fixed.srt B6_fixed.srt | cut -c1-12
13b486390f74
13b486390f74
13b486390f74
13b486390f74
13b486390f74
13b486390f74
The last lines compare hashes. The first 12 characters match for the original and the five repaired files, so every repaired file equals the original byte for byte. A2, A3, A6, A7 and the others in the list of 15 came back the same way.
Fix SRT files that will not load, step by step
We tested the steps on Linux with ffmpeg 6.1.1, pysrt 1.1.2, srt 3.5.3 and pysubs2 1.9.1. We opened no file in a player, and the steps keep the original untouched at every point.
- Copy your SRT file, write its SHA-256 hash and work on the copy.
-
Name the start with
xxd -l 16and the four kinds of start. A plain file starts with a number. - Use the check script on this page. A flag or warning names the problem.
- Try a second reader. ffmpeg and pysrt passed the most of our files, so use both.
- Match the answer to a cause in the table above and try its fix on the copy.
- If one fix fails, do not stack another on top. Go back to the copy and try the next cause.
- Count the cues in two readers, then watch the subtitles against the video.
What to send a helper
Short messages get faster answers. Include the details below and add the script output. Its first word gives OK, WARN or FLAG.
Subject: My SRT file will not load
File: name, size in bytes and SHA-256 hash
Start: the output of xxd -l 16
Check: the output of srt_peek.py
Program: name, version and the exact words of the error
Source: where the file came from, and how it was sent
What no step can fix
Do not try online repair sites. Sites that offer to fix any subtitle file receive your upload. Try the steps above on a copy first.
How Do You Convert an SRT File to VTT or Put It in a Video? Three tested commands, and what changed
ffmpeg converted example.srt to WebVTT in one command, and one more command put the SRT file inside an MP4 or MKV video. We tested all three on Linux. Cues and times came back the same after a round trip, and the bytes did not.
People convert an SRT file to use it somewhere that wants another format. The commands below do it from a terminal, and every output below is actual. We tested no web converter and no editor.
Convert SRT to VTT
ffmpeg wrote a 270 byte file that starts with WEBVTT. It dropped the cue numbers and wrote short times like 00:01.000. pysubs2 wrote 311 bytes, kept the numbers and wrote full times like 00:00:01.000.
ffmpeg -i example.srt example.vtt
WEBVTT
00:01.000 --> 00:03.500
Hello, and welcome.
python3 -c "import pysubs2; pysubs2.load('example.srt').save('example.vtt')"
WEBVTT
1
00:00:01.000 --> 00:00:03.500
Hello, and welcome.
The same two tools wrote an ASS file of 993 bytes (ffmpeg) and 1,003 bytes (pysubs2). ffmpeg wrote the italic tag as {\i1} and {\i0} and the line break as \N.
Convert back to SRT
We converted the VTT file back with ffmpeg -i example.vtt back.srt. pysrt found 5 cues, the same text and the same times. The bytes were not the same, and the file command named mixed line ends, CRLF and LF. So a round trip kept the cues and not the file.
Put an SRT file inside a video
Embedding keeps the subtitles as a track in the video. For MP4 the track becomes mov_text, and for MKV it stays subrip. Both commands copy the video without encoding it again.
ffmpeg -i v.mp4 -i example.srt -map 0 -map 1 -c copy -c:s mov_text vs.mp4
ffmpeg -i v.mp4 -i example.srt -map 0 -map 1 -c copy vs.mkv
ffprobe -select_streams s -show_entries stream=codec_name vs.mp4 → mov_text
ffprobe -select_streams s -show_entries stream=codec_name vs.mkv → subrip
Our test video is a black 320 by 180 clip of 15 seconds and 10,497 bytes. The MP4 grew to 11,351 bytes and the MKV came to 10,041. The sizes show one small case and not a rule.
Burn subtitles into the picture
A burned in subtitle is part of the picture, and nobody can switch it off. ffmpeg -i v.mp4 -vf "subtitles=example.srt" burn.mp4 worked and gave 18,091 bytes, because the video had to be encoded again. Keep the SRT file for later edits.
Before you convert
We pulled the subtitles back out of the MKV and the times had moved by 128 milliseconds. We did not find the cause, so we do not claim that embedding keeps every time exactly. Check the result against the original.
ffprobe and our script print the format and the cues and write nothing.
Keep the SRT file. A converted copy can lose tags, numbers or exact times. Keep the original for later edits.
How Does an SRT File Differ From VTT and ASS Files? Plain cues against styles
SRT, VTT and ASS all store timed text. SRT is the simplest of the three. For our five cues the SRT file was 302 bytes. The ffmpeg VTT file was 270 and the pysubs2 VTT file 311. The ffmpeg ASS file was 993 and the pysubs2 ASS file 1,003.
The table lists the neighbors of an SRT file and what we measured. We made the VTT and ASS files from example.srt with ffmpeg and pysubs2. Sizes depend on the tool and the settings, so they show one case and not a rule.
| Type | What separates it |
|---|---|
| SRT | Numbered cues with a comma before the milliseconds. Our example was 302 bytes. Wikipedia says SubRip dates from 1999. |
| VTT | Starts with the word WEBVTT and uses a dot before the milliseconds. ffmpeg dropped the cue numbers and wrote 270 bytes. Wikipedia says WebSRT was renamed WebVTT. |
| ASS |
Starts with section headers and has Dialogue lines with styles. ffmpeg wrote 993 bytes and used tags like {\i1}.
|
SRT or VTT
VTT looks much like SRT. The differences we saw are the first line, the dot in the times and the numbers, which ffmpeg dropped and pysubs2 kept. A converter handles those for you.
SRT or ASS
ASS stores styles, and SRT stores text with a few tags. Converting SRT to ASS keeps the words and times and adds style lines. We did not test ASS to SRT.
Which one do you have
What Is the SRT File Format Made Of? The facts we could check, and where they came from
An SRT file stores numbered cues, and every cue has a time line and text. Facts below come from our own checks of 53 files and 21 damaged copies. Sources are Wikipedia and the four test tools.
| Part | What we could check |
|---|---|
| Maker | A user named Brain made SubRip in 1999, per Wikipedia. |
| Name | SubRip text, with the ending .srt. Wikipedia gives application/x-subrip and says IANA has not approved it. The file command printed the same type for our example. |
| First bytes | The file has no signature. A plain file starts with the number 1. 35 of our 53 files start with a number, 9 with a BOM and 4 with a UTF-16 or UTF-32 mark. |
| Layout | A number line, a time line, one or more text lines and a blank line, repeated for every cue, per Wikipedia. |
| Time line | hh:mm:ss,mmm --> hh:mm:ss,mmm, with a comma before the milliseconds, per Wikipedia. |
| Encoding | Not stored in the file. Wikipedia says no official standard exists, ffmpeg assumes UTF-8 and some programs write Windows-1252. |
| Sizes | Our files are 0 to 165,900 bytes long, with a median of 601. Our example is 302 bytes. |
| Tags | b, i, u and font tags and screen positions exist, and Wikipedia calls them unofficial. Our example uses one italic tag. |
| Checksum | We found no checksum in the layout. Readers rely on the text, so a changed word can pass, as C4 did. |
| Our tests | 53 files, 21 damaged copies, 4 readers, 1 repair route and a script of 32 lines. ffmpeg 6.1.1, pysrt 1.1.2, srt 3.5.3 and pysubs2 1.9.1 on Linux. |
About the values we list
Facts about the layout come from our own reading of one example file and 53 test files, and from the page we name. We found no standards document for SRT, so we claim no field that our files do not show.
Where we found no record, we say so. We could not complete an IANA check, so we make no IANA claim. We found no checksum, and we tested no player.
What we left out
We opened no file in a video player or an editor. We used no web converter and scanned no file for malware. Our readers and scripts worked on Linux, and Windows and macOS programs can accept or refuse files that they treat differently.
All 53 files come from 14 public projects, and many are built to break readers. Our damaged copies come from one small file and change one thing at a time. Files from other sources can differ from ours. We did not find out why times moved by 128 milliseconds after we extracted them from an MKV file.
Sources checked
For the format, see the Wikipedia article on SubRip.
For the tools, see the pysrt project, the srt library, pysubs2 and ffmpeg. Every count on this page came from files and scripts in our research folder.
Frequently Asked Questions About SRT Files
What is an SRT file?
An SRT file is a plain text subtitle file. It stores captions as numbered cues, and every cue has a start time, an end time and one or more lines of text. A user named Brain made SubRip in 1999, per Wikipedia.
How do I open an SRT file?
Open it in any text editor, because the file is plain text. Choose UTF-8 if the editor asks. We also tested ffmpeg, pysrt, srt and pysubs2, and ffmpeg and pysrt passed 41 of our 53 files apiece.
How do I use an SRT file with a video?
Keep the SRT file next to the video or embed it. We embedded one in an MP4 as mov_text and in an MKV as subrip with ffmpeg. We tested no player, so check how yours loads subtitles.
What is the difference between SRT and VTT?
A VTT file starts with the word WEBVTT and uses a dot before the milliseconds. An SRT file uses a comma and numbers every cue. ffmpeg dropped the numbers when it converted our example, and pysubs2 kept them.
Is an SRT file safe to open?
Looking at an SRT file starts nothing, because it is text. A wrong encoding can garble the words, and a free tool keeps the file you upload. We scanned none of our files for malware.
How do I convert an SRT file to VTT?
Use ffmpeg with the command ffmpeg -i example.srt example.vtt, or use pysubs2. ffmpeg wrote 270 bytes and pysubs2 wrote 311. Converting back gave the same 5 cues and times, and different bytes.
Why will my SRT file not load?
Eight causes cover what we saw in damaged files. They are UTF-16 text, bytes that are not UTF-8, line ends and a BOM, a missing blank line, wrong numbers, a bad time format, wrong times and lost words. An empty cue list can also be the cause.
How can I check if an SRT file is damaged?
Look at the first bytes, use our script and compare two readers. The script flagged or warned on 18 of 21 damaged copies, and it printed OK for C4 while a word was missing. Count the cues in two readers too.
Can a damaged SRT file be repaired?
Some damage can be repaired. Our script restored 15 copies byte for byte, and 6 of them needed it. Changed times and lost words did not come back. Keep the original and work on a copy.
Do all readers agree on a damaged SRT file?
No. ffmpeg, pysrt, srt and pysubs2 agreed on 14 of our 21 damaged copies and split on 7. All four returned a changed list on 3 copies, because the file itself changed. Compare two readers.
How do I fix subtitles that come late?
Shift every time by the same amount. pysrt moved our example half a second earlier with shift(milliseconds=-500). A time cannot go below zero, and a delay that grows through the video needs another fix.
What MIME type is an SRT file?
Wikipedia gives application/x-subrip and says IANA has not approved it. The file command printed the same type for our example. We could not complete an IANA check, so we make no claim about the registry.
Still Stuck With an SRT File? Where to go next, depending on what went wrong
Look at the first bytes and use the check script. The cause table lists what to try in order.
The first bytes table names the kind, and the neighbors name the formats that look alike.
Is it a video file? The guide to MP4 files covers the video format that can hold subtitles.
Is it a document? The guide to PDF files covers the document format.
Is it a zipped folder? The guide to ZIP files covers the archive format that opens everywhere.
Is it a file type you do not know? Browse the file extension resource library, or send it on the submit a file type page.
Do you need the format facts? Read the format part for the layout, the encodings and the sources of SRT files.