From bf83847f3e1e35b332bc535748cc330c4815199b Mon Sep 17 00:00:00 2001 From: Quentin Renard Date: Sun, 2 Jul 2017 15:52:57 +0200 Subject: [PATCH] Added readme --- readme.md | 74 ++++++++++++++++++++++++++++++++++++++ testdata/example-in.srt | 26 ++++++++++++++ testdata/example-in.stl | Bin 0 -> 1792 bytes testdata/example-in.ttml | 46 ++++++++++++++++++++++++ testdata/example-in.vtt | 42 ++++++++++++++++++++++ testdata/example-out.srt | 26 ++++++++++++++ testdata/example-out.stl | Bin 0 -> 1792 bytes testdata/example-out.ttml | 48 +++++++++++++++++++++++++ testdata/example-out.vtt | 37 +++++++++++++++++++ 9 files changed, 299 insertions(+) create mode 100644 readme.md create mode 100644 testdata/example-in.srt create mode 100644 testdata/example-in.stl create mode 100644 testdata/example-in.ttml create mode 100644 testdata/example-in.vtt create mode 100644 testdata/example-out.srt create mode 100644 testdata/example-out.stl create mode 100644 testdata/example-out.ttml create mode 100644 testdata/example-out.vtt diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..1b8bdb8 --- /dev/null +++ b/readme.md @@ -0,0 +1,74 @@ +[![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) +[![GoCoverage](https://cover.run/go/github.com/asticode/go-astisub.svg)](https://cover.run/go/github.com/asticode/go-astisub) + +This is a Golang library to manipulate subtitles. + +It allows you to manipulate `srt`, `ttml` and `webvtt` files for now. + +Available operations are `parsing`, `writing`, `syncing`, `fragmenting` and `merging`. + +# Installation + +To install the library and command line program, use the following: + + go get -u github.com/asticode/go-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.Open("/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) +s1.Add(-2*time.Second) + +// Fragment the subtitles +s1.Fragment(2*time.Second) + +// Merge subtitles +s1.Merge(s2) + +// 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 + +- 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 + +- 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 +- [x] merging +- [x] ordering +- [x] .srt +- [x] .ttml +- [x] .vtt +- [x] .stl +- [ ] .teletext +- [ ] .smi \ No newline at end of file diff --git a/testdata/example-in.srt b/testdata/example-in.srt new file mode 100644 index 0000000..d5d552d --- /dev/null +++ b/testdata/example-in.srt @@ -0,0 +1,26 @@ +1 +00:01:39 --> 00:01:41,04 +(deep rumbling) + +2 +00:02:04,08 --> 00:02:07,12 +MAN: +How did we end up here? + +3 +00:02:12,16 --> 00:02:15,20 +This place is horrible. + +4 +00:02:20,24 --> 00:02:22,28 +Smells like balls. + +5 +00:02:28,32 --> 00:02:31,36 +We don't belong +in this shithole. + +6 +00:02:31,40 --> 00:02:33,44 +(computer playing +electronic melody) diff --git a/testdata/example-in.stl b/testdata/example-in.stl new file mode 100644 index 0000000000000000000000000000000000000000..ea74d60b7f7ee29a9ad2cc835cc297b4f74e3818 GIT binary patch literal 1792 zcmeH_J8!};5P&b{)tA%-b*jX50v2QwUhPt$N~lBIp&)f8$%$Asag;bh`~{Z&HgJ zkNy@h;C(mmc^|^Pw+F@Sefp&1Z6a5pIbsoe0jK?B;2#6vz&C)?wzKOr9q0r^F(%pC zQ!-k0zse3^IiFP-utvr5U#D*myJx+@KnA!Wq$t2F#*h+vETa~v6#T0yu5ZO+uX{(o@tc16|w+)q>xw1G{Nh{(MbJrKsd5p|`YYdFWq$t>E9D0c)LG{s&>8 zqqaehl#W(A8KKFQq@gsSKD-I27yQ-*u)9mk@A!HhXNHpe5w`XV?nseu5* + + + Title test + Copyright test + + + + + + + + + + + + + +
+

+ (deep rumbling) +

+

+ MAN: +

+ How did we + end up + here? +

+

+ This place is horrible. +

+

+ Smells like balls. +

+

+ We don't belong +

+ in this shithole. +

+

+ (computer playing +

+ electronic melody) +

+
+ + \ No newline at end of file diff --git a/testdata/example-out.vtt b/testdata/example-out.vtt new file mode 100644 index 0000000..e3092a8 --- /dev/null +++ b/testdata/example-out.vtt @@ -0,0 +1,37 @@ +WEBVTT + +Region: id=fred lines=3 regionanchor=0%,100% scroll=up viewportanchor=10%,90% width=40% +Region: id=bill lines=3 regionanchor=100%,100% scroll=up viewportanchor=90%,90% width=40% + +NOTE this a nice example +of a VTT + +1 +00:01:39.000 --> 00:01:41.040 region:bill +(deep rumbling) + +NOTE This a comment inside the VTT +and this is the second line + +2 +00:02:04.080 --> 00:02:07.120 align:left position:10%,start region:fred size:35% +MAN: +How did we end up here? + +3 +00:02:12.160 --> 00:02:15.200 +This place is horrible. + +4 +00:02:20.240 --> 00:02:22.280 +Smells like balls. + +5 +00:02:28.320 --> 00:02:31.360 +We don't belong +in this shithole. + +6 +00:02:31.400 --> 00:02:33.440 +(computer playing +electronic melody)