-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (43 loc) · 1021 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
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
)
func main() {
err := filepath.Walk("C:/Users/Ricardo/Videos/compress", func(path string, info os.FileInfo, err error) error {
var input, output string
if err != nil {
fmt.Println(err)
return err
}
if !info.IsDir() {
fmt.Printf("Compress filename: %s\n", info.Name())
input = "C:/Users/Ricardo/Videos/compress/" + info.Name()
output = "C:/Users/Ricardo/Videos/compressed/" + info.Name()
cmd := exec.Command("ffmpeg",
"-i",
input,
"-c:v",
"libx264",
"-pix_fmt",
"yuv420p",
output,
)
// pipe the commands output to the applications
// standard output
cmd.Stdout = os.Stdout
fmt.Println("Run command: " + cmd.String())
// Run still runs the command and waits for completion
// but the output is instantly piped to Stdout
if err := cmd.Run(); err != nil {
fmt.Println("could not run command: ", err)
}
}
return nil
})
if err != nil {
fmt.Println(err)
}
}