Skip to content

Add NVENC (h264_nvenc, hevc_nvenc) encoder support for Linux builds#16

Open
willy-scr wants to merge 2 commits into
remotion-dev:mainfrom
willy-scr:feature/nvenc
Open

Add NVENC (h264_nvenc, hevc_nvenc) encoder support for Linux builds#16
willy-scr wants to merge 2 commits into
remotion-dev:mainfrom
willy-scr:feature/nvenc

Conversation

@willy-scr
Copy link
Copy Markdown

@willy-scr willy-scr commented May 28, 2026

Summary

Add NVIDIA NVENC hardware encoder support (h264_nvenc, hevc_nvenc) to the FFmpeg build for Linux targets.

Changes

New file: compile-nvenc.mjs

  • Clones FFmpeg/nv-codec-headers (tag n12.2.16.0) and installs to PREFIX
  • Header-only — no library compilation, no runtime dependency at build time
  • Only runs on native Linux builds (process.platform === "linux" && !isWindows)

Modified: compile-ffmpeg.mjs

  • Import and call enableNvencHeaders(isWindows) alongside other enable* functions
  • Add --enable-encoder=h264_nvenc and --enable-encoder=hevc_nvenc to FFmpeg configure
  • Guarded by !isWindows && process.platform === "linux" — mirrors the existing VideoToolbox pattern for macOS

Platform impact

Platform NVENC Notes
Linux x86_64 glibc ✅ Enabled Desktop/server with NVIDIA GPUs
Linux x86_64 musl ✅ Enabled No GPU typically, but harmless
Linux x86_64 musl ✅ Enabled No GPU typically, but harmless
Linux ARM64 gnu (Lambda) ✅ Enabled No GPU, harmless
Linux ARM64 musl ✅ Enabled No GPU, harmless
Windows x86_64 ❌ Skipped Cross-compile complexity
macOS ❌ Skipped Uses VideoToolbox instead

How it works

  1. enableNvencHeaders() clones nv-codec-headers and installs to PREFIX/include/ffnvcodec/ + PREFIX/lib/pkgconfig/ffnvcodec.pc
  2. FFmpeg's configure auto-detects NVENC via pkg-config (ffnvcodec package)
  3. Since the build uses --disable-encoders + selective re-enable, we explicitly add --enable-encoder=h264_nvenc and --enable-encoder=hevc_nvenc
  4. At runtime, NVENC encoders are available if NVIDIA GPU + driver are present; they fail gracefully otherwise

Testing

@JonnyBurger
Copy link
Copy Markdown
Member

I copied this into #17 so CircleCI can run on a maintainer-owned branch. Once CI passes there, we can review/merge with confidence while preserving your original contribution.

@JonnyBurger
Copy link
Copy Markdown
Member

CircleCI failed on the copied PR: https://app.circleci.com/pipelines/github/remotion-dev/rust-ffmpeg-splitter/436/workflows/5e0302d6-46c8-4783-a298-afcbbab90b1c

Could you take a look and fix the failure? If CircleCI isn’t running for you yet, you may need to sign up for a free CircleCI account first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants