Awesome Open Source
Awesome Open Source

GoReportCard GoDoc Travis Coveralls

This is a Golang library to manipulate subtitles.

It allows you to manipulate srt, stl, ttml, ssa/ass, webvtt and teletext files for now.

Available operations are parsing, writing, syncing, fragmenting, unfragmenting, merging and optimizing.


To install the library and command line program, use the following:

go get -u

Using the library in your code

WARNING: the code below doesn't handle errors for readibility purposes. However you SHOULD!

// Open subtitles
s1, _ := astisub.OpenFile("/path/to/example.ttml")
s2, _ := astisub.ReadFromSRT(bytes.NewReader([]byte("00:01:00.000 --> 00:02:00.000\nCredits")))

// Add a duration to every subtitles (syncing)

// Fragment the subtitles

// Merge subtitles

// Optimize subtitles

// Unfragment the subtitles

// Write subtitles
var buf = &bytes.Buffer{}

Using the CLI

If astisub has been installed properly you can:

  • convert any type of subtitle to any other type of subtitle:

      astisub convert -i -o example.ttml
  • fragment any type of subtitle:

      astisub fragment -i -f 2s -o
  • merge any type of subtitle into any other type of subtitle:

      astisub merge -i -i example.ttml -o
  • optimize any type of subtitle:

      astisub optimize -i -o
  • unfragment any type of subtitle:

      astisub unfragment -i -o
  • sync any type of subtitle:

      astisub sync -i -s "-2s" -o

Features and roadmap

  • [x] parsing
  • [x] writing
  • [x] syncing
  • [x] fragmenting/unfragmenting
  • [x] merging
  • [x] ordering
  • [x] optimizing
  • [x] .srt
  • [x] .ttml
  • [x] .vtt
  • [x] .stl
  • [x] .ssa/.ass
  • [x] .teletext
  • [ ] .smi

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
go (14,669
golang (3,757
golang-library (136
stl (52
subtitle (38
srt (24

Find Open Source By Browsing 7,000 Topics Across 59 Categories