sp3ctum / webvtt-py

Read, write and segment WebVTT caption files in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Read, write and segment WebVTT caption files in Python.

License:MIT License


Languages

Language:Python 100.0%Language:SRecode Template 0.0%