The Production FFmpeg Cookbook: NVENC vs QuickSync vs Software, With Real Command Lines

Copy-paste encoding recipes tested in production — hardware transcode matrices, two-pass rate control, film grain preservation, and the flags that actually matter.

FFmpeg tutorials online optimize for tutorial-views, not production outcomes. After running thousands of transcodes across our pipeline, these are the recipes that survived contact with real content, real hardware, and real deadlines.

The Hardware Transcoding Matrix

Encoder        │ Throughput (1080p60) │ Quality/bit │ Best Use
───────────────┼──────────────────────┼─────────────┼──────────────────────────
libx264 medium │        1.0×          │  ★★★★★      │ Archival, premium tier
libx265 slow   │        0.4×          │  ★★★★★+     │ High-value assets
NVENC (RTX)    │        8.5×          │  ★★★☆       │ Live, near-live, scale
QuickSync      │        6.2×          │  ★★★        │ Intel-heavy fleets
libsvt-av1 P8  │        1.8×          │  ★★★★☆      │ Modern efficiency default

Recipe 1: Production x264 (the boring, correct baseline)

ffmpeg -i input.mp4 \
  -c:v libx264 -preset medium -crf 20 \
  -profile:v high -level 4.1 \
  -pix_fmt yuv420p \
  -x264-params keyint=120:min-keyint=60 \
  -c:a aac -b:a 160k \
  -movflags +faststart \
  output.mp4

Why these flags: -movflags +faststart relocates the moov atom for instant progressive playback, keyint=120 aligns with 4-second segment boundaries at 30fps, yuv420p guarantees decode on every device ever made.

Recipe 2: NVENC at Scale

ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \
  -c:v h264_nvenc -preset p5 -rc vbr -cq 23 \
  -b:v 0 -maxrate 6M -bufsize 12M \
  -spatial_aq 1 -temporal_aq 1 -rc-lookahead 20 \
  -c:a copy output.mp4

The critical knobs: -spatial_aq and -temporal_aq (adaptive quantization) close most of NVENC’s quality gap vs software, and -rc-lookahead gives the rate controller frame context. Without them, hardware encode quality craters.

Recipe 3: SVT-AV1 Balanced Production

ffmpeg -i input.mp4 \
  -c:v libsvtav1 -preset 8 -crf 32 \
  -svtav1-params tune=0:film-grain=8 \
  -c:a libopus -b:a 96k \
  output.mkv

film-grain=8 is the sleeper flag — it denoises pre-encode and synthesizes grain at decode, rescuing otherwise-destroyed film grain at a fraction of the bitrate.

Two-Pass Encoding: When It’s Worth It

CRF is better for archives; two-pass ABR is better when you must hit a bitrate ceiling (CDN cost tiers, player compatibility):

# Pass 1: analysis only
ffmpeg -i input.mp4 -c:v libx264 -preset slow -b:v 4M -pass 1 -an -f null /dev/null
# Pass 2: encode with stats
ffmpeg -i input.mp4 -c:v libx264 -preset slow -b:v 4M -pass 2 -c:a aac -b:a 160k output.mp4

All tested settings, quality-per-watt tables, and edge cases at Production FFmpeg Cookbook & Hardware Transcoding Matrix.