Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asticode/go-astisub
Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)
https://github.com/asticode/go-astisub
go golang golang-library srt stl subtitle ttml webvtt
Last synced: 2 days ago
JSON representation
Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)
- Host: GitHub
- URL: https://github.com/asticode/go-astisub
- Owner: asticode
- License: mit
- Created: 2016-12-16T14:47:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-08T13:59:16.000Z (26 days ago)
- Last Synced: 2024-10-25T05:26:08.102Z (10 days ago)
- Topics: go, golang, golang-library, srt, stl, subtitle, ttml, webvtt
- Language: Go
- Homepage:
- Size: 139 KB
- Stars: 587
- Watchers: 9
- Forks: 111
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-video - go-astisub - Manipulate subtitles in GO (.srt, .stl, .ttml, .webvtt, .ssa/.ass, teletext, .smi, etc.). (Language and platform specific libraries / Go)
- awesome-go - go-astisub - Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.) - ★ 130 (Video)
- awesome-go-extra - go-astisub - 12-16T14:47:59Z|2022-07-11T20:05:40Z| (Video / Fail injection)
README
[![GoReportCard](http://goreportcard.com/badge/github.com/asticode/go-astisub)](http://goreportcard.com/report/github.com/asticode/go-astisub)
[![GoDoc](https://godoc.org/github.com/asticode/go-astisub?status.svg)](https://godoc.org/github.com/asticode/go-astisub)
[![Test](https://github.com/asticode/go-astisub/actions/workflows/test.yml/badge.svg)](https://github.com/asticode/go-astisub/actions/workflows/test.yml)
[![Coveralls](https://coveralls.io/repos/github/asticode/go-astisub/badge.svg?branch=master)](https://coveralls.io/github/asticode/go-astisub)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`, `applying linear correction`, `syncing`, `fragmenting`, `unfragmenting`, `merging` and `optimizing`.
# Installation
To install the library:
go get github.com/asticode/go-astisub
To install the CLI:
go install github.com/asticode/go-astisub/astisub
# Using the library in your code
WARNING: the code below doesn't handle errors for readibility purposes. However you SHOULD!
```go
// Open subtitles
s1, _ := astisub.OpenFile("/path/to/example.ttml")
s2, _ := astisub.ReadFromSRT(bytes.NewReader([]byte("1\n00:01:00.000 --> 00:02:00.000\nCredits")))// Add a duration to every subtitles (syncing)
s1.Add(-2*time.Second)// Fragment the subtitles
s1.Fragment(2*time.Second)// Merge subtitles
s1.Merge(s2)// Optimize subtitles
s1.Optimize()// Unfragment the subtitles
s1.Unfragment()// Apply linear correction
s1.ApplyLinearCorrection(1*time.Second, 2*time.Second, 5*time.Second, 7*time.Second)// Write subtitles
s1.Write("/path/to/example.srt")
var buf = &bytes.Buffer{}
s2.WriteToTTML(buf)
```# 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 example.srt -o example.ttml
- apply linear correction to any type of subtitle:
astisub apply-linear-correction -i example.srt -a1 1s -d1 2s -a2 5s -d2 7s -o example.out.srt
- fragment any type of subtitle:
astisub fragment -i example.srt -f 2s -o example.out.srt
- merge any type of subtitle into any other type of subtitle:
astisub merge -i example.srt -i example.ttml -o example.out.srt
- optimize any type of subtitle:
astisub optimize -i example.srt -o example.out.srt
- unfragment any type of subtitle:
astisub unfragment -i example.srt -o example.out.srt
- sync any type of subtitle:
astisub sync -i example.srt -s "-2s" -o example.out.srt
# Features and roadmap
- [x] parsing
- [x] writing
- [x] syncing
- [x] fragmenting/unfragmenting
- [x] merging
- [x] ordering
- [x] optimizing
- [x] linear correction
- [x] .srt
- [x] .ttml
- [x] .vtt
- [x] .stl
- [x] .ssa/.ass
- [x] .teletext
- [ ] .smi