SrtSynch |
Homepage Forum topic |
Changes the framerate of srt subtitles, or sets a delay (positive or negative) on them. Further info in Remarks.
SrtSynch(DelayOrFramerate, InputSubtitleFile, OutputSubtitleFile, TimeOfDelay, IsDelayPositive, InputFps, OutputFps)
| DelayOrFramerate | It's 0 if you want to set a delay, 1 if you want to change the framerate. |
| InputSubtitleFile | Path to the subtitle file you want
to convert or change enclosed in quotation marks. If the subtitle file
is in the same folder as the script, you can give only the filename
instead of the full path. |
| OutputSubtitleFile | Path of the converted subtitle file enclosed in
quotation marks. |
| TimeOfDelay | The time of the delay in ms. |
| IsDelayPositive | It's value is 1 if the subtitles go faster than the movie, 0 if the subtitles go slower than the movie. |
| InputFps | It's the framerate of the input subtitle file (the one you want to convert). The format must be a number to three decimal spaces without decimal separator. 25,000 will be 25000, 29,97 will be 29970, 23,976 will be 23976 etc. |
| OutputFps | It's the framerate of the movie you want to adjust your subtitle to. Format is the same as above. |
You can use this function to either change the framerate of the subtitles or set a delay on them. (You CAN'T do both together.)
You'll want to set a delay, if the time difference between the movie and the subtitles doesn't change throughout the movie. In other words, if the subtitles come 2s sooner than the movie at the beginning of the movie and at the end of the movie too, you'll have to set a delay (a positive 2000ms delay in this case).
If the time difference increases or decreases throughout the
movie, you'll have to adjust the framerate of the subtitles to the
framerate of the movie. To do that you're gonna have to know the
framerate of the movie and of the subtitles as well. There
are many free and even open source applications designed to get this
kind of information about movies, one of them is MediaInfo
(http://sourceforge.net/projects/mediainfo/). As for the framerate of
the subtitles: If you don't know it, you'll have to guess.
If you downloaded it from somewhere, you'll want to look
there for framerate info. On the popular subtitle download sites you'll
find framerate info by the description of the subtitle. Look for the
acronym "FPS".
If you want to change the framerate, all the delay parameters
(TimeOfDelay, IsDelayPositive) must be set to 0.
The situation is the same if you want to set a delay: the
framerate parameters (InputFps, OutputFps) must be set to 0.
For now only the file based conversion is supported, if you have a string that contains subtitles in srt format, and you want to convert it, you'll have to write it out to a file first, only then can you use this function.
There are no verifying methods implemented, so if the conversion didn't succeed, you'll only know that something went wrong, if you check the output subtitles.
If you have further questions, you can ask them here: http://www.autohotkey.com/forum/topic41466.html
Loop (read file contents), StringReplace, StringSplit, StringLen, Transform, FileAppend, If
; This converts the subtitle file insub.srt in c:\ root from 25,000 fps (framerate of the input subtitle file) to 29,97 fps (framerate of the movie),
; the name and path of the converted subtitle file is c:\outsub.srt
SrtSynch("1", "c:\insub.srt", "c:\outsub.srt", 0, 0, 25000, 29970)
; If the script is in the same folder as the input and/or output subtitles (in this case c:\), instead of full path (c:\insub.srt and c:\outsub.srt),
; you can specify the filename of the input (insub.srt) and/or output (outsub.srt) files.
SrtSynch("1", "insub.srt", "outsub.srt", 0, 0, 25000, 29970)
; This sets a positive 5000ms delay (the output subtitles will pop up 5s later) on the subtitle file insub.srt which is in the folder x:\subtitles,
; it converts the file to c:\ root as outsub.srt
SrtSynch("0", "x:\subtitles\insub.srt", "c:\outsub.srt", 5000, 1, 0, 0)
; The delay settings are the same as above, only here the input file will be overwritten
; with the converted file (input and output filenames and paths are the same)
SrtSynch("0", "x:\subtitles\insub.srt", "x:\subtitles\insub.srt", 5000, 1, 0, 0)