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

Hardware Acceleration — When and Why

~10 min · hardware, videotoolbox, nvenc, qsv

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

The fast lane is real, but it has tolls

Modern GPUs and SoCs ship dedicated silicon for video encode/decode: VideoToolbox on Apple Silicon, NVENC/NVDEC on NVIDIA, QuickSync on Intel iGPU, AMF on AMD, V4L2-M2M on Raspberry Pi. They're 5–20× faster than CPU encoders. They're also less efficient per bit — at the same bitrate, hardware-encoded H.264 looks slightly worse than libx264 at -preset slow.

You take that trade when speed matters more than the last 5% of quality: live streaming, batch transcoding overnight queues, screen recording where the GPU is doing capture anyway, real-time AI video pipelines.

Apple Silicon — VideoToolbox

On M-series Macs the dedicated media engines absolutely scream. A 30-minute 4K clip transcodes to H.265 in roughly real time on an M3, vs ~10× longer with libx265 -preset slow. That's why every Final Cut export uses VideoToolbox.

How to invoke it

Hardware encode with -c:v <encoder_name>. Hardware decode (less common, only matters for live pipelines) with -hwaccel videotoolbox before -i. Track 8 lesson 'Apple Silicon Optimization' covers the full setup.

Code

Hardware H.265 on Apple Silicon·bash
# Encode with the dedicated media engine
ffmpeg -i input.mp4 \
  -c:v hevc_videotoolbox -b:v 6M -tag:v hvc1 \
  -c:a aac -b:a 192k \
  output.mp4

# Why -tag:v hvc1: makes the file play in QuickTime/Apple TV.
# The default 'hev1' tag is identical bytes but Apple won't play it.
Hardware encode + decode chained·bash
# Decode in hardware, encode in hardware — fully on the GPU
# (Frames stay in GPU memory; CPU touches very little)
ffmpeg -hwaccel videotoolbox \
  -i input.mp4 \
  -c:v hevc_videotoolbox -b:v 8M \
  -c:a copy \
  output.mp4

# Caveat: most filters don't run on GPU memory. Adding -vf scale=...
# forces a download to CPU, which negates the speed win.

External links

Exercise

Pick a 60-second 1080p clip. Encode it three ways: libx264 -preset slow -crf 20, libx264 -preset veryfast -crf 20, and h264_videotoolbox -b:v 6M. Compare wall-clock time and file size for each. Which one would you ship for: (a) a YouTube upload, (b) a master archive, (c) a 200-file batch overnight job?

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.