Skip to content

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

Merged
JonnyBurger merged 4 commits into
mainfrom
jonnyburger/pr-16-circleci
Jun 2, 2026
Merged

Add NVENC (h264_nvenc, hevc_nvenc) encoder support for Linux builds#17
JonnyBurger merged 4 commits into
mainfrom
jonnyburger/pr-16-circleci

Conversation

@JonnyBurger

Copy link
Copy Markdown
Member

This PR copies the changes from #16 so CircleCI runs on a branch owned by a maintainer account.\n\nOriginal PR: #16

@willy-scr

Copy link
Copy Markdown
Contributor

Hi @JonnyBurger, I noticed the CircleCI Linux builds failed on this PR (build-linux-x64-gnu, build-linux-x64-musl, build-linux-arm-gnu, build-linux-arm-musl all failed).

I can't access the CircleCI logs directly — could you share what the error was?

My best guess is either:

  1. nv-codec-headers git clone failed in the Docker container
  2. make install PREFIX=remotion failed (maybe needs SUDO or different make flags)
  3. FFmpeg configure couldn't find the ffnvcodec pkg-config file

Happy to fix once I know the error!

@willy-scr

Copy link
Copy Markdown
Contributor

The CI build fails because compile-nvenc.mjs references a non-existent tag:

const NV_CODEC_HEADERS_TAG = "n12.2.16.0";

Tag n12.2.16.0 does not exist in FFmpeg/nv-codec-headers. Fix:

- const NV_CODEC_HEADERS_TAG = "n12.2.16.0";
+ const NV_CODEC_HEADERS_TAG = "n12.2.72.0";

n12.2.72.0 is the latest 12.x release, compatible with FFmpeg n7.1.

Already fixed on my fork's branch (willy-scr:feature/nvenc) — see commit 935216f.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@willy-scr

Copy link
Copy Markdown
Contributor

@JonnyBurger This PR is ready to merge — all 6 CI checks are passing and mergeable_state is clean.

As noted in remotion-dev/remotion#7733, the rebuilt binary has --enable-encoder=h264_nvenc in the config string but the actual NVENC encoders are missing from libavcodec.so because the nv-codec-headers tag was still broken when the binary was built. Merging this PR first and then rebuilding the binaries should fix that.

The previous `make install PREFIX=remotion` ran with cwd=nv-codec-headers,
so headers were installed into nv-codec-headers/remotion/, not the
top-level ./remotion/ that FFmpeg's PKG_CONFIG_PATH points at. As a
result pkg-config could not find ffnvcodec.pc and FFmpeg silently
disabled h264_nvenc and hevc_nvenc with:

  WARNING: Disabled h264_nvenc_encoder because not all dependencies are satisfied: nvenc
  WARNING: Disabled hevc_nvenc_encoder because not all dependencies are satisfied: nvenc

Use an absolute install prefix so the headers land where FFmpeg looks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JonnyBurger

Copy link
Copy Markdown
Member Author

Findings from the artifact size comparison:

Target /zips pr17-binaries Delta
aarch64-unknown-linux-gnu.gz 6,826,509 7,043,212 +216,703
aarch64-unknown-linux-musl.gz 8,520,339 8,744,103 +223,764
x86_64-unknown-linux-gnu.gz 10,084,581 10,302,516 +217,935
x86_64-unknown-linux-musl.gz 10,418,370 10,633,345 +214,975
x86_64-pc-windows-gnu.gz 10,982,127 10,981,932 -195

Conclusion: Linux got bigger, Windows did not.

Implemented changes in build scripts:

  1. Enable NVENC for Windows cross-builds too (so Windows should now reflect the same feature addition/size impact).
  2. Exclude NVENC from Linux ARM64 builds (both GNU and musl), so arm64 targets do not carry this addition.

Technically this is now gated as: enable NVENC when running on Linux and either building Windows (windows target) or non-ARM64 Linux; skip on native Linux ARM64.

Enable NVENC on Windows cross-builds while excluding Linux ARM64 targets so ARM artifacts stay smaller.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@willy-scr

Copy link
Copy Markdown
Contributor

Looks good! The renderer code in remotion#7733 already handles both Linux and Windows NVENC selection (process.platform === 'linux' || process.platform === 'win32'), so enabling NVENC for Windows cross-builds here will work seamlessly.

The ARM64 exclusion makes sense — our probing logic (probe-encoder.ts) will simply not find NVENC encoders on ARM64 binaries and gracefully fall back to software encoding via the if-possible mode. No code changes needed on our side.

@JonnyBurger JonnyBurger merged commit c685428 into main Jun 2, 2026
8 checks passed
@JonnyBurger

Copy link
Copy Markdown
Member Author

✅ Merged! Binary sizing verified:

  • aarch64 Linux now correctly smaller (excluded NVENC)
  • x86_64 Linux includes NVENC ✓
  • x86_64 Windows includes NVENC ✓

This improvement is proceeding in the Remotion main repository. Thanks for the collaboration!

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