read_subtitles: Read subtitles

Description Usage Arguments Details Value Examples

View source: R/read_subtitles.R

Description

Reads subtitles from a file.

Usage

1
2
read_subtitles(file, format = "auto", clean.tags = TRUE,
  metadata = data.frame(), frame.rate = NA, encoding = "auto")

Arguments

file

the name of the file which the subtitles are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory.

format

a character string specifying the format of the subtitles. Four formats can be read: "subrip", "substation", "microdvd", "subviewer" (v.2) and "webvtt". Default is "auto" which tries to detect automatically the format of the file from its extension.

clean.tags

logical. If "TRUE" (default), formating tags are deleted from subtitles using clean_tags.

metadata

a one-row dataframe or tibble, or any object that can be coerced into a one-row tibble by link[tibble]{as_tibble}.

frame.rate

a numeric value giving the frame rate in frames per second. Only relevant for MicroDVD format. If NA (default), the function tries to extract the frame.rate from the file. If it fails, the frame rate is set at 24p (23.976).

encoding

the name of the encoding to be used. Default is "auto" and uses guess_encoding to detect encoding.

Details

The support of WebVTT is basic and experimental.

Value

An object of class subtitles (see subtitles).

Examples

1
2
3
4
# read a SubRip file
f <- system.file("extdata", "ex_subrip.srt", package = "subtools")
f <- system.file("extdata", "ex_webvtt.vtt", package = "subtools")
read_subtitles(f)

fkeck/subtools documentation built on Dec. 2, 2019, 3:19 a.m.