/
gpu.ts
90 lines (78 loc) 路 2.19 KB
/
gpu.ts
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
import type {ChromiumOptions, LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {BrowserSafeApis} from '@remotion/renderer/client';
import {defaultBrowserDownloadProgress} from './browser-download-bar';
import {chalk} from './chalk';
import {getCliOptions} from './get-cli-options';
import {Log} from './log';
import {parsedCli, quietFlagProvided} from './parsed-cli';
export const GPU_COMMAND = 'gpu';
const {
enableMultiprocessOnLinuxOption,
glOption,
delayRenderTimeoutInMillisecondsOption,
headlessOption,
} = BrowserSafeApis.options;
export const gpuCommand = async (logLevel: LogLevel) => {
const {
browserExecutable,
disableWebSecurity,
ignoreCertificateErrors,
userAgent,
} = getCliOptions({
isStill: false,
logLevel,
indent: false,
});
const enableMultiProcessOnLinux = enableMultiprocessOnLinuxOption.getValue({
commandLine: parsedCli,
}).value;
const gl = glOption.getValue({commandLine: parsedCli}).value;
const puppeteerTimeout = delayRenderTimeoutInMillisecondsOption.getValue({
commandLine: parsedCli,
}).value;
const headless = headlessOption.getValue({
commandLine: parsedCli,
}).value;
const chromiumOptions: ChromiumOptions = {
disableWebSecurity,
enableMultiProcessOnLinux,
gl,
headless,
ignoreCertificateErrors,
userAgent,
};
const statuses = await RenderInternals.getChromiumGpuInformation({
browserExecutable,
indent: false,
logLevel,
chromiumOptions,
timeoutInMilliseconds: puppeteerTimeout,
onBrowserDownload: defaultBrowserDownloadProgress({
indent: false,
logLevel,
quiet: quietFlagProvided(),
}),
});
for (const {feature, status} of statuses) {
Log.info({indent: false, logLevel}, `${feature}: ${colorStatus(status)}`);
}
};
const colorStatus = (status: string) => {
if (status === 'Enabled') {
return chalk.green(status);
}
if (status === 'Hardware accelerated') {
return chalk.green(status);
}
if (status === 'Disabled') {
return chalk.red(status);
}
if (status === 'Software only. Hardware acceleration disabled') {
return chalk.red(status);
}
if (status === 'Software only, hardware acceleration unavailable') {
return chalk.red(status);
}
return status;
};