Type: | Package |
Title: | Adjust Srt File to Get Better Experience when Watching Movie |
Version: | 1.2.0 |
Date: | 2019-07-02 |
Description: | Srt file is a common subtitle format for videos, it contains subtitle and when the subtitle showed. This package is for align time of srt file, and also change color, style and position of subtitle in videos, the srt file will be read as a vector into R, and can be write into srt file after modified using this package. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Imports: | magrittr (≥ 1.5) |
RoxygenNote: | 6.1.1 |
Encoding: | UTF-8 |
Depends: | R (≥ 2.10) |
URL: | https://github.com/ChiHangChen/SRTtools |
BugReports: | https://github.com/ChiHangChen/SRTtools/issues |
NeedsCompilation: | no |
Packaged: | 2019-07-16 10:01:25 UTC; ChiHang |
Author: | Jim Chen [aut, cre] |
Maintainer: | Jim Chen <jim71183@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2019-07-18 06:38:24 UTC |
Adjust srt file to get better experience in watching movie.
Description
Srt file is a common subtitle format for videos, it contains subtitle and when the subtitle showed. This package is for ealign time of srt file, and also change color, style and position of subtitle in videos, the srt file will be read as a vector into R, and can be write into srt file after modified using this package.
Author(s)
Jim Chen
Retrieve Subtitle Text
Description
Retrieve all the subtitle text content from a srt file
Usage
srt.content(srt)
Arguments
srt |
vector. The srt file read by |
See Also
Examples
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
srt.content(srt)
Insert new dialog
Description
Insert new dialog to subtitles by specific index
Usage
srt.insert(srt, index, time, text)
Arguments
srt |
vector. The srt file read by |
index |
integer. The index of new dialog. |
time |
character. The time of new dialog, a proper format is "hr:min:sec,msec –> hr:min:sec,msec" |
text |
character. The content of new dialog. |
See Also
Examples
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
srt.insert(srt, index = 1, time = "00:00:00,000 --> 00:00:30,000", text = "Added by SRTtools")
Read srt file
Description
Read a srt file as a vector, if there is any encoding issue, try to save your srt fle as ANSI encoding using Windows Notepad.
Usage
srt.read(file, encoding = "utf-8")
Arguments
file |
character. The name of the file which the subtitles are to be read from. |
encoding |
character. Encoding to be assumed for input strings, deafult is 'utf-8'. |
See Also
Examples
# read a ANSI srt file
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
Remove dialog
Description
Remove unwanted dialog from subtitles by specific index
Usage
srt.remove(srt, index)
Arguments
srt |
vector. The srt file read by |
index |
integer. The index of unwanted dialog . |
See Also
Examples
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
srt.remove(srt, index = 10)
Search Index By KeyWord
Description
Return the subtitle index by specific keyword
Usage
srt.search(srt, key_word)
Arguments
srt |
vector. The srt file read by |
key_word |
character. The key word want to be searched in subtitles. |
See Also
Examples
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
srt.search(srt, key_word = "captain")
Re-synchronize Srt File
Description
Shift a srt file with specific time.
Usage
srt.shift(srt, time_shifted)
Arguments
srt |
vector. The srt file read by |
time_shifted |
numeric. The time that srt file want to be shifted (in seconds). |
See Also
Examples
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
# Postpone subtitles 3 seconds later
srt <- srt.shift(srt, time_shifted = 3)
# Expedite subtitles 5 seconds earlier
srt <- srt.shift(srt, time_shifted = -5)
Change Style of Subtitle
Description
Change subtitle style or posistion by specific subtitle index.
Usage
srt.style(srt, line = "all", pos = "None", style = "None",
col = "None")
Arguments
srt |
vector. The srt file read by |
line |
numerical vector. Style will only change the subtitles of the selected subtitle index, default is 'all', means the whole subtitles will apply the style. |
pos |
character. The subtitles position, the valid options are ' |
style |
character vector. The styles that subtitle applied, ' |
col |
character. The color that subtitle applied. |
See Also
Examples
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
srt.style(srt, line = c(1,3,5), pos = 'top-left', style = c('b','i'), col = 'red')
Srt Output
Description
Write the srt file to the system.
Usage
srt.write(srt, filename)
Arguments
srt |
vector. The srt file read by |
filename |
Either a character string naming a file or a connection open for writing. |
See Also
Examples
srt_path <- system.file("extdata", "movie.srt", package="SRTtools")
srt <- srt.read(srt_path, encoding = 'utf-8')
# Postpone subtitles 3 seconds later
srt <- srt.shift(srt, time_shifted = 3)
# Save and cover original "movie.srt" file
srt.write(srt, filename = file.path(tempdir(), "movie.srt"))