When to Use This Skill
Activate when GPU acceleration is needed:
- Encoding speed is critical (10-30x faster than CPU)
- Processing large batches of videos
- Real-time encoding for streaming
- Server-side transcoding at scale
- Docker containers with GPU passthrough
GPU encoding trades some quality for massive speed. Use -cq, -qp, or -global_quality for quality control.
Quick Reference
| Platform |
Encoder |
Decoder |
Detect Command |
| NVIDIA |
h264_nvenc, hevc_nvenc, av1_nvenc |
h264_cuvid, hevc_cuvid |
ffmpeg -encoders | grep nvenc |
| Intel QSV |
h264_qsv, hevc_qsv, av1_qsv |
h264_qsv, hevc_qsv |
ffmpeg -encoders | grep qsv |
| AMD AMF |
h264_amf, hevc_amf, av1_amf |
N/A (use software) |
ffmpeg -encoders | grep amf |
| Apple |
h264_videotoolbox, hevc_videotoolbox |
h264_videotoolbox |
macOS only |
| VAAPI |
h264_vaapi, hevc_vaapi, av1_vaapi |
with -hwaccel vaapi |
Linux only |
| Vulkan |
h264_vulkan, hevc_vulkan, av1_vulkan, ffv1_vulkan |
VP9, ProRes RAW (8.0+) |
ffmpeg -encoders | grep vulkan |
Current Latest: FFmpeg 8.0.1 (released 2025-11-20). Check with ffmpeg -version.
Hardware Acceleration Overview
Hardware acceleration uses dedicated GPU/SoC components for video processing:
- NVENC/NVDEC (NVIDIA): dedicated encode/decode engines
- QSV (Intel): Quick Sync Video on Intel CPUs with integrated graphics
- AMF (AMD): Advanced Media Framework for AMD GPUs
- VideoToolbox (Apple): macOS/iOS hardware acceleration
- VAAPI (Linux): Video Acceleration API (Intel, AMD on Linux)
- Vulkan Video (Cross-platform, FFmpeg 7.1+/8.0): compute-shader-based codecs
Performance Comparison (2025 Benchmarks)
| Method |
Speed |
Quality |
Power |
Use Case |
| libx264 (CPU) |
1x |
Best |
High |
Quality-critical |
| libx265 (CPU) |
0.3x |
Best |
Very High |
Archival |
| h264_nvenc |
10-20x |
Good |
Low |
Real-time, streaming |
| hevc_nvenc |
8-15x |
Good |
Low |
4K streaming |
| h264_qsv |
8-15x |
Good |
Very Low |
Laptop, efficiency |
| h264_amf |
8-15x |
Good |
Low |
AMD systems |
Core Workflow
- Detect what you have:
ffmpeg -hwaccels, ffmpeg -encoders | grep <api>
- Pick a backend: prefer the vendor-native one (NVENC on NVIDIA, QSV on Intel, AMF on AMD, VideoToolbox on Apple). Use Vulkan for cross-platform portability.
- Build a full-GPU pipeline where possible:
- Add
-hwaccel <api> and -hwaccel_output_format <api> before -i
- Use GPU-side filters (
scale_cuda, scale_vulkan, vpp_qsv, ...)
- Use the matching hardware encoder
- Tune quality:
-preset (NVENC p1-p7), -cq/-qp/-global_quality, lookahead, spatial/temporal AQ
- Verify: benchmark with
ffmpeg -benchmark and monitor GPU via nvidia-smi dmon, intel_gpu_top, etc.
Minimal Examples per Backend
# NVIDIA NVENC
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \
-c:v h264_nvenc -preset p4 -b:v 5M output.mp4
# Intel QSV
ffmpeg -hwaccel qsv -hwaccel_output_format qsv -i input.mp4 \
-c:v h264_qsv -preset medium -b:v 5M output.mp4
# AMD AMF
ffmpeg -i input.mp4 -c:v h264_amf -quality balanced -b:v 5M output.mp4
# Apple VideoToolbox
ffmpeg -i input.mp4 -c:v h264_videotoolbox -b:v 5M output.mp4
# Linux VAAPI
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
-hwaccel_output_format vaapi -i input.mp4 \
-c:v h264_vaapi -b:v 5M output.mp4
# Vulkan (cross-platform)
ffmpeg -init_hw_device vulkan -i input.mp4 \
-c:v h264_vulkan -b:v 5M output.mp4
Full GPU Pipeline Pattern (Critical)
ffmpeg -y -vsync 0 \
-hwaccel cuda -hwaccel_output_format cuda \
-i input.mp4 \
-vf scale_cuda=1280:720 \
-c:v h264_nvenc -preset p4 -b:v 5M \
-c:a copy \
output.mp4
Omitting -hwaccel_output_format can cut throughput by up to 50% because decoded frames silently round-trip through CPU memory. See references/gpu-memory-and-troubleshooting.md for memory flow diagrams and best practices.
Cross-Vendor Filter Quick Map
| Operation |
NVIDIA |
Intel |
AMD/Linux |
Cross-platform |
| Scale |
scale_cuda, scale_npp |
vpp_qsv, scale_qsv |
scale_vaapi |
scale_vulkan, scale_opencl, libplacebo |
| Overlay |
overlay_cuda |
- |
- |
overlay_vulkan, overlay_opencl |
| Deinterlace |
bwdif_cuda |
vpp_qsv |
deinterlace_vaapi |
bwdif_vulkan |
| Denoise |
bilateral_cuda |
- |
- |
nlmeans_vulkan, nlmeans_opencl |
| Chromakey |
chromakey_cuda |
- |
- |
colorkey_opencl |
| Tonemap (HDR->SDR) |
- |
- |
tonemap_vaapi |
libplacebo, tonemap_opencl |
| Pad/letterbox |
pad_cuda (8.0+) |
- |
- |
pad_opencl |
Use-Case Quick Recipes
Live streaming (low latency)
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input \
-c:v h264_nvenc -preset p3 -tune ll -zerolatency 1 -b:v 6M \
-f flv rtmp://server/live/stream
VOD (quality target)
ffmpeg -i input.mp4 \
-c:v hevc_nvenc -preset p6 -tune hq \
-rc vbr -cq 22 -b:v 0 \
-rc-lookahead 32 -spatial-aq 1 \
output.mp4
Batch / parallel encoding
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input1.mp4 -c:v h264_nvenc output1.mp4 &
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input2.mp4 -c:v h264_nvenc output2.mp4 &
wait
Docker (GPU passthrough)
docker run --gpus all --rm -v $(pwd):/data \
jrottenberg/ffmpeg:nvidia \
-hwaccel cuda -hwaccel_output_format cuda \
-i /data/input.mp4 -c:v h264_nvenc /data/output.mp4
Best Practices
- Use full GPU pipelines when possible to avoid CPU/GPU memory transfers
- Match decode and encode hardware for best performance
- Pick presets deliberately - faster is not always better for quality
- Enable lookahead and AQ for quality-critical encodes
- Test on target hardware - quality varies by GPU generation
- Monitor GPU memory for high-resolution content
- Consider power efficiency for laptops and servers
- Update drivers regularly for performance and feature improvements
Reference Map
For deep dives on each backend, see:
- NVIDIA NVENC/NVDEC (presets, CUDA filters, scale_npp, hybrid pipelines, two-pass, multi-GPU, 1:N ABR):
references/nvidia-nvenc.md
- Intel QSV (full pipeline, vpp_qsv, lookahead, multi-GPU, VVC decoding):
references/intel-qsv.md
- AMD AMF, VAAPI, Apple VideoToolbox (encoders, scaling, VVC VAAPI 8.0+ SCC support):
references/amd-amf-vaapi-videotoolbox.md
- Vulkan Video and Vulkan filters (h264/hevc/av1/ffv1, VP9/ProRes RAW decode, scale/overlay/blur/transitions/libplacebo):
references/vulkan.md
- OpenCL filters (scale, overlay, colorkey, nlmeans, deshake, unsharp, tonemap):
references/opencl-filters.md
- GPU memory management, filter comparison matrix, Docker, troubleshooting:
references/gpu-memory-and-troubleshooting.md
1---2name: ffmpeg-hardware-acceleration3description: Complete GPU-accelerated encoding/decoding system for FFmpeg 7.1 LTS and 8.0.1 (latest stable, released 2025-11-20). PROACTIVELY activate for: (1) NVIDIA NVENC/NVDEC encoding, (2) Intel Quick Sync Video (QSV), (3) AMD AMF encoding, (4) Apple VideoToolbox, (5) Linux VAAPI setup, (6) Vulkan Video 8.0 (FFv1, AV1, VP9, ProRes RAW), (7) VVC/H.266 hardware decoding (VAAPI/QSV), (8) GPU pipeline optimization with pad_cuda, (9) Docker GPU containers, (10) Performance benchmarking. Provides: Platform-specific commands, preset comparisons, quality tuning, full GPU pipeline examples, Vulkan compute codecs, VVC decoding, troubleshooting guides. Ensures: Maximum encoding speed with optimal quality using GPU acceleration.4---5
6## When to Use This Skill
7
8Activate when **GPU acceleration is needed**:
9
10- Encoding speed is critical (10-30x faster than CPU)
11- Processing large batches of videos
12- Real-time encoding for streaming
13- Server-side transcoding at scale
14- Docker containers with GPU passthrough
15
16GPU encoding trades some quality for massive speed. Use `-cq`, `-qp`, or `-global_quality` for quality control.
17
18## Quick Reference
19
20| Platform | Encoder | Decoder | Detect Command |
21|----------|---------|---------|----------------|
22| NVIDIA | `h264_nvenc`, `hevc_nvenc`, `av1_nvenc` | `h264_cuvid`, `hevc_cuvid` | `ffmpeg -encoders \| grep nvenc` |
23| Intel QSV | `h264_qsv`, `hevc_qsv`, `av1_qsv` | `h264_qsv`, `hevc_qsv` | `ffmpeg -encoders \| grep qsv` |
24| AMD AMF | `h264_amf`, `hevc_amf`, `av1_amf` | N/A (use software) | `ffmpeg -encoders \| grep amf` |
25| Apple | `h264_videotoolbox`, `hevc_videotoolbox` | `h264_videotoolbox` | macOS only |
26| VAAPI | `h264_vaapi`, `hevc_vaapi`, `av1_vaapi` | with `-hwaccel vaapi` | Linux only |
27| Vulkan | `h264_vulkan`, `hevc_vulkan`, `av1_vulkan`, `ffv1_vulkan` | VP9, ProRes RAW (8.0+) | `ffmpeg -encoders \| grep vulkan` |
28
29**Current Latest**: FFmpeg 8.0.1 (released 2025-11-20). Check with `ffmpeg -version`.
30
31## Hardware Acceleration Overview
32
33Hardware acceleration uses dedicated GPU/SoC components for video processing:
34
35- **NVENC/NVDEC** (NVIDIA): dedicated encode/decode engines
36- **QSV** (Intel): Quick Sync Video on Intel CPUs with integrated graphics
37- **AMF** (AMD): Advanced Media Framework for AMD GPUs
38- **VideoToolbox** (Apple): macOS/iOS hardware acceleration
39- **VAAPI** (Linux): Video Acceleration API (Intel, AMD on Linux)
40- **Vulkan Video** (Cross-platform, FFmpeg 7.1+/8.0): compute-shader-based codecs
41
42### Performance Comparison (2025 Benchmarks)
43
44| Method | Speed | Quality | Power | Use Case |
45|--------|-------|---------|-------|----------|
46| libx264 (CPU) | 1x | Best | High | Quality-critical |
47| libx265 (CPU) | 0.3x | Best | Very High | Archival |
48| h264_nvenc | 10-20x | Good | Low | Real-time, streaming |
49| hevc_nvenc | 8-15x | Good | Low | 4K streaming |
50| h264_qsv | 8-15x | Good | Very Low | Laptop, efficiency |
51| h264_amf | 8-15x | Good | Low | AMD systems |
52
53## Core Workflow
54
551. **Detect what you have**: `ffmpeg -hwaccels`, `ffmpeg -encoders | grep <api>`
562. **Pick a backend**: prefer the vendor-native one (NVENC on NVIDIA, QSV on Intel, AMF on AMD, VideoToolbox on Apple). Use Vulkan for cross-platform portability.
573. **Build a full-GPU pipeline** where possible:
58 - Add `-hwaccel <api>` and `-hwaccel_output_format <api>` *before* `-i`
59 - Use GPU-side filters (`scale_cuda`, `scale_vulkan`, `vpp_qsv`, ...)
60 - Use the matching hardware encoder
614. **Tune quality**: `-preset` (NVENC `p1-p7`), `-cq`/`-qp`/`-global_quality`, lookahead, spatial/temporal AQ
625. **Verify**: benchmark with `ffmpeg -benchmark` and monitor GPU via `nvidia-smi dmon`, `intel_gpu_top`, etc.
63
64## Minimal Examples per Backend
65
66```bash
67# NVIDIA NVENC
68ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \
69 -c:v h264_nvenc -preset p4 -b:v 5M output.mp4
70
71# Intel QSV
72ffmpeg -hwaccel qsv -hwaccel_output_format qsv -i input.mp4 \
73 -c:v h264_qsv -preset medium -b:v 5M output.mp4
74
75# AMD AMF
76ffmpeg -i input.mp4 -c:v h264_amf -quality balanced -b:v 5M output.mp4
77
78# Apple VideoToolbox
79ffmpeg -i input.mp4 -c:v h264_videotoolbox -b:v 5M output.mp4
80
81# Linux VAAPI
82ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
83 -hwaccel_output_format vaapi -i input.mp4 \
84 -c:v h264_vaapi -b:v 5M output.mp4
85
86# Vulkan (cross-platform)
87ffmpeg -init_hw_device vulkan -i input.mp4 \
88 -c:v h264_vulkan -b:v 5M output.mp4
89```
90
91## Full GPU Pipeline Pattern (Critical)
92
93```bash
94ffmpeg -y -vsync 0 \
95 -hwaccel cuda -hwaccel_output_format cuda \
96 -i input.mp4 \
97 -vf scale_cuda=1280:720 \
98 -c:v h264_nvenc -preset p4 -b:v 5M \
99 -c:a copy \
100 output.mp4
101```
102
103Omitting `-hwaccel_output_format` can cut throughput by up to 50% because decoded frames silently round-trip through CPU memory. See [`references/gpu-memory-and-troubleshooting.md`](references/gpu-memory-and-troubleshooting.md) for memory flow diagrams and best practices.
104
105## Cross-Vendor Filter Quick Map
106
107| Operation | NVIDIA | Intel | AMD/Linux | Cross-platform |
108|-----------|--------|-------|-----------|----------------|
109| Scale | `scale_cuda`, `scale_npp` | `vpp_qsv`, `scale_qsv` | `scale_vaapi` | `scale_vulkan`, `scale_opencl`, `libplacebo` |
110| Overlay | `overlay_cuda` | - | - | `overlay_vulkan`, `overlay_opencl` |
111| Deinterlace | `bwdif_cuda` | `vpp_qsv` | `deinterlace_vaapi` | `bwdif_vulkan` |
112| Denoise | `bilateral_cuda` | - | - | `nlmeans_vulkan`, `nlmeans_opencl` |
113| Chromakey | `chromakey_cuda` | - | - | `colorkey_opencl` |
114| Tonemap (HDR->SDR) | - | - | `tonemap_vaapi` | `libplacebo`, `tonemap_opencl` |
115| Pad/letterbox | `pad_cuda` (8.0+) | - | - | `pad_opencl` |
116
117## Use-Case Quick Recipes
118
119### Live streaming (low latency)
120
121```bash
122ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input \
123 -c:v h264_nvenc -preset p3 -tune ll -zerolatency 1 -b:v 6M \
124 -f flv rtmp://server/live/stream
125```
126
127### VOD (quality target)
128
129```bash
130ffmpeg -i input.mp4 \
131 -c:v hevc_nvenc -preset p6 -tune hq \
132 -rc vbr -cq 22 -b:v 0 \
133 -rc-lookahead 32 -spatial-aq 1 \
134 output.mp4
135```
136
137### Batch / parallel encoding
138
139```bash
140ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input1.mp4 -c:v h264_nvenc output1.mp4 &
141ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input2.mp4 -c:v h264_nvenc output2.mp4 &
142wait
143```
144
145### Docker (GPU passthrough)
146
147```bash
148docker run --gpus all --rm -v $(pwd):/data \
149 jrottenberg/ffmpeg:nvidia \
150 -hwaccel cuda -hwaccel_output_format cuda \
151 -i /data/input.mp4 -c:v h264_nvenc /data/output.mp4
152```
153
154## Best Practices
155
1561. Use full GPU pipelines when possible to avoid CPU/GPU memory transfers
1572. Match decode and encode hardware for best performance
1583. Pick presets deliberately - faster is not always better for quality
1594. Enable lookahead and AQ for quality-critical encodes
1605. Test on target hardware - quality varies by GPU generation
1616. Monitor GPU memory for high-resolution content
1627. Consider power efficiency for laptops and servers
1638. Update drivers regularly for performance and feature improvements
164
165## Reference Map
166
167For deep dives on each backend, see:
168
169- **NVIDIA NVENC/NVDEC** (presets, CUDA filters, scale_npp, hybrid pipelines, two-pass, multi-GPU, 1:N ABR): [`references/nvidia-nvenc.md`](references/nvidia-nvenc.md)
170- **Intel QSV** (full pipeline, vpp_qsv, lookahead, multi-GPU, VVC decoding): [`references/intel-qsv.md`](references/intel-qsv.md)
171- **AMD AMF, VAAPI, Apple VideoToolbox** (encoders, scaling, VVC VAAPI 8.0+ SCC support): [`references/amd-amf-vaapi-videotoolbox.md`](references/amd-amf-vaapi-videotoolbox.md)
172- **Vulkan Video and Vulkan filters** (h264/hevc/av1/ffv1, VP9/ProRes RAW decode, scale/overlay/blur/transitions/libplacebo): [`references/vulkan.md`](references/vulkan.md)
173- **OpenCL filters** (scale, overlay, colorkey, nlmeans, deshake, unsharp, tonemap): [`references/opencl-filters.md`](references/opencl-filters.md)
174- **GPU memory management, filter comparison matrix, Docker, troubleshooting**: [`references/gpu-memory-and-troubleshooting.md`](references/gpu-memory-and-troubleshooting.md)