Skip to content
Read, write and segment WebVTT caption files in Python.
Python
Branch: master
Clone or download
Latest commit 9106321 Jan 14, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Update version, usage and history Nov 22, 2019
tests Merge branch 'master' of github.com:glut23/webvtt-py into fix_invalid… Jan 1, 2020
webvtt Merge branch 'master' of github.com:glut23/webvtt-py into fix_invalid… Jan 1, 2020
.gitignore
.travis.yml Drop Python3.3 Jun 8, 2018
LICENSE Add license. May 19, 2016
MANIFEST.in Exclude tests. May 20, 2016
README.rst Drop Python3.3 Jun 8, 2018
pytest.ini Switch to using pytest Sep 21, 2019
requirements.txt Refactor of BOM detection, saving as SRT and output writers Sep 16, 2017
setup.py Remove chardet dependency Sep 18, 2017
tox.ini Merge pull request #20 from drape-io/switch_to_pytest Jan 14, 2020

README.rst

webvtt-py

https://travis-ci.org/glut23/webvtt-py.svg?branch=master Documentation Status

webvtt-py is a Python module for reading/writing WebVTT caption files. It also features caption segmentation useful when captioning HLS videos.

Requires Python 3.4+.

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.start)
    print(caption.end)
    print(caption.text)

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()

# one liner if we just need to convert without editing
webvtt.from_sbv('captions.sbv').save()

CLI

Caption segmentation is also available from the command line:

$ webvtt segment captions.vtt --output destination/directoy

License

Licensed under the MIT License.

You can’t perform that action at this time.