-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile-av1.mjs
63 lines (52 loc) · 1.48 KB
/
compile-av1.mjs
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
import { execSync } from "child_process";
import { join, dirname } from "node:path";
import { existsSync, mkdirSync, rmSync, cpSync, writeFileSync } from "node:fs";
export const enableAv1 = (isWindows) => {
const pkgConfig = `
prefix=${process.cwd()}/av1/build
includedir=$\{prefix\}/include
libdir=$\{prefix\}/lib
srcdir=${process.cwd()}/av1
Name: libdav1d
Description: AV1 decoding library
Version: 1.2.1
Libs: -L$\{prefix\}/src -ldav1d -lpthread ${isWindows ? "" : "-ldl"}
Cflags: -I$\{prefix\}/src -I$\{srcdir\}/src -I$\{prefix\} -I$\{srcdir\} -I$\{prefix\}/include/dav1d -I$\{srcdir\}/include/dav1d -I$\{prefix\}/include -I$\{srcdir\}/include
`.trim();
if (!existsSync("av1")) {
execSync("git clone https://code.videolan.org/videolan/dav1d av1", {
stdio: "inherit",
});
}
execSync("git checkout 1.2.1", {
cwd: "av1",
});
rmSync("av1/build", {
force: true,
recursive: true,
});
mkdirSync("av1/build", {
recursive: true,
});
execSync(
"meson setup .. --default-library=static " +
(isWindows
? "--cross-file=../package/crossfiles/x86_64-w64-mingw32.meson"
: ""),
{
cwd: "av1/build",
stdio: "inherit",
}
);
execSync("ninja", {
cwd: "av1/build",
stdio: "inherit",
});
const outPath = join(process.cwd(), "remotion/lib/pkgconfig/dav1d.pc");
if (!existsSync(dirname(outPath))) {
mkdirSync(dirname(outPath), {
recursive: true,
});
}
writeFileSync(outPath, pkgConfig);
};