# webvtt-py package reference

## webvtt.webvtt

class `webvtt.webvtt.``WebVTT`(file='', captions=None, styles=None)

  Parse captions in WebVTT format and also from other formats like SRT.

  To read WebVTT:

  > WebVTT().read(‘captions.vtt’)

  For other formats like SRT, use from_[format in lower case]:

  > WebVTT().from_srt(‘captions.srt’)

  A list of all supported formats is available calling list_formats().

  `captions`

    Returns the list of captions.

  classmethod `from_sbv`(file)

    Reads captions from a file in YouTube SBV format.

  classmethod `from_srt`(file)

    Reads captions from a file in SubRip format.

  static `list_formats`()

    Provides a list of supported formats that this class can read from.

  classmethod `read`(file)

    Reads a WebVTT captions file.

  classmethod `read_buffer`(buffer)

    Reads a WebVTT captions from a file-like object. Such file-like object may be the return of an io.open call, io.StringIO object, tempfile.TemporaryFile object, etc.

  `save`(output='')

    Save the document. If no output is provided the file will be saved in the same location. Otherwise output can determine a target directory or file.

  `total_length`

    Returns the total length of the captions.

## webvtt.segmenter

class `webvtt.segmenter.``WebVTTSegmenter`

  Provides segmentation of WebVTT captions for HTTP Live Streaming (HLS).

  `seconds`

    Returns the number of seconds used for segmenting captions.

  `segment`(webvtt, output='', seconds=10, mpegts=900000)

    Segments the captions based on a number of seconds.

  `segments`

    Return the list of segments.

  `total_segments`

    Returns the total of segments.

## webvtt.cli

Usage:
  webvtt segment <file> [–target-duration=SECONDS] [–mpegts=OFFSET] [–output=<dir>] webvtt -h | –help webvtt –version
Options:
  -h –help Show this screen. –version Show version. –target-duration=SECONDS Target duration of each segment in seconds [default: 10]. –mpegts=OFFSET Presentation timestamp value [default: 900000]. –output=<dir> Output to directory [default: ./].
Examples:
  webvtt segment captions.vtt –output destination/directory

`webvtt.cli.``main`()

  Main entry point for CLI commands.

`webvtt.cli.``segment`(f, output, target_duration, mpegts)

  Segment command.

## webvtt.generic

## webvtt.parsers

class `webvtt.parsers.``SBVParser`(parse_options=None)

  Bases: `webvtt.parsers.TextBasedParser`

  YouTube SBV parser.

class `webvtt.parsers.``SRTParser`(parse_options=None)

  Bases: `webvtt.parsers.TextBasedParser`

  SRT parser.

class `webvtt.parsers.``TextBasedParser`(parse_options=None)

  Bases: `object`

  Parser for plain text caption files. This is a generic class, do not use directly.

  `read`(file)

    Reads the captions file.

class `webvtt.parsers.``WebVTTParser`

  Bases: `webvtt.parsers.TextBasedParser`

  WebVTT parser.

## webvtt.writers

## webvtt.exceptions