Skip to content

Use NVENC in FFmpeg

Hardware acceleration can significantly speed up video encoding compared to CPU-based software encoders. One of the most popular hardware encoders is NVENC from NVIDIA. It’s available on most modern NVIDIA GPUs and can be used in FFmpeg.


🔍 Step 1. Check Available Hardware Accelerators

Terminal window
ffmpeg -hwaccels

Look for cuda or nvdec in the list.


🧩 Step 2. Check Available Encoders

Terminal window
ffmpeg -encoders | findstr h264

Look for h264_nvenc in the output.


⚙️ Step 3. Check Encoder Options

Terminal window
ffmpeg -h encoder=h264_nvenc

▶️ Step 4. Basic NVENC Encoding Example

Terminal window
ffmpeg -hwaccel cuda -i source.mp4 -c:v h264_nvenc -cq 23 -r 30 encoded.mp4
  • -hwaccel cuda — enables CUDA hardware acceleration for decoding.

  • -c:v h264_nvenc — encodes video using NVENC (NVIDIA’s hardware video encoder).

  • -cq 23 — sets the quality level (similar to -crf in x264, but with a different scale).

  • -r 30 — sets the output frame rate to 30 frames per second.


🚀 Advanced Example

Terminal window
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i ${i} \
-c:v h264_nvenc -profile:v high -level 4.0 -preset p7 \
-b:v 0 -cq 23 -c:a copy ${o}

-hwaccel_output_format cuda — decoding and storing frames in GPU memory (avoids PCIe transfer).

-profile:v high -level 4.0 — sets the H.264 profile suitable for 1080p.

-preset p7 — one of the slowest but highest-quality NVENC presets.

-b:v 0 -cq 23 — uses Constant Quality mode (CQ), where cq=23 provides a balance between quality and file size.

-c:a copy — copies the audio stream without re-encoding.


ℹ️ Tips

  • NVENC is faster than CPU encoding, but may result in slightly lower quality.
  • No real 2-pass support or precise bitrate control.
  • NVENC support depends on your GPU model.