Skip to content

🎥 Make videos programmatically with React

npx remotion gpu

Jonny Burger9d0c7f25b1c0
diff --git a/packages/cli-autocomplete/src/source.ts b/packages/cli-autocomplete/src/source.ts
index 75052d8667..3e5d9f5d7f 100644
--- a/packages/cli-autocomplete/src/source.ts
+++ b/packages/cli-autocomplete/src/source.ts
@@ -500,6 +500,10 @@ const completionSpec: Fig.Spec = {
name: "versions",
description: "Prints and validates versions of all Remotion packages",
},
+ {
+ name: "gpu",
+ description: "Prints information about how Chrome uses the GPU",
+ },
{
name: "compositions",
description: "Prints the list of available compositions",
diff --git a/packages/cli/src/gpu.ts b/packages/cli/src/gpu.ts
new file mode 100644
index 0000000000..64fed422bf
--- /dev/null
+++ b/packages/cli/src/gpu.ts
@@ -0,0 +1,48 @@
+import {RenderInternals} from '@remotion/renderer';
+import {chalk} from './chalk';
+import {getCliOptions} from './get-cli-options';
+import {Log} from './log';
+
+export const GPU_COMMAND = 'gpu';
+
+export const gpuCommand = async (remotionRoot: string) => {
+ const {browserExecutable, logLevel, chromiumOptions} = await getCliOptions({
+ isLambda: false,
+ remotionRoot,
+ type: 'get-compositions',
+ });
+
+ const statuses = await RenderInternals.getChromiumGpuInformation({
+ browserExecutable,
+ indent: false,
+ logLevel,
+ chromiumOptions,
+ });
+ for (const {feature, status} of statuses) {
+ Log.info(`${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;
+};
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index 6af9eae827..33a949d2f2 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -15,6 +15,7 @@ import {getCliOptions} from './get-cli-options';
import {getCompositionWithDimensionOverride} from './get-composition-with-dimension-override';
import {loadConfig} from './get-config-file-name';
import {getFinalOutputCodec} from './get-final-output-codec';
+import {gpuCommand} from './gpu';
import {getVideoImageFormat} from './image-formats';
import {initializeCli} from './initialize-cli';
import {lambdaCommand} from './lambda-command';
@@ -91,6 +92,8 @@ export const cli = async () => {
await still(remotionRoot, args);
} else if (command === 'ffmpeg') {
ffmpegCommand(remotionRoot, process.argv.slice(3));
+ } else if (command === 'gpu') {
+ await gpuCommand(remotionRoot);
} else if (command === 'ffprobe') {
ffprobeCommand(remotionRoot, process.argv.slice(3));
} else if (command === 'upgrade') {
diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.ts
index 09b6396ee4..99411222bf 100644
--- a/packages/cli/src/print-help.ts
+++ b/packages/cli/src/print-help.ts
@@ -1,90 +1,64 @@
import {chalk} from './chalk';
+import {GPU_COMMAND} from './gpu';
import {Log} from './log';
import {VERSIONS_COMMAND} from './versions';
const packagejson = require('../package.json');
-const printFlags = (flags: [string, string][]) => {
- flags.forEach(([flag, description]) => {
- Log.info(chalk.blue(`${flag.padEnd(22, ' ')} ${description}`));
- });
-};
-
export const printHelp = () => {
- Log.info(
- `@remotion/cli ${
- packagejson.version
- } © ${new Date().getFullYear()} The Remotion developers`,
- );
+ Log.info(`@remotion/cli ${packagejson.version}`);
+ Log.info(`© ${new Date().getFullYear()} The Remotion AG`);
Log.info();
Log.info('Available commands:');
Log.info('');
- Log.info('remotion studio <entry-point.ts>');
- Log.info(chalk.gray('Start the Remotion studio.'));
- printFlags([['--props', 'Pass input props as filename or as JSON']]);
- Log.info();
- Log.info('remotion render <entry-point.ts> <comp-id> <output-file.mp4>');
- Log.info(chalk.gray('Render video, audio or an image sequence.'));
- printFlags([
- ['--props', 'Pass input props as filename or as JSON'],
- ['--concurrency', 'How many frames to render in parallel'],
- ['--image-format', 'Format to render the video/still in'],
- ['--pixel-format', 'Custom pixel format, see docs for available values'],
- ['--config', 'Custom location for a Remotion config file'],
- ['--jpeg-quality', 'Quality for rendered frames, JPEG only, 0-100'],
- ['--overwrite', 'Overwrite if file exists, default true'],
- ['--sequence', 'Output as an image sequence'],
- ['--codec', 'Video of audio codec'],
- ['--audio-bitrate', 'Customize the output audio bitrate'],
- ['--video-bitrate', 'Customize the output video bitrate'],
- ['--crf', 'FFMPEG CRF value, controls quality, see docs for info'],
- ['--browser-executable', 'Custom path for browser executable'],
- ['--frames', 'Render a portion or a still of a video'],
- ['--bundle-cache', 'Cache webpack bundle, boolean, default true'],
- ['--log', 'Log level, "error", "warning", "verbose", "info" (default)'],
- ['--port', 'Custom port to use for the HTTP server'],
- ['--env-file', 'Specify a location for a dotenv file'],
- ]);
+ Log.info(chalk.blue('remotion studio') + chalk.gray(' <entry-point.ts>'));
+ Log.info('Start the Remotion studio.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/studio'));
Log.info();
- Log.info('remotion still <entry-point.ts> <comp-id> <still.png>');
- Log.info(chalk.gray('Render a still frame and save it as an image.'));
- printFlags([
- ['--frame', 'Which frame to render (default 0)'],
- ['--image-format', 'Format to render the video/still in'],
- ['--props', 'Pass input props as filename or as JSON'],
- ['--config', 'Custom location for a Remotion config file'],
- ['--jpeg-quality', 'Quality for rendered frames, JPEG only, 0-100'],
- ['--overwrite', 'Overwrite if file exists, default true'],
- ['--browser-executable', 'Custom path for browser executable'],
- ['--bundle-cache', 'Cache webpack bundle, boolean, default true'],
- ['--log', 'Log level, "error", "warning", "verbose", "info" (default)'],
- ['--port', 'Custom port to use for the HTTP server'],
- ['--env-file', 'Specify a location for a dotenv file'],
- ]);
+ Log.info(
+ chalk.blue('remotion render') +
+ chalk.gray(' <entry-point.ts> <comp-id> <output-file.mp4>'),
+ );
+ Log.info('Render video, audio or an image sequence.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/render'));
+
Log.info();
- Log.info('remotion compositions <index-file.ts>');
- Log.info(chalk.gray('Prints the available compositions.'));
+ Log.info(
+ chalk.blue('remotion still') +
+ chalk.gray(' <entry-point.ts> <comp-id> <still.png>'),
+ );
+ Log.info('Render a still frame and save it as an image.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/still'));
+
Log.info();
- Log.info('remotion benchmark <index-file.ts> <list-of-compositions>');
Log.info(
- chalk.gray(
- 'Benchmarks rendering a composition. Same options as for render.',
- ),
+ chalk.blue('remotion compositions') + chalk.gray(' <index-file.ts>'),
);
+ Log.info('Prints the available compositions.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/compositions'));
+
Log.info();
- Log.info('remotion ' + VERSIONS_COMMAND);
Log.info(
- chalk.gray('Prints and validates versions of all Remotion packages.'),
+ chalk.blue('remotion benchmark') +
+ chalk.gray(' <index-file.ts> <list-of-compositions>'),
);
+ Log.info('Benchmarks rendering a composition. Same options as for render.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/benchmark'));
+
Log.info();
- Log.info('remotion upgrade');
- Log.info(chalk.gray('Ensure Remotion is on the newest version.'));
- printFlags([
- [
- '--package-manager',
- 'Force a specific package manager, defaults to use from lockfile',
- ],
- ]);
+ Log.info(chalk.blue('remotion ' + VERSIONS_COMMAND));
+ Log.info('Prints and validates versions of all Remotion packages.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/versions'));
+ Log.info();
+ Log.info(chalk.blue('remotion ' + GPU_COMMAND));
+ Log.info('Prints information about how Chrome uses the CPU.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/gpu'));
+
+ Log.info();
+ Log.info(chalk.blue('remotion upgrade'));
+ Log.info('Ensure Remotion is on the newest version.');
+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/upgrade'));
+
Log.info();
Log.info(
'Visit https://www.remotion.dev/docs/cli for browsable CLI documentation.',
diff --git a/packages/docs/docs/cli/gpu.md b/packages/docs/docs/cli/gpu.md
new file mode 100644
index 0000000000..03fb887f8d
--- /dev/null
+++ b/packages/docs/docs/cli/gpu.md
@@ -0,0 +1,34 @@
+---
+crumb: CLI Reference
+sidebar_label: gpu
+title: npx remotion gpu
+---
+
+_Available from Remotion v4.0.52_
+
+Prints out how the Chrome browser uses the GPUs.
+
+```bash
+npx remotion gpu
+```
+
+```bash title="Example output"
+Canvas: Hardware accelerated
+Canvas out-of-process rasterization: Enabled
+Direct Rendering Display Compositor: Disabled
+Compositing: Hardware accelerated
+Multiple Raster Threads: Enabled
+OpenGL: Enabled
+Rasterization: Hardware accelerated
+Raw Draw: Disabled
+Skia Graphite: Disabled
+Video Decode: Hardware accelerated
+Video Encode: Hardware accelerated
+WebGL: Hardware accelerated
+WebGL2: Hardware accelerated
+WebGPU: Hardware accelerated
+```
+
+The output should not be used for automated parsing, as it may change inbetween any Remotion and Chrome versions.
+
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/cli/src/gpu.ts)
diff --git a/packages/docs/docs/cli/versions.md b/packages/docs/docs/cli/versions.md
index 3936b22571..7ca4d2992e 100644
--- a/packages/docs/docs/cli/versions.md
+++ b/packages/docs/docs/cli/versions.md
@@ -30,3 +30,7 @@ On version: 3.0.19
✅ Great! All packages have the same version.
```
+
+## See also
+
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/cli/src/versions.ts)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 7eca18828a..960b89db18 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -54,6 +54,7 @@ module.exports = {
"cli/upgrade",
"cli/ffmpeg",
"cli/ffprobe",
+ "cli/gpu",
"cli/help",
],
},
diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.ts
index 85243d408c..837acc6e4b 100644
--- a/packages/renderer/src/index.ts
+++ b/packages/renderer/src/index.ts
@@ -67,6 +67,7 @@ import {internalRenderStill} from './render-still';
import {internalSelectComposition} from './select-composition';
import {isPathInside} from './serve-handler/is-path-inside';
import {serveStatic} from './serve-static';
+import {getChromiumGpuInformation} from './test-gpu';
import {tmpDir} from './tmp-dir';
import {
getMaxConcurrency,
@@ -217,6 +218,7 @@ export const RenderInternals = {
validOpenGlRenderers,
copyImageToClipboard,
isIpV6Supported,
+ getChromiumGpuInformation,
};
// Warn of potential performance issues with Apple Silicon (M1 chip under Rosetta)
diff --git a/packages/renderer/src/test-gpu.ts b/packages/renderer/src/test-gpu.ts
new file mode 100644
index 0000000000..7b0ffd87d9
--- /dev/null
+++ b/packages/renderer/src/test-gpu.ts
@@ -0,0 +1,63 @@
+import type {BrowserExecutable} from './browser-executable';
+import {getPageAndCleanupFn} from './get-browser-instance';
+import type {LogLevel} from './log-level';
+import type {ChromiumOptions} from './open-browser';
+import {puppeteerEvaluateWithCatch} from './puppeteer-evaluate';
+
+type Item = {
+ feature: string;
+ status: string;
+};
+
+export const getChromiumGpuInformation = async ({
+ browserExecutable,
+ indent,
+ logLevel,
+ chromiumOptions,
+}: {
+ browserExecutable: BrowserExecutable;
+ indent: boolean;
+ logLevel: LogLevel;
+ chromiumOptions: ChromiumOptions;
+}) => {
+ const {page, cleanup} = await getPageAndCleanupFn({
+ passedInInstance: undefined,
+ browserExecutable,
+ chromiumOptions,
+ context: null,
+ forceDeviceScaleFactor: undefined,
+ indent,
+ logLevel,
+ });
+
+ await page.goto({url: 'chrome://gpu', timeout: 12000});
+
+ const {value} = await puppeteerEvaluateWithCatch<Item[]>({
+ pageFunction: (): Item[] => {
+ const statuses: Item[] = [];
+
+ const items = document
+ .querySelector('info-view')
+ ?.shadowRoot?.querySelector('ul')
+ ?.querySelectorAll('li');
+
+ [].forEach.call(items, (item: HTMLLIElement) => {
+ // do whatever
+ const [feature, status] = item.innerText.split(': ');
+ statuses.push({
+ feature,
+ status,
+ });
+ });
+
+ return statuses;
+ },
+ frame: null,
+ args: [],
+ page,
+ });
+
+ cleanup();
+
+ return value;
+};