-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathmain.go
59 lines (44 loc) · 928 Bytes
/
main.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
50
51
52
53
54
55
56
57
58
59
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"time"
"videosrt/videosrt"
)
//定义配置文件
const CONFIG = "config.ini"
func main() {
//致命错误捕获
defer func() {
if err := recover(); err != nil {
fmt.Println("执行错误 : ", err)
os.Exit(500)
}
}()
appDir, err := filepath.Abs(filepath.Dir(os.Args[0])) //应用执行根目录
if err != nil {
panic(err)
}
//初始化
if len(os.Args) < 2 {
os.Args = append(os.Args , "")
}
var video string
//设置命令行参数
flag.StringVar(&video, "f", "", "enter a video file waiting to be processed .")
flag.Parse()
if video == "" && os.Args[1] != "" && os.Args[1] != "-f" {
video = os.Args[1]
}
//获取应用
app := videosrt.NewApp(CONFIG)
appDir = videosrt.WinDir(appDir)
//初始化应用
app.Init(appDir)
//调起应用
app.Run(videosrt.WinDir(video))
//延迟退出
time.Sleep(time.Second * 1)
}