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