Skip to content

Read, write and segment WebVTT caption files in Python.

License

Notifications You must be signed in to change notification settings

allo-media/webvtt-py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.3+.

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

Installation

$ pip install webvtt-py

Usage

from webvtt import WebVTT

for caption in WebVTT().read('captions.vtt'):
    print(caption.start)
    print(caption.end)
    print(caption.text)

Segmenting for HLS

from webvtt import WebVTTSegmenter

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

Converting captions from other formats

Supported formats:

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

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

# we can convert captions in one line
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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%