-
Notifications
You must be signed in to change notification settings - Fork 19
/
blog_test.go
49 lines (44 loc) · 1.03 KB
/
blog_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
46
47
48
49
package main
import (
"testing"
"html/template"
"io"
"io/ioutil"
"os"
"os/exec"
"fmt"
)
func TestTplConvContent(t *testing.T) {
assBuf, _ := ioutil.ReadFile("./resources/template/sorry/template.ass")
outputAss, _ := os.Create("./dist/output.ass")
makeAss(string(assBuf), outputAss)
}
func makeAss(tplContentText string, fWriter io.Writer) {
sentences := []string{
"好啊",
"就算你是一流程序员",
"写出来的代码再完美",
"我说这是 BUG 它就是 BUG",
"毕竟我是用户",
"你害我加班啊",
"sorry 我就喜欢看程序猿加班",
"以后天天找他 BUG",
"天天找 天天找",
}
data := map[string][]string{
"sentences": sentences,
}
tpl := template.New("subTitle")
tpl, _ = tpl.Parse(tplContentText)
tpl.Execute(fWriter, data)
}
func TestMakeVideo(t *testing.T) {
makeVideo()
}
func makeVideo() {
cmd := exec.Command("ffmpeg", "-i", "./resources/template/sorry/template.mp4",
"-vf", fmt.Sprintf("ass=%s", "./dist/output.ass"),
"-an",
"-y", "./dist/output.mp4")
cmd.Start()
}