Skip to content

Read, write, convert and segment WebVTT caption files in Python.

License

Notifications You must be signed in to change notification settings

t-hiroishi/webvtt-py

 
 

Repository files navigation

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.

About

Read, write, convert and segment WebVTT caption files in Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.9%
  • Other 0.1%