-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.go
53 lines (43 loc) · 1.41 KB
/
template.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
package gexrender
import (
"runtime"
"github.com/yearnfar/gexrender/internal/pkg/sliceutil"
)
// Template 素材模板
type Template struct {
Src string `json:"src" validate:"required"` // 文件
Composition string `json:"composition" validate:"required"` // 合成
Dest string `json:"dest"` // 输出
FrameStart string `json:"frame_start"` // -s 开始帧
FrameEnd string `json:"frame_end"` // -e 结束
IncrementFrame string `json:"increment_frame"` // -i
ContinueOnMissing bool `json:"continue_on_missing"` //
SettingsTemplate string `json:"settings_template"` // - RStemplate
OutputModule string `json:"output_module"` // - OMtemplate
OutputExt string `json:"output_ext"` // 输出视频后缀
ImageSequence bool `json:"image_sequence"` // 图片序列帧
}
// Fetch 抓取资源
func (t *Template) Fetch(saveDir string) error {
dest, err := Fetch(t.Src, saveDir)
if err != nil {
return err
}
t.Dest = dest
return nil
}
// IsRenderImageSequence 是否渲染序列帧
func (t *Template) IsRenderImageSequence() bool {
return sliceutil.InStrings(t.OutputExt, []string{"jpeg", "jpg", "png"})
}
// GetOutputExt 渲染视频后缀
func (t *Template) GetOutputExt() string {
if t.OutputExt != "" {
return t.OutputExt
}
if runtime.GOOS == "darwin" {
return "mov"
} else {
return "avi"
}
}