@remotion/renderer: Add NVENC hardware encoding for H.264/H.265 on Linux/Windows#7733
@remotion/renderer: Add NVENC hardware encoding for H.264/H.265 on Linux/Windows#7733willy-scr wants to merge 5 commits into
@remotion/renderer: Add NVENC hardware encoding for H.264/H.265 on Linux/Windows#7733Conversation
There was a problem hiding this comment.
Important
The docs update introduces a broken markdown code block that will render the rest of the article incorrectly. Please fix before merging.
Reviewed changes — Added NVENC hardware encoding support for H.264/H.265 on Linux/Windows, following the existing VideoToolbox pattern.
- Add NVENC encoder selection in
get-codec-name.tsforh264andh265onlinux/win32 - Add 22 test cases in
get-codec-name.test.tscovering macOS regression, NVENC on Linux/Windows, unsupported codecs, software fallback, and audio codecs - Update docs in
hardware-acceleration.mdxandencoding.mdxto reflect NVENC support
Kimi K2 | 𝕏
| ``` | ||
| Encoder: prores_videotoolbox, hardware accelerated: true | ||
| ``` | ||
| Encoder: h264_nvenc, hardware accelerated: true |
There was a problem hiding this comment.
|
|
||
| test('h264 + linux + hwaccel:if-possible + crf=20 falls back to software', () => { | ||
| setPlatform('linux'); | ||
| expect( |
There was a problem hiding this comment.
ℹ️ The (NEW - will fail) label in the describe block name is a development note that should be removed now that the implementation is in place and these tests pass.
| }); | ||
| }); | ||
|
|
||
| describe('getCodecName - No hardware acceleration for unsupported codecs', () => { |
There was a problem hiding this comment.
ℹ️ Same as above — remove the (NEW - will fail) label from the describe block name.
|
Quick question about the NVENC setup: When you tested this, did you specify a custom FFmpeg binary via |
|
@JonnyBurger Yes, you're correct — the successful NVENC render test used a custom That's exactly why I also opened remotion-dev/rust-ffmpeg-splitter#16 — it adds The two PRs work together:
Once both are merged, NVENC will work out-of-the-box on Linux machines with NVIDIA GPUs. The probing logic ( |
4c1995c to
7b5c932
Compare
|
Deployment failed with the following error: |
|
@willy-scr I rebuilt the compositor binaries for all platforms with the updated rust-ffmpeg. Could you test this again now without overriding Remotion with a custom FFmpeg binary? |
0ed76ad to
b955a7d
Compare
|
@JonnyBurger I tried to test with the bundled FFmpeg, but the current Also, the monorepo build is currently broken on main ( I verified NVENC works on my RTX 4060 using the system FFmpeg: Could you confirm: was the new binary with NVENC published to npm? Or does it need a version bump to pull the update? |
|
No, we're not pushing to npm yet, the idea would be that you check out the PR in it's current state.. If you are getting a build error, it might be a cache issue, try running the clean script and be precise in following the instructions: https://www.remotion.dev/docs/contributing#setup |
|
@JonnyBurger I did a clean build ( I also checked the alpha channel ( The monorepo build errors I'm seeing ( Could you point me to the right binary/version? Or should I wait for the rust-ffmpeg-splitter merge to propagate? |
|
@JonnyBurger I did a full clean ( The compositor binary at The binary's BuildID is |
|
@willy-scr the rebuilt binaries are now on this PR branch again at the latest head commit. They are not published to npm, and checking @remotion/compositor-linux-x64-gnu@4.0.469 or the alpha package will not test this change. Please check out this PR branch itself and test the bundled binary from the workspace, for example: gh pr checkout 7733
LD_LIBRARY_PATH=packages/compositor-linux-x64-gnu packages/compositor-linux-x64-gnu/ffmpeg -encoders | grep nvencThen run your Remotion test without binariesDirectory / custom FFmpeg so we can verify this PR works with the bundled FFmpeg. |
…Linux/Windows - h264 + linux/win32 + hwaccel -> h264_nvenc - h265 + linux/win32 + hwaccel -> hevc_nvenc - Follows same pattern as existing macOS VideoToolbox support - Users need NVIDIA GPU + drivers; FFmpeg fails naturally if unavailable - Use --video-bitrate for quality control (CRF not supported with hw accel) - Updated hardware-acceleration and encoding docs - Added 22 tests covering all encoder selection paths
…eleration Probe FFmpeg binary for encoder availability before selecting NVENC. If encoder not available in FFmpeg build: - 'if-possible' mode: gracefully falls back to software encoding - 'required' mode: throws clear error message This handles the case where bundled FFmpeg lacks NVENC support.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6c0f783 to
47a8b9d
Compare

Summary
Add NVENC (NVIDIA hardware encoding) support for H.264 and H.265 codecs on Linux and Windows, including FFmpeg encoder availability probing for automatic fallback.
✅ End-to-end verified with NVENC (RTX 4060, Linux)
Changes
Core implementation
packages/renderer/src/get-codec-name.ts— Added NVENC encoder selection for Linux/Windowspackages/renderer/src/probe-encoder.ts— NEW: Encoder availability probingprobeEncoderAvailability()— Probes FFmpeg binary for specific encoderresolveHardwareAcceleration()— Resolves effective hw accel settingpackages/renderer/src/stitch-frames-to-video.ts— Probes before generating FFmpeg argspackages/renderer/src/prespawn-ffmpeg.ts— Same probe for pre-spawn pathpackages/renderer/src/test/get-codec-name.test.ts— 22 test casespackages/docs/docs/hardware-acceleration.mdx— Updated platforms + prerequisitespackages/docs/docs/encoding.mdx— Updated codec tablesUsage
How it works
ffmpeg -encoders) to check if the selected hw encoder existsif-possiblemode: if encoder missing → silently falls back to software encodingrequiredmode: if encoder missing → throws clear errordisablemode: no probing, always softwarePrerequisites for NVENC
binariesDirectory)