-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.go
89 lines (77 loc) · 1.75 KB
/
helper.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)
func totalDurationCalculate(inputPath string, locImageCounter int) string {
_totalVideoDuration := totalDurationVideo(inputPath)
splitTotal := int(_totalVideoDuration / float32(myFlag.second))
lenSplitTotal := len(strconv.Itoa(splitTotal)) + 1
preload := len(strconv.Itoa(locImageCounter + 1))
updateZero := lenSplitTotal - preload
prefixZero := ""
for i := 1; i <= updateZero; i++ {
prefixZero = prefixZero + "0"
}
return prefixZero
// fmt.Println("---------------> ", lenSplitTotal)
}
func maxDurationPerSecond(inputPath string, durable int) int {
_totalVideoDuration := int(totalDurationVideo(inputPath))
if durable == -1 {
return _totalVideoDuration
} else if durable > _totalVideoDuration {
log.Panic("duration is greater than total duration of video")
return _totalVideoDuration
} else {
return durable
}
}
func execute() {
cmd, err := exec.Command("/bin/sh", "./pdf.sh").Output()
if err != nil {
fmt.Printf("error %s", err)
}
output := string(cmd)
log.Info(output)
}
func cleanOutPut(outPath string) {
// v := outPath + "*.jpg"
_path := outPath + "*.jpg"
files, err := filepath.Glob(_path)
if err != nil {
panic(err)
}
for _, f := range files {
if err := os.Remove(f); err != nil {
panic(err)
}
}
}
func runMode(condition bool) runnerCore {
if condition {
return &RunReadFrameAsJpeg{}
} else {
return &RunReadTimePositionAsJpeg{}
}
}
func runner(isParallel bool, f runnerCore, arg flags) {
if isParallel {
go func() {
err := f.Execute(arg)
if err != nil {
logrus.Error(err)
}
}()
} else {
err := f.Execute(arg)
if err != nil {
logrus.Error(err)
}
}
}