[Share Experiences] nvidia显卡firefox硬解在线视频
Tofloor
poster avatar
callcz
deepin
2022-03-16 08:50
Author

2024/11/07

更新0.0.13版:nvidia-vaapi-driver_0.0.13_deepin20.9.zip


2024/06/04

更新0.0.12版:nvidia-vaapi-driver_0.0.12_deepin20.9.zip


2024/03/22

更新0.0.11版:nvidia-vaapi-driver_0.0.11_deepin20.9.zip


2023/07/02

更新0.0.10版:nvidia-vaapi-driver_0.0.10_deepin20.9.zip


2023/03/30

更新0.0.9版:nvidia-vaapi-driver_0.0.9_deepin20.8.zip


2023/01/21

新年快乐!!

更新0.0.8版:nvidia-vaapi-driver_0.0.8_deepin20.8.zip


2022/11/01

更新0.0.7版:nvidia-vaapi-driver_0.0.7_deepin20.7.1.zip

试了一下firefox 106暂没发现问题,而且连视频底部的彩条也修复了[赞]。

PS.升级20.7后libva和meson用自带的就可以满足依赖了


2022/05/28

在 firefox 100 下面拖视频进度条会报错,要硬解只能继续用99版本。

更新0.0.6版:nvidia-vaapi-driver_0.0.6_deepin20.5.zip


2022/03/06更新

nvidia-vaapi-driver已经打包了

https://bbs.deepin.org/post/233571


nvidia显卡在浏览器上看在线视频一向只能软解,前一阵子得知github上有大神开发了nvidia的vaapi的驱动——nvidia-vaapi-driver,研究了一下发现真牛X!

*本文所讲具体内容以deepin20.4为参考,需安装nvidia闭源驱动,本文所用驱动为官方源包,如果你用的是非官方源驱动可能会因为某些包的版本冲突而出问题。

*下载编译依赖包需要打开deb-src源。

*firefox版本需要98以上,请通过mozilla.org下载。

1.项目网址在(可能需要科学上网):

https://github.com/elFarto/nvidia-vaapi-driver

可通过git得到原代码

$mkdir -p ~/build/nvidia-vaapi-driver
$cd ~/build/nvidia-vaapi-driver 
$git https://github.com/elFarto/nvidia-vaapi-driver.git

需要修改 src/vabackend.c,可以文本编辑器打开,在原文前头有很多 #include 的行,在它们最下面添加

#include   <---不要漏了这一行:)
pid_t gettid() {
return syscall(SYS_gettid);
}

2.安装所编译需要的包

a.这些可以直接通过apt和pip获得:

pip3官方源国内不可用,需要用到国内镜像,将以下内容拷贝到~/.pip/pip.conf

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
$sudo apt install nvidia-settings libegl-dev libgstreamer-plugins-bad1.0-dev ninja-build libcuda1 libnvcuvid1 python3-pip nvidia-cuda-dev
#meson需要大于0.58.0 deepin源里的版本太低安装前请先删除源里的版本再安装pip里的版本
$sudo pip3 install meson

b.以下列出来的需要自已编译,如果不想麻烦等下提供编译好的deb包。

libva>=2.8.0其实只有2.14.0可用,deepin源里的版本太低

$sudo apt build-dep libva
$mkdir -p ~/build/libva &&cd ~/build/libva
$git clone https://salsa.debian.org/multimedia-team/libva.git
$cd libva-xx #xx为版本号
$dpkg -us -uc -j8 #开始编译,完成后在上级目录生成deb安装包,PS:添加-ai386参数可以编译32位的deb包(uengine和wine微信需要依赖,如要编译32位包需安装gcc-multilib-i686-linux-gnu)
$cd ..&&rm *dbgsym*.deb&&sudo dpkg -i *.amd64.deb

libva-utils是vainfo源码的名称2.12.0可用,deepin源里的版本太低

$sudo apt build-dep libva-utils
$mkdir -p ~/build/libva-utils &&cd ~/build/libva-utils
$git clone https://salsa.debian.org/multimedia-team/libva-utils.git
$cd libva-utils-xx #xx为版本号
$dpkg -us -uc -j8 #开始编译,完成后在上级目录生成deb安装包
$cd ..&&rm *dbgsym*.deb&&sudo dpkg -i *.amd64.deb

nv-codec-headers

$mkdir -p ~/build/nv-codec-headers&&cd ~/build/nv-codec-headers
$git clone https://salsa.debian.org/multimedia-team/nv-codec-headers.git
$cd nv-codec-headers-xx #xx为版本号
$make &&sudo make install

3.编译nvidia-vaapi-driver

$cd ~/build/nvidia-vaapi-driver/nvidia-vaapi-driver
$meson setup build/
$meson install -C build/
$rm -rf build/ #如需再次编译需删除build目录

4.运行vainfo

$vainfo

应返回类似信息(如报错不要紧,等修改nvidia-drm.modeset=1后重启完再看):

$vainfo
libva info: VA-API version 1.14.0
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
vainfo: Driver version: VA-API NVDEC driver
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple            : VAEntrypointVLD
VAProfileMPEG2Main              : VAEntrypointVLD
VAProfileVC1Simple              : VAEntrypointVLD
VAProfileVC1Main                : VAEntrypointVLD
VAProfileVC1Advanced            : VAEntrypointVLD
VAProfileVC1Advanced            : VAEntrypointVLD
               : VAEntrypointVLD
VAProfileH264Main               : VAEntrypointVLD
VAProfileH264High               : VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileHEVCMain               : VAEntrypointVLD
VAProfileVP8Version0_3          : VAEntrypointVLD
VAProfileVP9Profile0            : VAEntrypointVLD

5.修改系统配置

a.将 nvidia-drm内核模式设置为1即 nvidia-drm.modeset=1

$sudo deepin-editor /boot/grub/grub.cfg #打开grub.cfg文件

找到以下一行(估计在149行):

linux	/boot/vmlinuz-xxx-amd64-desktop root=UUID=xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro  splash quiet  DEEPIN_GFXMODE=$DEEPIN_GFXMODE

在ro后面加上 nvidia-drm.modeset=1

linux	/boot/vmlinuz-xxx-amd64-desktop root=UUID=xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro  nvidia-drm.modeset=1 splash quiet  DEEPIN_GFXMODE=$DEEPIN_GFXMODE

保存退出

b.修改 /etc/profile

$sudo deepin-editor /etc/profile #打开/etc/profile文件

在文件最后尾加上:

export LIBVA_DRIVER_NAME=nvidia
export LIBVA_DRIVER_PATH=/usr/lib/x86_64-linux-gnu/dri/
export MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_X11_EGL=1
export MOZ_ENABLE_WAYLAND=1

c.修改firefox配置

在地址栏输入 about:config 修改以下配置:

media.ffmpeg.vaapi.enabled true Required, enables the use of VA-API.
media.rdd-ffmpeg.enabled true Required, default on FF97. Forces ffmpeg usage into the RDD process, rather than the content process.
media.av1.enabled false Optional, disables AV1. If your GPU doesn't support AV1, this will prevent sites using it and falling back to software decoding. Hopefully the site will fall back to using a different codec that is hardware accellerated.
gfx.x11-egl.force-enabled true This driver requires that Firefox use the EGL backend. If it isn't selecting it by default, it'll need to be forced on using this option or by setting the MOZ_X11_EGL environment variable to 1. It's recommended you try the environment variable method first to test it.
widget.dmabuf.force-enabled true Required for NVIDIA 470 series drivers, not required at all on 495+. This option has been shown to help getting decoding working on the 470 driver series. However it should be noted that Firefox isn't coded to allow DMA-BUF support without GBM support, so it may not function completely correctly when it's forced on.

d.重启电脑测试

测试nvidia-drm内核模式

sudo cat /sys/module/nvidia_drm/parameters/modeset #返回Y正常,否则modeset=1可能未设置成功

打开firefox播放B站(firefox版本需要98以上,mozilla.org下载)

打开 nvidia-settings查看 Video Engine Utilization占用率,有数值表明已开启硬解,如下图:

截图_20220315230440.png


附:

已编译好的libva、vainfo的deb包:

libva-2.14_deb_deepin.zip

vainfo_2.12.0+ds1-1_amd64.zip

已编译好的nvidia-vaapi-driver:

只有一个.so文件,放进 /usr/lib/x86_64-linux-gnu/dri/里,不知道能不能直接使用,应该要安装 libegl-dev libgstreamer-plugins-bad1.0-devlibcuda1 libnvcuvid1等cuda库作为依赖。

nvidia_drv_video.zip


Reply Favorite View the author
All Replies
jjcui8595
deepin
2022-03-16 14:07
#1

感谢分享,支持一下

Reply View the author
fozei
deepin
2022-03-16 16:49
#2

显卡一直不敢折腾,15时代,不管是深度还是Ubuntu,只要是独立显卡的本本,都不能装系统呢。现在可以了,但是有一天我跑一个老照片修复的库,提示我没有安装显卡,但是实际上我的本本是有独立显卡的,这块一直没有弄不明白过。感谢楼主分享。

Reply View the author
Tonny
deepin
2022-03-16 17:09
#3
It has been deleted!
zccrs
deepin
2022-03-16 17:40
#4

这个包可以考虑在仓库集成一下,另外版本落后的编译工具可以更新下。@zeno

Reply View the author
神末shenmo
deepin
Spark-App
2022-03-17 05:30
#5
zccrs

这个包可以考虑在仓库集成一下,另外版本落后的编译工具可以更新下。@zeno

@zeno 帮你补上

Reply View the author
zeno
deepin developers team
2022-03-17 23:07
#6

@callcz 拿了个3070试了下 Video Engine Utilization的占用率一直为0 ,但是GPU Utilization的数值是有变化的,应该是开启了硬解 不然GPU Utilization也不会上升

Reply View the author
zeno
deepin developers team
2022-03-17 23:07
#7
It has been deleted!
callcz
deepin
2022-03-18 08:35
#8
zeno

@callcz 拿了个3070试了下 Video Engine Utilization的占用率一直为0 ,但是GPU Utilization的数值是有变化的,应该是开启了硬解 不然GPU Utilization也不会上升

Video Engine Utilization有数值才是启用了硬解,GPU Utilization只要是画面通过GPU渲染就会数值,例如切换窗口、刷新画面等。

你看看vainfo的输出是否正常,并且试试在终端里打开firefox播放视频看终端的输出信息是否包含vainfo error的信息。

Reply View the author
Breeze
deepin
2022-10-27 11:27
#9

007出来了,能不能打包一下,谢谢

Reply View the author
callcz
deepin
2022-11-02 08:01
#10
Breeze

007出来了,能不能打包一下,谢谢

已打包😁

Reply View the author
Breeze
deepin
2022-11-03 00:40
#11
callcz

已打包😁

谢谢!kissing_heart

Reply View the author
L
deepin
2023-07-13 01:45
#12

大佬你好,我用是ARM架构的,再编译nvidia-vaapi-driver的时候出现以下错误,该怎么解决呢

root@ubuntu:/build/nvidia-vaapi-driver/nvidia-vaapi-driver# meson setup build/
The Meson build system
Version: 0.61.5
Source dir: /root/build/nvidia-vaapi-driver/nvidia-vaapi-driver
Build dir: /root/build/nvidia-vaapi-driver/nvidia-vaapi-driver/build
Build type: native build
Project name: nvidia-vaapi-driver
Project version: 0.1
C compiler for the host machine: cc (gcc 7.5.0 "cc (Ubuntu/Linaro 7.5.0-3ubuntu1
18.04) 7.5.0")
C linker for the host machine: cc ld.bfd 2.30
Host machine cpu family: aarch64
Host machine cpu: aarch64
Library m found: YES
Library dl found: YES
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Run-time dependency egl found: YES 20.0.8
Run-time dependency ffnvcodec found: YES 12.0.16.0
Run-time dependency libdrm found: YES 2.4.101
Run-time dependency threads found: YES
Dependency libva found: NO found 1.1.0 but need: '>= 1.8.0'
Found CMake: /usr/bin/cmake (3.10.2)
Run-time dependency libva found: NO (tried cmake)

meson.build:24:0: ERROR: Invalid version of dependency, need 'libva' ['>= 1.8.0'] found '1.1.0'.

A full log can be found at /root/build/nvidia-vaapi-driver/nvidia-vaapi-driver/build/meson-logs/meson-log.txt
NOTICE: You are using Python 3.6 which is EOL. Starting with v0.62.0, Meson will require Python 3.7 or newer

Reply View the author
callcz
deepin
2023-07-17 07:55
#13
L

大佬你好,我用是ARM架构的,再编译nvidia-vaapi-driver的时候出现以下错误,该怎么解决呢

root@ubuntu:/build/nvidia-vaapi-driver/nvidia-vaapi-driver# meson setup build/
The Meson build system
Version: 0.61.5
Source dir: /root/build/nvidia-vaapi-driver/nvidia-vaapi-driver
Build dir: /root/build/nvidia-vaapi-driver/nvidia-vaapi-driver/build
Build type: native build
Project name: nvidia-vaapi-driver
Project version: 0.1
C compiler for the host machine: cc (gcc 7.5.0 "cc (Ubuntu/Linaro 7.5.0-3ubuntu1
18.04) 7.5.0")
C linker for the host machine: cc ld.bfd 2.30
Host machine cpu family: aarch64
Host machine cpu: aarch64
Library m found: YES
Library dl found: YES
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Run-time dependency egl found: YES 20.0.8
Run-time dependency ffnvcodec found: YES 12.0.16.0
Run-time dependency libdrm found: YES 2.4.101
Run-time dependency threads found: YES
Dependency libva found: NO found 1.1.0 but need: '>= 1.8.0'
Found CMake: /usr/bin/cmake (3.10.2)
Run-time dependency libva found: NO (tried cmake)

meson.build:24:0: ERROR: Invalid version of dependency, need 'libva' ['>= 1.8.0'] found '1.1.0'.

A full log can be found at /root/build/nvidia-vaapi-driver/nvidia-vaapi-driver/build/meson-logs/meson-log.txt
NOTICE: You are using Python 3.6 which is EOL. Starting with v0.62.0, Meson will require Python 3.7 or newer

大佬真不敢当,只不过是业余初学者。

根据编译报错是由于libva版本太低,需要>=1.8.0,你可以安装更高版本的libva试试。

还有,ARM这个真的不太了解,nvidia的ARM驱动支持也不了解,或者先确定一下GPU是nvidia的而且正确安装了显卡驱动和cuda库?(nvidia那个开发板好贵没舍得买😂 )

vappi是intel推出的,其它架构是否能支持也不了解。

Reply View the author
New Thread

Popular Ranking

Change

Popular Events

More
国际排名
WHLUG