SubRip: Difference between revisions
No edit summary |
|||
Line 39: | Line 39: | ||
[[Unicode]] and basic [[HTML]] tags such as <code><nowiki><i></nowiki></code>, <code><nowiki><b></nowiki></code>, <code><nowiki><u></nowiki></code> and <code><nowiki><font></nowiki></code> in subtitles are supported by most players, but [[VLC media player|VLC]] (the nightly builds are starting handling them) and some subtitle editors (SubResync, Subtitle Workshop) do not handle these tags well. |
[[Unicode]] and basic [[HTML]] tags such as <code><nowiki><i></nowiki></code>, <code><nowiki><b></nowiki></code>, <code><nowiki><u></nowiki></code> and <code><nowiki><font></nowiki></code> in subtitles are supported by most players, but [[VLC media player|VLC]] (the nightly builds are starting handling them) and some subtitle editors (SubResync, Subtitle Workshop) do not handle these tags well. |
||
Note that SubRip is hard to port to [[Linux]] because of the language it's written in ([[Delphi programming language|Delphi]]). That being said, SubRip works |
Note that SubRip is hard to port to [[Linux]] because of the language it's written in ([[Delphi programming language|Delphi]]). That being said, SubRip works well on Linux with newer versions of [[Wine (software)|Wine]].[http://appdb.winehq.org/objectManager.php?sClass=application&iId=2621] |
||
Whoever is looking to implement most of the official and unofficial tags that may exist in a SRT file, should inspect the [http://ale5000.altervista.org/subtitles.htm#test SubRip subtitles capability tester by ale5000] |
Whoever is looking to implement most of the official and unofficial tags that may exist in a SRT file, should inspect the [http://ale5000.altervista.org/subtitles.htm#test SubRip subtitles capability tester by ale5000] |
Revision as of 00:40, 31 December 2008
This article needs additional citations for verification. (November 2008) |
Filename extension |
.srt |
---|
SubRip is an optical character recognition program for Windows which rips (extracts) subtitles and their timings from video files or DVDs, recording them as a text file. Subrip is also the name of the subtitle format created by this software. The caption files are named with the extension .SRT. This format is supported by most software video players and subtitle creation programs, detailed in the article Comparison of media players.
In practice, SubRip is first configured to correctly detect subtitles in a video file. The correct video codecs (DGMPGDec for DVDs) must be installed, along with AviSynth. SubRip is configured while displaying a frame with subtitles, including their color, shape of the subtitle area, and any required image manipulation (fattening, contrast adjustments). After trial and fine tuning, extraction is then performed automatically for the entire file during playback.
The time format used is hours:minutes:seconds,milliseconds, with the milliseconds field precise to three decimal places. The decimal separator used is the comma, since the program was written in France, and the line break used is the CR+LF pair. Subtitles are indexed numerically, starting at 1.
Fields
- Subtitle number
Start time --> End time X1:Position left X2:Position right Y1:Position up Y2:Position down
Text of subtitle (one or more lines)
Blank line
Display coordinates are optional[1] and they aren't handled correctly by most current players[2]
Unicode and basic HTML tags such as <i>
, <b>
, <u>
and <font>
in subtitles are supported by most players, but VLC (the nightly builds are starting handling them) and some subtitle editors (SubResync, Subtitle Workshop) do not handle these tags well.
Note that SubRip is hard to port to Linux because of the language it's written in (Delphi). That being said, SubRip works well on Linux with newer versions of Wine.[1]
Whoever is looking to implement most of the official and unofficial tags that may exist in a SRT file, should inspect the SubRip subtitles capability tester by ale5000
Sample file
This article contains instructions, advice, or how-to content. |
It represents a time span in 'hours:minutes:seconds,milliseconds' to show the subtitle text.
1 00:00:20,000 --> 00:00:24,400 In connection with a dramatic increase in crime in certain neighbourhoods, 2 00:00:24,600 --> 00:00:27,800 The government is implementing a new policy...
MPlayer tolerates missing index lines as in the example below:
00:00:00,000 --> 00:00:00,999 I know this.. 00:00:01,000 --> 00:00:01,999 It's a unix system!
With optional display coordinates
1 00:00:20,000 --> 00:00:24,400 X1:100 X2:600 Y1:050 Y2:100 In connection with a dramatic increase in crime in certain neighbourhoods, 2 00:00:24,600 --> 00:00:27,800 The government is implementing a new policy...
Conversion
Here is an exemplary python-script "srt2sub.py" which converts subtitles from the SubRip .srt format into the MicroDVD .sub format.
import sys,string,re
framerate = 23.956
if(len(sys.argv)<2):
print 'usage: %s input'%(sys.argv[0])
sys.exit(0)
name = sys.argv[1]
if name[-4:] == '.srt':
name = name[:-4]
infile = '%s.srt'%(name)
outfile = '%s.sub'%(name)
fin = open(infile,'r')
fout = open(outfile,'w')
subtitle_count = 1
read_mode = 0
read_buffer = []
html_re = re.compile(r'<.*?>')
for line in fin:
line = line.strip()
if (read_mode == 0) and (string.find(line,str(subtitle_count)) >=0 ):
read_mode = 1
continue
if (read_mode == 1):
starttime = 60*60*int(line[:2]) + 60*int(line[3:5]) + int(line[6:8]) + int(line[9:12])/1000.0
stoptime = 60*60*int(line[17:2+17]) + 60*int(line[3+17:5+17]) + int(line[6+17:8+17]) + int(line[9+17:12+17])/1000.0
read_mode = 2
continue
if (read_mode == 2):
if (line == ''):
read_mode = 0
write_str = '{%d}{%d}%s%s'%(starttime*framerate,stoptime*framerate,'|'.join(read_buffer),'\n')
write_str = html_re.sub('',write_str)
fout.write(write_str)
read_buffer = []
subtitle_count += 1
continue
read_buffer += [line]
fin.close()
fout.close()