-
Notifications
You must be signed in to change notification settings - Fork 32
/
ffmpeg.tengo
166 lines (162 loc) · 7.8 KB
/
ffmpeg.tengo
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
os := import("os")
fmt := import("fmt")
text := import("text")
nami := import("nami")
json := import("json")
got := false
if nami.os == "darwin" && nami.arch == "arm64" {
got = true
if err := nami.sh("which", "7z"); is_error(err){
fmt.println("Please install 7z first: $ nami install 7z")
os.exit(1)
}
err := nami.write_file(nami.cache_dir + "/version", "v6.1")
if is_error(err) {
fmt.println(err)
os.exit(1)
}
err = nami.sh("curl", "-L", "--progress-bar", "https://www.osxexperts.net/ffmpeg61arm.zip", "-o", "/tmp/_.zip")
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", "/tmp/_")
nami.sh("mkdir", "/tmp/_")
nami.sh("7z", "x", "/tmp/_.zip", "-o/tmp/_")
nami.sh("mv", "/tmp/_/ffmpeg", nami.cache_dir+"/ffmpeg")
err = nami.sh("curl", "-L", "--progress-bar", "https://www.osxexperts.net/ffprobe61arm.zip", "-o", "/tmp/_.zip")
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", "/tmp/_")
nami.sh("mkdir", "/tmp/_")
nami.sh("7z", "x", "/tmp/_.zip", "-o/tmp/_")
nami.sh("mv", "/tmp/_/ffprobe", nami.cache_dir+"/ffprobe")
err = nami.sh("curl", "-L", "--progress-bar", "https://www.osxexperts.net/ffplay61arm.zip", "-o", "/tmp/_.zip")
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", "/tmp/_")
nami.sh("mkdir", "/tmp/_")
nami.sh("7z", "x", "/tmp/_.zip", "-o/tmp/_")
nami.sh("mv", "/tmp/_/ffplay", nami.cache_dir+"/ffplay")
}
if nami.os == "darwin" && nami.arch == "amd64" {
got = true
if err := nami.sh("which", "7z"); is_error(err){
fmt.println("Please install 7z first: $ nami install 7z")
os.exit(1)
}
b := nami.sh1("curl", "-L", "https://evermeet.cx/ffmpeg/info/ffmpeg/release")
if is_error(b) {
fmt.println(b)
os.exit(1)
}
v := json.decode(b).version
err := nami.write_file(text.join([nami.cache_dir, "version"], os.path_separator), v)
if is_error(err) {
fmt.println(err)
os.exit(1)
}
err = nami.sh("curl", "-L", "--progress-bar", "https://evermeet.cx/ffmpeg/getrelease/ffmpeg/zip", "-o", text.join([nami.tmp_dir, "_.zip"], os.path_separator))
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mkdir", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("7z", "x", text.join([nami.tmp_dir, "_.zip"], os.path_separator), "-o" + text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", "ffmpeg"], os.path_separator), text.join([nami.cache_dir, "ffmpeg"], os.path_separator))
err = nami.sh("curl", "-L", "--progress-bar", "https://evermeet.cx/ffmpeg/getrelease/ffprobe/zip", "-o", text.join([nami.tmp_dir, "_.zip"], os.path_separator))
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mkdir", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("7z", "x", text.join([nami.tmp_dir, "_.zip"], os.path_separator), "-o" + text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", "ffprobe"], os.path_separator), text.join([nami.cache_dir, "ffprobe"], os.path_separator))
err = nami.sh("curl", "-L", "--progress-bar", "https://evermeet.cx/ffmpeg/getrelease/ffplay/zip", "-o", text.join([nami.tmp_dir, "_.zip"], os.path_separator))
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mkdir", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("7z", "x", text.join([nami.tmp_dir, "_.zip"], os.path_separator), "-o" + text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", "ffplay"], os.path_separator), text.join([nami.cache_dir, "ffplay"], os.path_separator))
err = nami.sh("curl", "-L", "--progress-bar", "https://evermeet.cx/ffmpeg/getrelease/ffserver/zip", "-o", text.join([nami.tmp_dir, "_.zip"], os.path_separator))
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mkdir", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("7z", "x", text.join([nami.tmp_dir, "_.zip"], os.path_separator), "-o" + text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", "ffserver"], os.path_separator), text.join([nami.cache_dir, "ffserver"], os.path_separator))
}
if nami.os == "linux" && nami.arch == "amd64" {
got = true
b := nami.sh1("sh", "-c", "curl https://johnvansickle.com/ffmpeg/release-readme.txt | grep -oP 'version: \\S+' | cut -d: -f2")
if is_error(b){
fmt.println(b)
os.exit(1)
}
v := text.trim_space(string(b))
err := nami.write_file(text.join([nami.cache_dir, "version"], os.path_separator), v)
if is_error(err) {
fmt.println(err)
os.exit(1)
}
err = nami.sh("curl", "-L", "--progress-bar", "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz", "-o", text.join([nami.tmp_dir, "_.txz"], os.path_separator))
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mkdir", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("tar", "Jxvf", text.join([nami.tmp_dir, "_.txz"], os.path_separator), "-C", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", "ffmpeg-"+v+"-amd64-static", "ffmpeg"], os.path_separator), text.join([nami.cache_dir, "ffmpeg"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", "ffmpeg-"+v+"-amd64-static", "ffprobe"], os.path_separator), text.join([nami.cache_dir, "ffprobe"], os.path_separator))
}
if nami.os == "windows" && nami.arch == "amd64" {
got = true
if err := nami.sh("which", "7z"); is_error(err){
fmt.println("Please install 7z first: $ nami install 7z")
os.exit(1)
}
b := nami.sh1("curl", "https://www.gyan.dev/ffmpeg/builds/last-build-update")
if is_error(b){
fmt.println(b)
os.exit(1)
}
v := text.trim_space(string(b))
err := nami.write_file(text.join([nami.cache_dir, "version"], os.path_separator), v)
if is_error(err) {
fmt.println(err)
os.exit(1)
}
err = nami.sh("curl", "-L", "--progress-bar", "https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z", "-o", text.join([nami.tmp_dir, "_.7z"], os.path_separator))
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("mkdir", text.join([nami.tmp_dir, "_"], os.path_separator))
nami.sh("7z", "x", text.join([nami.tmp_dir, "_.7z"], os.path_separator), "-o" + text.join([nami.tmp_dir, "_"], os.path_separator))
b = nami.sh1("sh", "-c", "ls $HOME/.nami/tmp/_ | cut -d/ -f1")
if is_error(b){
fmt.println(b)
os.exit(1)
}
s := text.trim_space(string(b))
nami.sh("mv", text.join([nami.tmp_dir, "_", s, "bin", "ffmpeg.exe"], os.path_separator), text.join([nami.cache_dir, "ffmpeg.exe"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", s, "bin", "ffplay.exe"], os.path_separator), text.join([nami.cache_dir, "ffplay.exe"], os.path_separator))
nami.sh("mv", text.join([nami.tmp_dir, "_", s, "bin", "ffprobe.exe"], os.path_separator), text.join([nami.cache_dir, "ffprobe.exe"], os.path_separator))
}
if !got {
fmt.println("ffmpeg does not support your OS or Arch now. PR welcome: https://github.com/txthinking/nami/blob/master/package")
os.exit(1)
}