NVIDIA
视频硬件加速的目标是把 H.264/H.265 解码从 CPU 转移到 iGPU/GPU,从而降低 CPU、功耗和多路摄像头压力。它与“AI 检测器”不是同一件事:GPU 可以负责视频解码,而 Coral/OpenVINO/ONNX/TensorRT 等负责目标检测。
先确认硬件透传
- Intel/AMD:容器通常需要访问 /dev/dri。
- NVIDIA:需要正确的主机驱动、NVIDIA Container Toolkit,并把 GPU 暴露给容器。
- 虚拟机:还需要宿主机 IOMMU / PCIe 或 vGPU/核显透传正确;仅在虚拟机里安装驱动并不等于设备已经透传。
常用配置
# Intel / AMD (VAAPI)
ffmpeg:
hwaccel_args: preset-vaapi
# Intel Quick Sync, use the preset matching the codec
# ffmpeg:
# hwaccel_args: preset-intel-qsv-h264Intel 选择
较新的 Intel 平台可使用 VAAPI 或 QSV。VAAPI 对 H.264/H.265 的自动适配更简单;QSV 预设通常按编码类型区分。若同一系统还有 OpenVINO NPU/GPU,可把“视频解码”和“目标检测/增强”分配到不同设备。
AMD / NVIDIA
AMD 通常通过 VAAPI;NVIDIA 使用 NVDEC/CUDA 相关预设。是否支持某一编码、位深和分辨率取决于具体 GPU 代际。尤其是 H.265 10-bit、4K 高帧率,必须核对硬件解码能力。
如何判断是否生效
- 启动后先看 Securex/FFmpeg 日志,确保没有 hwaccel 初始化错误。
- 比较启用前后的 FFmpeg CPU 占用。
- 查看系统状态页 GPU 使用率;注意低帧率子码流可能只产生很低的 GPU 百分比。
- 如果指定了硬件加速却初始化失败,不要假设系统会无损地自动回退到 CPU,应立即根据日志修正。
常见误区
- “Intel GPU 0%”不一定代表没工作;短时间采样或低负载可能接近 0。
- Coral TPU 正常工作不代表视频已经使用 GPU 解码。
- 硬件解码正常也不代表目标检测使用 GPU。
- 不要同时给所有摄像头套用一个不匹配编码的 QSV 预设。
NVIDIA
Video hardware acceleration moves H.264/H.265 decoding from the CPU to an iGPU/GPU. It is separate from object detection: a GPU may decode video while Coral, OpenVINO, ONNX, TensorRT, or another runtime performs inference.
Pass the device through first
- Intel/AMD containers generally need access to /dev/dri.
- NVIDIA requires a compatible host driver, NVIDIA Container Toolkit, and GPU access inside the container.
- Virtual machines also require working host-side IOMMU/PCIe or virtual-GPU passthrough; installing a guest driver alone is not passthrough.
Common configuration
# Intel / AMD (VAAPI)
ffmpeg:
hwaccel_args: preset-vaapi
# Intel Quick Sync, use the preset matching the codec
# ffmpeg:
# hwaccel_args: preset-intel-qsv-h264Intel
Modern Intel systems can use VAAPI or QSV. VAAPI is convenient when mixed H.264/H.265 sources are present; QSV presets are commonly selected by codec. Systems with both GPU and NPU can split decode, detection, and enrichment workloads.
AMD and NVIDIA
AMD commonly uses VAAPI. NVIDIA uses NVDEC/CUDA-capable presets. Codec, bit depth, resolution, and frame-rate support depend on GPU generation, so verify capabilities for 10-bit H.265 and high-resolution streams.
Verify acceleration
- Read FFmpeg startup logs for hwaccel initialization errors.
- Compare FFmpeg CPU use before and after enabling acceleration.
- Check GPU telemetry; low-FPS substreams can produce very small utilization numbers.
- If an explicitly configured accelerator fails to initialize, fix the error rather than assuming a seamless CPU fallback.
Common misconceptions
- A 0% GPU snapshot does not always mean decoding is inactive.
- A healthy Coral TPU does not imply GPU video decode is enabled.
- Hardware decode does not mean object detection uses the GPU.
- Do not apply one codec-specific QSV preset to incompatible camera streams.
NVIDIA
La aceleración de vídeo traslada la decodificación H.264/H.265 desde la CPU a una iGPU/GPU. Es independiente del detector de objetos: la GPU puede decodificar mientras Coral, OpenVINO, ONNX o TensorRT hacen inferencia.
Primero, exponga el dispositivo
- Intel/AMD suelen requerir /dev/dri dentro del contenedor.
- NVIDIA requiere controlador, NVIDIA Container Toolkit y acceso a la GPU.
- En una VM también hace falta passthrough real de IOMMU/PCIe o GPU virtual.
Configuración habitual
# Intel / AMD (VAAPI)
ffmpeg:
hwaccel_args: preset-vaapi
# Intel Quick Sync, use the preset matching the codec
# ffmpeg:
# hwaccel_args: preset-intel-qsv-h264Intel
Los sistemas Intel modernos pueden usar VAAPI o QSV. VAAPI simplifica escenarios H.264/H.265 mixtos; QSV suele elegirse según el códec. GPU y NPU pueden repartirse decodificación, detección y enriquecimientos.
AMD y NVIDIA
AMD suele usar VAAPI y NVIDIA NVDEC/CUDA. La compatibilidad depende de la generación, el códec, bit depth y resolución.
Verificación
- Revise errores de inicialización en los logs de FFmpeg.
- Compare el uso de CPU antes y después.
- Revise telemetría de GPU; un substream ligero puede mostrar porcentajes muy bajos.
- Si falla el acelerador configurado, corrija el error en lugar de confiar en un fallback implícito.
Errores conceptuales
- 0% en una muestra no siempre significa que no se use GPU.
- Coral funcionando no implica decodificación por GPU.
- Decodificación por hardware no significa inferencia por GPU.
- No mezcle presets QSV incompatibles con el códec.
