@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 12 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 | 𝕏
|
|
||
| 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>
9078cf9 to
a84d90a
Compare
- Tighten encoder probe regex with word-boundary match to prevent false positives - Throw clear error for h264-mkv/h264-ts with hardwareAcceleration: 'required' - Add Windows NVENC test cases (required, CRF fallback) - Add unit tests for probe-encoder.ts (resolveHardwareAcceleration)
Remove compositor module mocks that caused /fake/ffmpeg to leak into other renderer tests. Only test code paths that short-circuit before FFmpeg probing (disable, audio codecs, software encoder passthrough).
- Escape regex metacharacters in encoderName before embedding in RegExp - Throw clear error for prores + required on Linux/Windows (consistent with h264-mkv/h264-ts) - Update prores test to expect throw instead of software fallback
|
Hi @JonnyBurger, quick update on the blocking item: rust-ffmpeg-splitter PR #17 (remotion-dev/rust-ffmpeg-splitter#17) is merged and now includes NVENC for both Linux and Windows builds. However, the Remotion compositor binaries still need to be rebuilt from the updated rust-ffmpeg source. Current status:
I verified NVENC works on my local Windows machine (RTX 4060) using system FFmpeg:
Would you be able to trigger a compositor binary rebuild when you get a chance? That should be the last step before this PR is ready for final review. |
There was a problem hiding this comment.
Caution
This branch contains ~8,000 files of committed agent-session state (.omc/) and a Python virtual environment (.venv/). These directories must be removed and added to .gitignore before merge.
Reviewed changes — adds NVENC hardware encoding for H.264/H.265 on Linux/Windows with FFmpeg encoder availability probing for automatic fallback.
- NVENC encoder selection in
getCodecName—h264_nvencandhevc_nvencforh264/h265onlinux/win32when hardware acceleration is requested and quality options (CRF, bitrate caps) aren't set probe-encoder.ts— new module withprobeEncoderAvailability()(sync FFmpeg-encodersprobe with proper regex escaping) andresolveHardwareAcceleration()(dispatches probing, falls back todisableforif-possible, throws forrequired)- Wiring into
stitch-frames-to-video.tsandprespawn-ffmpeg.ts— both paths resolve hardware acceleration via the probe before generating FFmpeg args - Clearer errors for unsupported codecs —
h264-mkv,h264-ts, andproreson non-macOS now throw whenhardwareAccelerationisrequired - Updated compositor binaries — rebuilt Rust FFmpeg binaries across all platform targets
- Docs — updated encoding codec tables and hardware acceleration prerequisites for NVENC
- 27 unit tests across
get-codec-name.test.tsandprobe-encoder.test.ts
🚨 .omc/ and .venv/ directories committed
The branch includes .omc/ (OpenCode agent session state: JSON snapshots, Python analysis scripts, serialized replay logs, PNG figures) and .venv/Lib/site-packages/PIL/ (a complete Python virtualenv with 2,900+ .py/.pyc files, plus matplotlib, contourpy, fontTools, and dateutil). These are unrelated to NVENC and account for nearly all of the 8,120 changed files and 1.8M additions.
Technical details
# `.omc/` and `.venv/` directories committed
## Affected sites
- `.omc/` directory — ~23 files (JSON state snapshots, Python scripts, PNG figures)
- `.venv/` directory — ~2,900+ files (Python virtualenv: Pillow, matplotlib, fontTools, contourpy, cycler, dateutil)
None of these files are referenced by the NVENC implementation.
## Required outcome
- Remove both directories from the branch: `git rm -r .omc .venv`
- Add `.omc/` and `.venv/` entries to `.gitignore` (or a local `.gitignore`)
- Amend commits to exclude these directories from the PR's history
## Open questions for the human
- Do `.omc/` and `.venv/` exist in the root `.gitignore`? If not, should entries be added for one or both?ℹ️ Documentation version reference
The hardware-acceleration.mdx page still says "H.264 and H.265 are supported from v4.0.236" on the bullet point for existing VideoToolbox support. The NVENC support added here should mention the version in which it becomes available.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
CI Status Update (commit
|
| Job | Status | Notes |
|---|---|---|
| Ubuntu (Node 16) | ✅ | Fixed! Was previously failing due to bun test runner crash |
| macOS (Node 25) | ✅ | Pass |
| SSR + Monorepo checks | ✅ | Pass |
| Browser tests | ✅ | Pass |
| Web renderer tests | ✅ | Pass |
| Lambda integration | ✅ | Pass |
| Linting + Formatting | ✅ | Pass |
| Template tests precheck | ✅ | Pass |
| Windows (Node 16) | ❌ | Pre-existing: Compositor exited with code 3221225785 (0xC0000135 = DLL not found). Fails in bundle-renderer.test.ts — not related to NVENC code |
| macOS (Node 25) | ❌ | Pre-existing: Flaky TypeError: Failed to fetch in integration tests. All 326 renderer tests actually pass (0 fail) |
Windows failure detail: The compositor binary (avcodec-61.dll or dependency) cannot load on the CI runner. This error exists on the main branch as well and is a known Windows compositor binary issue. All NVENC-related unit tests (probe-encoder.test.ts + get-codec-name.test.ts) pass with 0 failures across all platforms.

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)