Record Gameplay with FFmpeg NVENC Low Latency

Recording gameplay without sacrificing system performance or introducing input lag requires hardware-level acceleration. This guide explains how to capture high-framerate PC gameplay using FFmpeg combined with NVIDIA’s NVENC encoder. By leveraging low-latency encoding presets and the Windows Desktop Duplication API, you can produce high-quality video files with virtually zero impact on your game's responsiveness.

Prerequisites

To use this configuration, ensure you have:

  • A modern NVIDIA graphics card (GeForce GTX 600 series or newer).
  • Up-to-date NVIDIA display drivers.
  • A recent build of FFmpeg with NVENC support enabled (available by default in most standard community builds like Gyan.dev).

The Low-Latency Recording Command

Open your terminal or command prompt and run the following command to record your primary display at 60 FPS:

ffmpeg -f lavfi -i ddagrab=framerate=60:draw_mouse=1 -c:v h264_nvenc -preset p1 -tune ull -rc constqp -qp 20 -pix_fmt yuv420p output.mp4

To stop recording, press q or Ctrl + C in the command prompt window.

Command Breakdown

  • -f lavfi -i ddagrab=framerate=60:draw_mouse=1: Uses the Desktop Duplication API (DirectX) instead of standard GDI capture. This allows FFmpeg to capture full-screen DirectX and Vulkan games directly from GPU memory with minimal latency.
  • -c:v h264_nvenc: Invokes NVIDIA's dedicated hardware video encoder, taking the encoding workload off the CPU.
  • -preset p1: Selects the fastest encoding preset (presets range from p1 for fastest to p7 for highest quality). p1 minimizes processing time per frame.
  • -tune ull: Specifies the "Ultra-Low Latency" tuning mode, which disables features like B-frames and lookahead that would otherwise buffer frames and increase latency.
  • -rc constqp -qp 20: Employs Constant Quantization Parameter mode. Unlike fixed-bitrate modes, Constant QP provides consistent visual quality for local recording without wasting processing time on complex rate-control calculations. Values between 18 and 23 offer a balance of high quality and reasonable file size.
  • -pix_fmt yuv420p: Converts the pixel format to standard 4:2:0 chroma subsampling, ensuring the resulting MP4 file plays smoothly across all media players and video editors.

Adding In-Game Audio

To record desktop audio alongside the video feed, use the DirectShow audio capture interface:

  1. Identify your default audio device:

    ffmpeg -list_devices true -f dshow -i dummy
  2. Include the audio input in your final command:

    ffmpeg -f lavfi -i ddagrab=framerate=60:draw_mouse=1 -f dshow -i audio="Your Stereo Mix Name" -c:v h264_nvenc -preset p1 -tune ull -rc constqp -qp 20 -c:a aac -b:a 192k -pix_fmt yuv420p output.mp4

This configuration ensures the video stream is encoded directly on the GPU using dedicated silicon, maintaining high frame rates in game while capturing smooth video output.