FFmpeg NVENC Hardware Acceleration 2026: GPU Encoding on FFmpeg 9.0

FFmpeg NVENC Hardware Acceleration 2026: GPU Encoding on FFmpeg 9.0

Software video encoding uses the CPU. It is slow, and it makes a 4K transcode take hours. Your NVIDIA GPU contains a separate chip for this exact job. That chip is NVENC, and FFmpeg can drive it directly.

This tutorial shows you how to encode with NVENC on FFmpeg 9.0. It covers the full GPU pipeline, the preset system, quality tuning, and one change that FFmpeg 9.0 introduced.

FFmpeg 9.0 removed deprecated NVENC options. The release also dropped support for Video Codec SDK versions before 11.1. If you upgrade from an older FFmpeg and your encode command fails, read the Migration section below first.

Prerequisites

  • An NVIDIA GPU with an NVENC chip. Most GTX 10-series cards and later include one.
  • The NVIDIA proprietary driver. The open-source Nouveau driver does not expose NVENC.
  • FFmpeg with the --enable-nvenc build flag.
  • Basic command-line experience.

Check your FFmpeg build first:

ffmpeg -encoders | grep nvenc

The command lists the available NVENC encoders. An empty result means your FFmpeg build lacks NVENC support. Install a full build, or compile FFmpeg with the flag above.

1. What FFmpeg 9.0 Changed

FFmpeg 9.0 carries the codename "Lei". The FFmpeg project released it on 4 August 2026, and it follows the project's roughly six-month major release cadence.

Two changes in this release affect GPU users directly:

ChangeEffect on you
Removal of deprecated NVENC optionsOld command lines can fail after an upgrade
End of support for pre-11.1 Video Codec SDKVery old drivers no longer work
New transpose_cuda filterYou can rotate video on the GPU
More Vulkan accelerationAPV decode and ProRes RAW gain hardware paths

The rest of the release focuses on other areas. It adds an animated WebP decoder, HE-AAC 960 decoding for DAB+, several AMD AMF filters, and an ONNX Runtime backend for the DNN filters.

2. The Three NVENC Encoders

NVIDIA documents three NVENC encoders for FFmpeg:

EncoderCodecTypical use
h264_nvencH.264Maximum compatibility. Every device plays it.
hevc_nvencHEVC / H.265Better compression at the same quality.
av1_nvencAV1Best compression. Needs an RTX 40-series card or later.

Start with h264_nvenc when you need the file to play anywhere. Choose hevc_nvenc when you want smaller files and you control the playback device.

A minimal encode looks like this:

ffmpeg -i input.mp4 -c:v h264_nvenc -b:v 5M output.mp4

This command decodes on the CPU and encodes on the GPU. The next section removes the CPU step.

3. The Full GPU Pipeline

The command above still moves every frame from GPU memory to system memory and back. That copy wastes time. NVIDIA documents two flags that keep the frames on the GPU:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
       -i input.mp4 \
       -c:v h264_nvenc -b:v 5M \
       output.mp4

-hwaccel cuda selects the GPU decoder. -hwaccel_output_format cuda keeps the decoded frames in GPU memory. NVIDIA states that this pair auto-detects the accelerated codec and holds video frames in GPU memory for the transcode.

Put both flags before -i. They configure the decoder, and the decoder starts when FFmpeg opens the input.

One limitation matters here. Most FFmpeg filters run on the CPU. A CPU filter forces a copy back to system memory and cancels the benefit. Use the CUDA filters, such as scale_cuda or the new transpose_cuda, to keep the pipeline on the GPU.

4. Presets: p1 to p7

NVENC replaced its old named presets with a numbered scale. NVIDIA's documentation uses p1 through p7. A low number encodes fast. A high number encodes well.

PresetSpeedUse it for
p1FastestLive streams on weak hardware
p2FastReal-time capture
p4MediumA sensible default
p6SlowArchive files and offline transcodes
p7SlowestMaximum quality per bit

Add a preset with -preset:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
       -i input.mp4 \
       -c:v hevc_nvenc -preset p6 -b:v 4M \
       output.mp4

NVIDIA also documents a -tune option. Use -tune hq for high quality. Use -tune ll for low latency, which suits live streams.

5. Quality Tuning

Bitrate alone gives you blunt control. NVENC exposes several options that spend bits where the eye notices them.

Adaptive quantization moves bits toward detailed regions. NVIDIA documents both a spatial and a temporal form:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
       -i input.mp4 \
       -c:v hevc_nvenc -preset p6 -tune hq \
       -spatial-aq 1 -aq-strength 8 \
       -temporal-aq 1 \
       -b:v 4M -maxrate 6M -bufsize 12M \
       output.mp4

Lookahead lets the encoder inspect future frames before it decides. Add -rc-lookahead 20 for offline encodes. Skip it for live work, because it adds latency.

B-frames improve compression. Set -bf 3 to allow three of them. NVIDIA also documents -b_ref_mode middle, which lets a B-frame act as a reference.

A complete archive-quality command combines these:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
       -i input.mkv \
       -c:v hevc_nvenc -preset p6 -tune hq \
       -rc-lookahead 20 -bf 3 -b_ref_mode middle \
       -spatial-aq 1 -aq-strength 8 -temporal-aq 1 \
       -b:v 6M -maxrate 9M -bufsize 18M -g 250 \
       -c:a copy \
       output.mkv

-c:a copy passes the audio through untouched. Audio encoding is cheap, but a copy is free.

6. Scale on the GPU

A CPU scale filter breaks the GPU pipeline. Use scale_cuda instead:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
       -i input4k.mp4 \
       -vf scale_cuda=1920:1080 \
       -c:v h264_nvenc -preset p4 -b:v 5M \
       output1080p.mp4

FFmpeg 9.0 adds transpose_cuda. It rotates video without a trip through system memory:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda \
       -i portrait.mp4 \
       -vf transpose_cuda=1 \
       -c:v h264_nvenc -preset p4 -b:v 5M \
       rotated.mp4

7. Migration From Older FFmpeg

FFmpeg 9.0 removed the deprecated NVENC options. An old command can fail with an unknown option error after you upgrade.

Follow these steps when that happens:

  1. Read the error. FFmpeg names the option that it no longer accepts.
  2. Remove that option from your command.
  3. Run the command again.
  4. Replace a removed quality option with the -preset p1p7 scale.

Check your driver as well. FFmpeg 9.0 dropped support for Video Codec SDK versions before 11.1. A very old driver no longer works, so update the driver if the encoder fails to open.

8. When Not to Use NVENC

NVENC is fast. It is not always the right choice.

  • You need the smallest possible file. A slow libx264 or libx265 CPU encode still beats NVENC on compression efficiency at the same bitrate.
  • You encode once and distribute widely. The extra CPU time costs you little, and every viewer benefits from the smaller download.
  • Your GPU lacks the codec. AV1 encoding needs an RTX 40-series card or later.

NVENC wins when speed matters: live streams, bulk transcodes, and any job where the CPU would take hours.

Quick Reference

TaskFlag
GPU decode-hwaccel cuda
Keep frames on the GPU-hwaccel_output_format cuda
H.264 encode-c:v h264_nvenc
HEVC encode-c:v hevc_nvenc
AV1 encode-c:v av1_nvenc
Quality preset-preset p1 to -preset p7
Quality tune-tune hq
Low-latency tune-tune ll
Spatial AQ-spatial-aq 1 -aq-strength 8
Temporal AQ-temporal-aq 1
Lookahead-rc-lookahead 20
GPU scale-vf scale_cuda=W:H
GPU rotate-vf transpose_cuda=1

Sources

Related Tutorials

Leonardo Lazzaro

Software engineer and technical writer. 10+ years experience in DevOps, Python, and Linux systems.

More articles by Leonardo Lazzaro