C.W.K.
Stream
Lesson 05 of 10 · published

Hardware Encoding — VideoToolbox, NVENC, QSV

~12 min · hardware, videotoolbox, nvenc, speed

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

The speed/quality tradeoff is real

Modern GPUs and SoCs include dedicated silicon for video encoding: VideoToolbox (Apple Silicon), NVENC (NVIDIA), QuickSync (Intel iGPU), AMF (AMD), V4L2-M2M (Raspberry Pi). They're 5–20× faster than CPU encoders. They're also slightly less efficient — at the same bitrate, hardware H.264 typically scores 1–3 VMAF points lower than libx264 -preset slow.

Apple Silicon — the standout

VideoToolbox on M-series Macs is unusually good. Real-time 4K HEVC encode on an M3 Pro. The H.264 encoder is fine, the HEVC encoder is great, ProRes encoding is hardware-accelerated too. For most 'I want to upload this to YouTube tonight' workflows on a Mac, hardware is the right answer.

The flag pattern

Hardware encoders use bitrate (-b:v) almost exclusively — they ignore or only loosely respect CRF. Some support 'constrained quality' modes (-q:v on h264_nvenc and recent VideoToolbox builds). Use the bitrate-target pattern.

Code

Hardware encoder cheatsheet·bash
# Apple Silicon — H.264 (1080p)
ffmpeg -i in.mp4 -c:v h264_videotoolbox -b:v 6M \
  -c:a aac -b:a 192k -movflags +faststart out.mp4

# Apple Silicon — HEVC (1080p, smaller file)
ffmpeg -i in.mp4 -c:v hevc_videotoolbox -b:v 4M -tag:v hvc1 \
  -c:a aac -b:a 192k -movflags +faststart out_h265.mp4

# NVIDIA — H.264
ffmpeg -i in.mp4 -c:v h264_nvenc -preset p5 -cq 22 \
  -c:a aac -b:a 192k -movflags +faststart out.mp4

# NVIDIA — HEVC
ffmpeg -i in.mp4 -c:v hevc_nvenc -preset p5 -cq 24 \
  -c:a aac -b:a 192k -movflags +faststart -tag:v hvc1 out.mp4
Pure-GPU pipeline (decode + encode in hardware)·bash
# Frames stay in GPU memory throughout. Fastest possible path.
ffmpeg -hwaccel videotoolbox -i in.mp4 \
  -c:v hevc_videotoolbox -b:v 4M -tag:v hvc1 \
  -c:a copy out.mp4

# Same on NVIDIA
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i in.mp4 \
  -c:v hevc_nvenc -preset p5 -cq 24 -tag:v hvc1 \
  -c:a copy out.mp4

# Caveat: most filters force a download to CPU memory.
# A -vf scale=... in the middle erases the speed win.

External links

Exercise

On your machine, identify the hardware H.264 encoder and run a 60-second clip through three encodes: libx264 -preset slow -crf 20, libx264 -preset veryfast -crf 20, hardware_h264 -b:v 6M. Time each. The hardware one should be 3–10× faster than even -preset veryfast. Compare file sizes and visual quality — which is the 'right tool' for: (a) one master, (b) twenty daily clips?

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.