Hardware video acceleration (简体中文)
Hardware video acceleration makes it possible for the video card to decode/encode video, thus offloading the CPU and saving power.
Linux 中有多种方式可以实现视频加速:
- 视频加速API (Video Acceleration API, 缩写为VA-API) 是一套提供视频硬件编解码的开源库和标准。
- Unix视频解码及演示 API (Video Decode and Presentation API for Unix,缩写为VDPAU)是一个开源的库,它使得部分的视频解码和视频后期处理任务转移到GPU硬件上。
Contents
支持的硬件
VA-API
开源驱动:
- AMD: 位于官方软件仓库的libva-vdpau-driver和mesa两者为 Radeon 9500 或更新的GPU提供支持。
- Intel: 位于官方软件仓库的libva-intel-driver软件包为 GMA 4500 系列或者更新的GPU提供支持。
- NVIDIA: 位于官方软件仓库的libva-vdpau-driver和mesa两者为 GeForce 8 系列和更新的GPU提供支持。位于AUR的 nouveau-fwAUR 软件包包含从NVIDIA闭源驱动中提取出的必要的固件文件。
闭源驱动:
- AMD: 位于AUR的libva-xvba-driverAUR[broken link: archived in aur-mirror]软件包为 Radeon HD 4000 系列或更新的GPU提供支持。在 Radeon HD 5000 系列或者更新的GPU上请使用 catalyst-utilsAUR 驱动;在 Radeon HD 4000 系列上使用 catalyst-total-hd234kAUR 作为驱动程序。
- NVIDIA: 位于官方软件仓库的libva-vdpau-driver软件包和 nvidia-utils 驱动为 GeForce 8 系列或更新的GPU提供支持。
VDPAU
开源驱动:
- AMD: 位于官方软件仓库的 mesa-vdpau 软件包为 Radeon 9500 或更新的GPU提供支持。
- Intel: 位于官方软件仓库的libvdpau-va-gl和libva-intel-driver这两个软件包为 GMA 4500 系列或者更新的GPU提供支持。
- NVIDIA: 位于官方软件仓库的 mesa-vdpau 软件包为 GeForce 8 系列和更新的GPU提供支持。位于AUR的 nouveau-fwAUR 软件包包含从NVIDIA闭源驱动中提取出的必要的固件 。
闭源驱动:
- AMD: 位于官方软件仓库的libvdpau-va-gl、位于AUR的libva-xvba-driverAUR[broken link: archived in aur-mirror]软件包两者为 Radeon HD 4000 系列或更新的GPU提供支持。在 Radeon HD 5000 系列或者更新的GPU上请使用 catalyst-utilsAUR 驱动;在 Radeon HD 4000 系列上 使用 catalyst-total-hd234kAUR 作为驱动程序。
- NVIDIA: 位于官方软件仓库的nvidia-utils软件包为 GeForce 400 系列或更新的GPU提供支持。
- GeForce 8/9 和 GeForce 100-300 系列由 nvidia-340xx-utils 软件包支持。
支持的格式
VA-API
Open source | Proprietary | ||||
---|---|---|---|---|---|
AMD | Intel | Nvidia | AMD | Nvidia | |
MPEG2 解码 | AMD Radeon 9500 或更新 | Intel GMA 4500 或更新 | Nvidia GeForce 8 或更新 | AMD Radeon HD 4000 或更新 | Nvidia GeForce 8 或更新 |
MPEG4 解码 | AMD Radeon HD 6000 或更新 | -- | Nvidia GeForce 200 或更新 | AMD Radeon HD 6000 或更新 | Nvidia GeForce 200 或更新 |
H264 解码 | AMD Radeon HD 4000 或更新 | Intel GMA 45001, Ironlake Graphics 或更新 | Nvidia GeForce 8 或更新 | AMD Radeon HD 4000 或更新 | Nvidia GeForce 8 或更新 |
VC1 解码 | AMD Radeon HD 4000 或更新 | Intel Sandy Bridge Graphics 或更新 | Nvidia GeForce 8200, 8300, 8400, 9300, 200 或更新 | AMD Radeon HD 4000 或更新 | Nvidia GeForce 8 或更新 |
MPEG2 编码 | -- | Intel Ivy Bridge Graphics 或更新 | -- | -- | -- |
H264 编码 | -- | Intel Sandy Bridge Graphics 或更新 | -- | -- | -- |
1libva-intel-driver-g45-h264AUR 软件包为其提供支持。具体方法和注意事项参看: 在 GMA 4500 硬解 H.264。
运行下面的命令以查看你的GPU支持哪些功能。这个命令由 libva-utils 软件包提供:
$ vainfo
VAEntrypointVLD 表示你可以解码该格式,VAEntrypointEncSlice 表示你可以编码该格式。
VDPAU
开源 | 闭源 | ||||
---|---|---|---|---|---|
AMD | Intel | Nvidia | AMD | Nvidia | |
MPEG2 decoding | Radeon 9500 and newer | |
GeForce 8 and newer | |
GeForce 8 and newer |
MPEG4 decoding | Radeon HD 6000 and newer | |
GeForce 200 and newer | |
GeForce 200 and newer |
H.264 decoding | Radeon HD 4000 and newer | GMA 45001, Ironlake Graphics and newer | GeForce 8 and newer | Radeon HD 4000 and newer | GeForce 8 and newer |
HEVC (H.265) decoding | |
|
|
|
GeForce 9004 and newer |
VC1 decoding | Radeon HD 4000 and newer | |
GeForce 83 and newer | |
GeForce 83 and newer |
- 1 Supported by the libva-intel-driver-g45-h264AUR package. See Intel graphics#H.264 decoding on GMA 4500[broken link: invalid section] for instructions and caveats.
- 2 As of version 0.3, the VA GL driver doesn't support any other hardware decoder than H.264.
- 3 Except GeForce 8800 Ultra, 8800 GTX, 8800 GTS (320/640 MB).
- 4 Except GeForce GTX 970 and GTX 980.
要检查一个功能是否被 GPU 支持,可以使用 vdpauinfo 软件包提供的命令:
$ vdpauinfo
配置
环境变量 VDPAU_DRIVER
决定使用的驱动。可以全局设置 或 针对一个用户 设置 环境变量
正确的驱动程序名称取决于您的设置:
- Intel 或 AMD Catalyst 使用
va_gl
. - 开源AMD/ATI驱动程序,您需要将它设置为适当的驱动程序版本取决于你的GPU。
- Nvidia的专有版本将变量设置为“nvidia”。
$ grep -i vdpau /var/log/Xorg.0.log
(II) RADEON(0): [DRI2] VDPAU driver: r300
然后设置 VDPAU 驱动:
VDPAU_DRIVER=r300
多显卡显示
对混合显卡(NVIDIA和AMD),需要设置下面环境变量。
$ export DRI_PRIME=1
更多信息,参阅 PRIME wiki 页面。
支持的软件
开启软件的硬件加速
- Adobe Flash Player — 见 Browser plugins#Adobe Flash Player.
- || flashplugin
- gnome-mplayer — 开启硬件加速: Edit > Preferences > Player, 设置 Video Output 为
vdpau
.
- SMplayer — 开启硬件加速: Options > Preferences > General > Video, 设置 Output driver 为
vdpau
.
- || smplayer
- bomi — 硬件加速可以启用: Preferences > Video > Hardware acceleration.
- https://bomi-player.github.io || bomiAUR bomi-gitAUR
- Mpv — 见 Mpv#Hardware decoding.
- || mpv
- || vlc
GStreamer
安装 gstreamer-vaapi 软件包,它存在于官方软件仓库。
$ gst-launch-1.0 playbin uri=file:///path/to/foobar.mpeg
如果发现了支持的格式,VA-API会自动被使用。
基于GStreamer的播放器:
- totem: 不需要配置。
MPlayer
安装 mplayer-vaapiAUR 软件包,它存在于官方软件仓库。
$ mplayer -vo vaapi -va vaapi foobar.mpeg
- -vo - 指定 vaapi 视频输出驱动
- -va - 指定 vaapi 视频解码驱动
基于 MPlayer 的播放器:
- gnome-mplayer: 开启硬件加速的方法: 编辑 > 首选项 > 播放器, 并设置视频输出为
vaapi
。 - smplayer: 开启硬件加速的方法: 选项 > 首选项 > 常规 > 视频, 并设置输出驱动为
vaapi
。
VLC media player
安装 vlc 软件包,它位于官方软件仓库。
开启硬件加速的方法: 工具 > 首选项 > 输入 / 编解码器, 然后设置 硬件加速解码 为 视频加速 (VA) API
。