packages/docs/docs/hardware-acceleration.mdx
Encoding is the process of converting a sequence of images into a video file.
Besides rendering frames, encoding is one of the two steps required to create a video.
From Remotion v4.0.228, Remotion supports hardware-accelerated encoding in some cases.
Since encoding is platform- and codec-specific, only a few scenarios are supported at the moment.
By default, hardware acceleration is "disabled".
You can set the hardwareAcceleration option to "if-possible" to enable hardware acceleration if it is available.
If you want the render to fail if hardware acceleration is not possible, set the option to "required".
Use the hardwareAcceleration option in the renderMedia() function.
const serveUrl = '/path/to/bundle';
const outputLocation = '/path/to/frames';
import {renderMedia, selectComposition} from '@remotion/renderer';
const inputProps = {
titleText: 'Hello World',
};
const composition = await selectComposition({
serveUrl,
id: 'my-video',
inputProps,
});
// ---cut---
await renderMedia({
composition,
serveUrl,
codec: 'prores',
outputLocation,
inputProps,
hardwareAcceleration: 'if-possible',
});
Use the --hardware-acceleration option in the npx remotion render command.
npx remotion render MyComp --codec prores --hardware-acceleration if-possible
In the Remotion Studio, you can set the hardware acceleration option in the "Advanced" tab when rendering a video.
You can set the setHardwareAcceleration() option in the config file.
import {Config} from '@remotion/cli/config';
Config.setHardwareAcceleration('if-possible');
These options are not supported in Remotion Lambda and Cloud Run, because those cloud services do not support hardware acceleration.
To use hardware-accelerated encoding on Linux and Windows, you need:
h264_nvenc or hevc_nvenc encoder supportThe FFmpeg binaries bundled with Remotion include NVENC support on Linux x64 only. NVENC on Linux ARM64 is not supported. On Windows, point Remotion to an FFmpeg build that includes NVENC using --binaries-directory or binariesDirectory.
Set --hardware-acceleration if-possible and Remotion will use NVENC if the configured FFmpeg build supports it.
Note that NVENC encoding is only available for H.264 and H.265 codecs. Other codecs will fall back to software encoding.
--video-bitrateNote that the file size is significantly larger by default when using hardware acceleration, likely because less compression is applied.
We recommend that you use the --video-bitrate flag to control the file size.
We find that --video-bitrate=8M achieves a similar file size than software encoding when exporting a H.264 Full HD video.
The crf option is not compatible with hardware-accelerated encoders. Instead, use the --video-bitrate flag to control the quality and file size of the output video.
Run the render with verbose logging. If the render is using hardware acceleration, you will see a log message like this:
Encoder: prores_videotoolbox, hardware accelerated: true
Encoder: h264_nvenc, hardware accelerated: true
Don't rely on the exact wording of the log message to determine if hardware acceleration is being used.