Skip to content

Latest commit

 

History

History
97 lines (63 loc) · 2.52 KB

README.rst

File metadata and controls

97 lines (63 loc) · 2.52 KB

webvtt-py

pypi Supported Python versions MIT License coverage build-status Documentation Status Downloads

webvtt-py is a Python library for reading, writing and converting WebVTT caption files. It also features caption segmentation useful when captioning HLS videos.

Documentation is available at http://webvtt-py.readthedocs.io.

Installation

$ pip install webvtt-py

Usage

import webvtt

for caption in webvtt.read('captions.vtt'):
    print(caption.identifier)  # cue identifier if any
    print(caption.start)       # cue start time
    print(caption.end)         # cue end time
    print(caption.text)        # cue payload
    print(caption.voice)       # cue voice span if any

Segmenting for HLS

import webvtt

webvtt.segment('captions.vtt', 'output/path')

Converting captions from other formats

Supported formats:

  • SubRip (.srt)
  • YouTube SBV (.sbv)
import webvtt

webvtt = webvtt.from_srt('captions.srt')
webvtt.save()

# alternatively in a single line
webvtt.from_sbv('captions.sbv').save()

CLI

Caption segmentation is also available from the command line:

$ webvtt segment captions.vtt --output output/path

License

Licensed under the MIT License.