Skip to main content

HW Accel

OSHW Acceleration
LinuxQSV, NVENC, AMF, VA-API
WindowsQSV, NVENC, AMF
MacOSVideoToolbox
RPiV4L2
VendorHW Acceleration
NVIDIANVENC
AMDAMF, VA-API
IntelQSV, VA-API
AppleVideoToolbox
RPiV4L2
ProjectGraphics GenRepo
oneVPLgen12+https://github.com/oneapi-src/oneVPL
iHD drivergen8+https://github.com/intel/media-driver
Libvagen5+https://github.com/intel/libva
MSDKgen8 ~ gen12(Rocket Lake)https://github.com/Intel-Media-SDK/MediaSDK
i965 drivergen5 ~ gen9.5https://github.com/intel/intel-vaapi-driver
  • Intel QuickSync (QSV)
    • 基于 VAAPI
  • 没有硬解支持 H.264 / AVC 10-bit
    • 升级为 HEVC 10-bit
  • /usr/lib/dri/ - 安装的驱动
    • iHD_drv_video.so
    • i965_drv_video.so
  • /dev/dri/render* DRM render node
  • i915
  • i965
cat /proc/cpuinfo | grep "model name" | uniq

apk add pciutils
lspci -nn | egrep -i "3d|display|vga"

apk add lshw
lshw -C display
lshw -c video

apk add inxi
inxi -G

# i915_cur_delayinfo
sudo sh -c 'cat /sys/kernel/debug/dri/*/name'


ls /dev/dri

# VA-API
# ==========
# AlpineLinux edge/testing libva-utils
apk -X https://mirrors.sjtug.sjtu.edu.cn/alpine/edge/testing add libva-utils
vainfo
# https://github.com/intel/libva-utils
# /dev/dri/renderXX

# Intel QSV
# =============
apk add intel-media-driver libva-intel-driver
sudo LIBVA_TRACE=/tmp/libva_trace.log DRI_PRIME=1 LIBVA_DRIVER_NAME=iHD vainfo

LIBVA_TRACE=/tmp/libva_trace.log DRI_PRIME=1 LIBVA_DRIVER_NAME=iHD ffmpeg -loglevel verbose -init_hw_device vaapi

# options i915 enable_guc=3
# options i915 enable_fbc=1
echo "options i915 force_probe=4692" | sudo tee /etc/modprobe.d/i915.conf

# GPU freq
sudo find /sys -type f -name gt_cur* -print0

# X11
# ==========
# apk add vdpauinfo
# vdpauinfo
grep -iE 'vdpau | dri driver' /var/log/Xorg.0.log

# FFMpeg
# =======
ffmpeg -hide_banner -decoders | grep qsv # 判断是否有加速
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i "video.MP4" -vf "select=eq(pict_type\,I)" -vsync vfr -qscale:v 2 -f image2 "%08d.jpg"

FFmpeg

  • {h264,hevc}_{videotoolbox,amf,vaapi}
    • videotoolbox - macOS
    • amf - Windows
    • vaapi - Linux - vainfo
  • -hwaccel auto
    • dxva2,cuda,d3d11va,videotoolbox
    • -hwaccel_device
ffmpeg -encoders | grep videotoolbox # 支持的 videotoolbox 编码
ffmpeg -h encoder=h264_videotoolbox # 查看编码器选项

ffprobe in.mp4 # 弄清楚原始 bitrate
ffmpeg -b:v 1900k -c:v h264_videotoolbox # -b:v 匹配原始 bitrate

# 使用 hwaccel 方式 - 外置 GPU
ffmpeg \
-hwaccel videotoolbox -i in.mp4 \
-c:v libx265 -preset medium -crf 28 \
-c:a copy \
out.mp4

vaInitialize failed with error code 18

看不到显卡

  • 尝试调整 BIOS - 修改为可切换显卡