Write subtitle data frame as SubRip text file

write_srt(x, path = NULL, wrap = TRUE, width = 40)

Arguments

x

A subtitle data frame from read_srt().

path

File or connection to write to.

wrap

If TRUE (default), subtitle lines will be wrapped.

width

If wrap is TRUE, the width of each wrapped subtitle.

Value

The path to the written file, invisibly.

Details

The SubRip text files format subtitles with four components separated by a blank line:

  1. A numeric counter identifying each sequential subtitle

  2. The time that the subtitle should appear on the screen, followed by --> and the time it should disappear

  3. Subtitle text itself on one or more lines

  4. A blank line containing no text, indicating the end of this subtitle

Examples

# read and write without line breaks
x <- read_srt(srt_example(), collapse = " ")
write_srt(x, tempfile(fileext = ".srt"), wrap = FALSE)