-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
45 lines (39 loc) · 1.18 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Example functions.
*/
package srtgears
// This example shows how to merge 2 subtitle files to have a dual sub saved in Sub Station Alpha (*.ssa) format.
func Example_merge() {
sp1, err := srtgears.ReadSrtFile("eng.srt")
// check err
sp2, err := srtgears.ReadSrtFile("hun.srt")
// check err
sp1.Merge(sp2)
err = srtgears.WriteSsaFile("eng+hun.ssa", sp1)
// check err
}
// This example shows how to concatenate 2 files where 2nd part of the movie starts at 51 min 15 sec.
func Example_concat() {
sp1, err := srtgears.ReadSrtFile("cd1.srt")
// check err
sp2, err := srtgears.ReadSrtFile("cd2.srt")
// check err
secPartStart := time.Minute*51 + time.Second*15
sp1.Concatenate(sp2, secPartStart)
err = srtgears.WriteSrtFile("cd12.srt", sp1)
// check err
}
// This example shows how to change subtitle color to yellow,
// move to top, remove HI (hearing impaired lines),
// increase display duration by 10% and save result as a
// Sub Station Alpha (*.ssa) file.
func Example_misc() {
sp1, err := srtgears.ReadSrtFile("eng.srt")
// check err
sp1.SetColor("yellow")
sp1.SetPos(srtgears.Top)
sp1.RemoveHI()
sp1.Lengthen(1.1)
err = srtgears.WriteSsaFile("eng2.ssa", sp1)
// check err
}