AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 679185
Accepted
FGarbuzov
FGarbuzov
Asked: 2021-11-27 05:12:22 +0800 CST2021-11-27 05:12:22 +0800 CST 2021-11-27 05:12:22 +0800 CST

在 Chrome、Kubuntu 20.04 中启用硬件视频加速

  • 772

简而言之:无法在 Chrome 中启用硬件视频加速。我的台式机集成了 GPU Intel UHD 750 和 Core i5 11600,它运行 Kubuntu 20.04。

最初,我根本没有硬件加速,所以即使是 VLC 播放视频也没有加速,尽管我已经intel-media-va-driver-non-free安装了。的输出vainfo是

libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 1
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns -1

我搜索了解决方案,但没有找到有同样问题的人。我决定就相关问题遵循一些建议。首先,我将内核从 5.11 更新到 5.15,但这并没有帮助。然后我添加了一个 repo 来安装英特尔驱动程序的 21.xx 版本,如此处评论中所建议的:https ://githubmemory.com/repo/HaveAGitGat/Tdarr/issues/452 。在升级了一些软件包并安装了一些保留的软件包后,我得到了视频加速。的当前输出vainfo为

libva info: VA-API version 1.12.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_12
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.12 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.3.3 (6fdf88c)
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats

等等。

下一步是在 Chrome 中启用硬件加速。我按照这里的说明https://www.linuxupprising.com/2021/01/how-to-enable-hardware-accelerated.html但没有帮助。该chrome://gpu选项卡显示以下内容

图形功能状态

  • 帆布:仅限软件。禁用硬件加速
  • 画布进程外光栅化:已禁用
  • 合成:仅限软件。禁用硬件加速
  • 多个光栅线程:禁用
  • 进程外光栅化:禁用
  • OpenGL:已禁用
  • 光栅化:仅限软件。禁用硬件加速
  • 原始绘图:已禁用
  • Skia 渲染器:已启用
  • 视频解码:仅限软件。禁用硬件加速
  • Vulkan:已禁用
  • WebGL:已禁用
  • WebGL2:已禁用

检测到的问题

  • 已通过阻止列表、about:flags 或命令行禁用加速视频解码。
    禁用功能:video_decode
  • Gpu 合成已通过阻止列表、about:flags 或命令行禁用。浏览器将退回到软件合成,硬件加速将不可用。
    禁用功能:gpu_compositing
  • GPU 进程无法启动:GPU 进程使用 SwiftShader 崩溃太多次。
    禁用功能:所有
    ...

我还尝试在 Firefox 中启用视频加速,但失败了。此外,我安装了 Chromium,chrome://gpu现在显示几乎所有功能都已启用,但视频加速未启用。

请帮忙!

video chrome
  • 1 1 个回答
  • 2841 Views

1 个回答

  • Voted
  1. Best Answer
    EnzoR
    2021-12-11T03:02:47+08:002021-12-11T03:02:47+08:00

    免责声明

    您可能不会在基于 Chrome 的浏览器中真正获得硬件加速。但我们不要投降:有些事情还是可以做的。

    我与您的设置的区别是:

    • 环境:ArchLinux+XOrg+KDE
    • GPU:(TigerLake-LP GT2 [Iris Xe Graphics]来自lspci)。
    • 内核:5.15.7-zen1-1-zen

    我想配方应该是一样的。

    需要的包

    我有这些(名称可能与 Ubuntu 不同):

    • 台面
    • xf86-视频-英特尔
    • 图书馆
    • libva 英特尔驱动程序
    • libva 台面驱动程序
    • libva-vdpau-驱动程序
    • 台面-vdpau
    • 英特尔-gmmlib
    • 英特尔媒体驱动程序

    您可能还需要一些工具来检查:

    • libva-utils
    • vdpauinfo
    • 英特尔 GPU 工具

    浏览器设置

    我设置它们chrome://flags,然后重新启动浏览器。这也适用于 Chromium,而 Vivaldi 内部 URL 位于vivaldi://前缀上。

    • 覆盖软件渲染列表
    • GPU 光栅化
    • 零拷贝光栅化器
    • 使显示合成器能够使用新的 gpu 线程
    • 加速的 2D 画布
    • 进程外 2D 画布光栅化

    浏览器启动

    您需要使用额外的选项重新启动浏览器:

    --enable-features=VaapiVideoDecoder
    

    您可以编辑您的启动配置文件以添加此配置文件。我的现在看起来像这样:

    /usr/bin/google-chrome-stable --enable-features=VaapiVideoDecoder %U
    

    检查状态

    这是最好的,恕我直言,你能做到。

    浏览器

    重新启动后,您可以转到内部 URLchrome://gpu并检查。这是我自己的状态:

    Graphics Feature Status
    Canvas: Hardware accelerated
    Canvas out-of-process rasterization: Enabled
    Compositing: Hardware accelerated
    Multiple Raster Threads: Enabled
    Out-of-process Rasterization: Hardware accelerated
    OpenGL: Enabled
    Rasterization: Hardware accelerated on all pages
    Raw Draw: Disabled
    Skia Renderer: Enabled
    Video Decode: Hardware accelerated
    Vulkan: Disabled
    WebGL: Hardware accelerated
    WebGL2: Hardware accelerated
    

    我保留Raw Draw: Disabled是因为它在浏览器中表现不佳。如果您想尝试它,请返回标志并启用“启用原始绘制”标志。

    vainfo

    如果您安装了它,只需运行它。我的工作是这样的:

    [enzo@Feynman ~] vainfo 
    vainfo: VA-API version: 1.13 (libva 2.13.0)
    vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.4.3 ()
    vainfo: Supported profile and entrypoints
          VAProfileNone                   : VAEntrypointVideoProc
          VAProfileNone                   : VAEntrypointStats
          VAProfileMPEG2Simple            : VAEntrypointVLD
          VAProfileMPEG2Simple            : VAEntrypointEncSlice
          VAProfileMPEG2Main              : VAEntrypointVLD
          VAProfileMPEG2Main              : VAEntrypointEncSlice
          VAProfileH264Main               : VAEntrypointVLD
          VAProfileH264Main               : VAEntrypointEncSlice
          VAProfileH264Main               : VAEntrypointFEI
          VAProfileH264Main               : VAEntrypointEncSliceLP
          VAProfileH264High               : VAEntrypointVLD
          VAProfileH264High               : VAEntrypointEncSlice
          VAProfileH264High               : VAEntrypointFEI
          VAProfileH264High               : VAEntrypointEncSliceLP
          VAProfileVC1Simple              : VAEntrypointVLD
          VAProfileVC1Main                : VAEntrypointVLD
          VAProfileVC1Advanced            : VAEntrypointVLD
          VAProfileJPEGBaseline           : VAEntrypointVLD
          VAProfileJPEGBaseline           : VAEntrypointEncPicture
          VAProfileH264ConstrainedBaseline: VAEntrypointVLD
          VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
          VAProfileH264ConstrainedBaseline: VAEntrypointFEI
          VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
          VAProfileVP8Version0_3          : VAEntrypointVLD
          VAProfileHEVCMain               : VAEntrypointVLD
          VAProfileHEVCMain               : VAEntrypointEncSlice
          VAProfileHEVCMain               : VAEntrypointFEI
          VAProfileHEVCMain               : VAEntrypointEncSliceLP
          VAProfileHEVCMain10             : VAEntrypointVLD
          VAProfileHEVCMain10             : VAEntrypointEncSlice
          VAProfileHEVCMain10             : VAEntrypointEncSliceLP
          VAProfileVP9Profile0            : VAEntrypointVLD
          VAProfileVP9Profile0            : VAEntrypointEncSliceLP
          VAProfileVP9Profile1            : VAEntrypointVLD
          VAProfileVP9Profile1            : VAEntrypointEncSliceLP
          VAProfileVP9Profile2            : VAEntrypointVLD
          VAProfileVP9Profile2            : VAEntrypointEncSliceLP
          VAProfileVP9Profile3            : VAEntrypointVLD
          VAProfileVP9Profile3            : VAEntrypointEncSliceLP
          VAProfileHEVCMain12             : VAEntrypointVLD
          VAProfileHEVCMain12             : VAEntrypointEncSlice
          VAProfileHEVCMain422_10         : VAEntrypointVLD
          VAProfileHEVCMain422_10         : VAEntrypointEncSlice
          VAProfileHEVCMain422_12         : VAEntrypointVLD
          VAProfileHEVCMain422_12         : VAEntrypointEncSlice
          VAProfileHEVCMain444            : VAEntrypointVLD
          VAProfileHEVCMain444            : VAEntrypointEncSliceLP
          VAProfileHEVCMain444_10         : VAEntrypointVLD
          VAProfileHEVCMain444_10         : VAEntrypointEncSliceLP
          VAProfileHEVCMain444_12         : VAEntrypointVLD
          VAProfileHEVCSccMain            : VAEntrypointVLD
          VAProfileHEVCSccMain            : VAEntrypointEncSliceLP
          VAProfileHEVCSccMain10          : VAEntrypointVLD
          VAProfileHEVCSccMain10          : VAEntrypointEncSliceLP
          VAProfileHEVCSccMain444         : VAEntrypointVLD
          VAProfileHEVCSccMain444         : VAEntrypointEncSliceLP
          VAProfileAV1Profile0            : VAEntrypointVLD
          VAProfileHEVCSccMain444_10      : VAEntrypointVLD
          VAProfileHEVCSccMain444_10      : VAEntrypointEncSliceLP
    

    vdpauinfo

    和上面一样。某处存在导致核心转储的错误。不过,似乎没有人注意到这一点。:-(

    但是,使用MALLOC_CHECK_并没有多大帮助。

    [enzo@Feynman ~] MALLOC_CHECK_=2 vdpauinfo 
    display: :0   screen: 0
    API version: 1
    Information string: OpenGL/VAAPI backend for VDPAU
    
    Video surface:
    
    name   width height types
    -------------------------------------------
    420     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
    422     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
    444     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
    420_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
    422_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
    444_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
    
    Decoder capabilities:
    
    name                        level macbs width height
    ----------------------------------------------------
    MPEG1                          --- not supported ---
    MPEG2_SIMPLE                   --- not supported ---
    MPEG2_MAIN                     --- not supported ---
    H264_BASELINE                  51 16384  2048  2048
    H264_MAIN                      51 16384  2048  2048
    H264_HIGH                      51 16384  2048  2048
    VC1_SIMPLE                     --- not supported ---
    VC1_MAIN                       --- not supported ---
    VC1_ADVANCED                   --- not supported ---
    MPEG4_PART2_SP                 --- not supported ---
    MPEG4_PART2_ASP                --- not supported ---
    DIVX4_QMOBILE                  --- not supported ---
    DIVX4_MOBILE                   --- not supported ---
    DIVX4_HOME_THEATER             --- not supported ---
    DIVX4_HD_1080P                 --- not supported ---
    DIVX5_QMOBILE                  --- not supported ---
    DIVX5_MOBILE                   --- not supported ---
    DIVX5_HOME_THEATER             --- not supported ---
    DIVX5_HD_1080P                 --- not supported ---
    H264_CONSTRAINED_BASELINE      51 16384  2048  2048
    H264_EXTENDED                  --- not supported ---
    H264_PROGRESSIVE_HIGH          --- not supported ---
    H264_CONSTRAINED_HIGH          --- not supported ---
    H264_HIGH_444_PREDICTIVE       --- not supported ---
    VP9_PROFILE_0                  --- not supported ---
    VP9_PROFILE_1                  --- not supported ---
    VP9_PROFILE_2                  --- not supported ---
    VP9_PROFILE_3                  --- not supported ---
    HEVC_MAIN                      --- not supported ---
    HEVC_MAIN_10                   --- not supported ---
    HEVC_MAIN_STILL                --- not supported ---
    HEVC_MAIN_12                   --- not supported ---
    HEVC_MAIN_444                  --- not supported ---
    HEVC_MAIN_444_10               --- not supported ---
    HEVC_MAIN_444_12               --- not supported ---
    
    Output surface:
    
    name              width height nat types
    ----------------------------------------------------
    B8G8R8A8         16384 16384    y  
    R8G8B8A8         16384 16384    y  
    R10G10B10A2      16384 16384    y  
    B10G10R10A2      16384 16384    y  
    A8               16384 16384    y  
    
    Bitmap surface:
    
    name              width height
    ------------------------------
    B8G8R8A8         16384 16384
    R8G8B8A8         16384 16384
    R10G10B10A2      16384 16384
    B10G10R10A2      16384 16384
    A8               16384 16384
    
    Video mixer:
    
    feature name                    sup
    ------------------------------------
    DEINTERLACE_TEMPORAL             -
    DEINTERLACE_TEMPORAL_SPATIAL     -
    INVERSE_TELECINE                 -
    NOISE_REDUCTION                  -
    SHARPNESS                        -
    LUMA_KEY                         -
    HIGH QUALITY SCALING - L1        -
    HIGH QUALITY SCALING - L2        -
    HIGH QUALITY SCALING - L3        -
    HIGH QUALITY SCALING - L4        -
    HIGH QUALITY SCALING - L5        -
    HIGH QUALITY SCALING - L6        -
    HIGH QUALITY SCALING - L7        -
    HIGH QUALITY SCALING - L8        -
    HIGH QUALITY SCALING - L9        -
    
    parameter name                  sup      min      max
    -----------------------------------------------------
    VIDEO_SURFACE_WIDTH              -
    VIDEO_SURFACE_HEIGHT             -
    CHROMA_TYPE                      -
    LAYERS                           -
    
    attribute name                  sup      min      max
    -----------------------------------------------------
    BACKGROUND_COLOR                 -
    CSC_MATRIX                       -
    NOISE_REDUCTION_LEVEL            -
    SHARPNESS_LEVEL                  -
    LUMA_KEY_MIN_LUMA                -
    LUMA_KEY_MAX_LUMA                -
    
    
    Segmentation fault (core dumped)
    

    我怀疑某些 VDPAU 库中存在错误,导致此错误以及随后无法使用硬件加速。不过只是猜测。

    真实世界

    现实可能会令人失望地偏离我们的愿望。

    在一个选项卡上播放视频(我使用 Youtube),然后在另一个选项卡上打开chrome://media-internals,选择播放器选项卡。在最近播放器中选择名为 的项目blob:https://www.youtube.com/...。

    在Player 属性中,您可以找到这样的行:

    kVideoDecoderName   "Dav1dVideoDecoder"
    

    这不是硬件解码器,应该是VDAVideoDecoder。

    在下一个日志区域中,您可以找到一些线索:

    00:00:00.321    info    "Selected FFmpegAudioDecoder for audio decoding, config: codec: opus, profile: unknown, bytes_per_channel: 4, channel_layout: STEREO, channels: 2, samples_per_second: 48000, sample_format: Float 32-bit, bytes_per_frame: 8, seek_preroll: 80000us, codec_delay: 312, has extra data: true, encryption scheme: Unencrypted, discard decoder delay: true, target_output_channel_layout: STEREO, has aac extra data: false"
    00:00:00.321    info    "Failed to initialize DecryptingVideoDecoder"
    00:00:00.321    info    "Failed to initialize VDAVideoDecoder"
    00:00:00.321    info    "Failed to initialize VpxVideoDecoder"
    00:00:00.322    info    "Effective playback rate changed from 0 to 1"
    00:00:00.322    event   "kPlay"
    00:00:00.325    kIsVideoDecryptingDemuxerStream false
    00:00:00.325    kVideoDecoderName   "Dav1dVideoDecoder"
    00:00:00.325    kIsPlatformVideoDecoder false
    

    您也可以intel_gpu_top在另一个终端窗口中使用(sudo在 ArchLinux 中需要,不确定 Ubuntu)。

    我有四个可用的“引擎”:“渲染/3D”、“Blitter”、“视频”和“视频增强”。

    During the browser play I can see the first two engines being busy, while "Video" is just idling. The video decoder engine provided by my GPU isn't in use at all!

    It seems like the browser is not able to use hardware accelerated video, despite it thinks it should.

    Let's make a different check.

    VLC

    It looks like VLC can make use of the hardware acceleration. Start it up with the GUI and go to Tools > Preferences > Input & Codecs and choose "Automatic" option under Hardware-accelerated decoding. Then close it and play a test video from command line (to get some diagnostics output).

    [enzo@Feynman ~] vlc ATestVideo.AC3.1080p.x264-WRM.mkv 
    VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2)
    [00005597db23e640] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
    [00005597db311900] main audio output error: too low audio sample frequency (0)
    [00007ff9e8d2fc00] main decoder error: failed to create audio output
    [00005597db311900] vlcpulse audio output error: digital pass-through stream connection failure: Not supported
    [00005597db311900] main audio output error: module not functional
    [00007ff9e8d2fc00] main decoder error: failed to create audio output
    [00007ff9c8005d20] gl gl: Initialized libplacebo v3.120.3 (API v120)
    [00007ff9e8c0d6b0] avcodec decoder: Using Intel iHD driver for Intel(R) Gen Graphics - 21.4.3 () for hardware decoding
    

    In the last two lines is says it is using hardware decoding. As we don't trust the logs, in another terminal window you can run intel_gpu_top and see that the "Video" resource is now being actively used.

    Firefox

    I know this is a little bit beyond the original scope (Chrome), but I think it's worth mentioning it. With Firefox it is possible to see some hardware accelerated video decode in action, thanks to VA-API, both under XOrg and Wayland.

    A guide on ArchLinux' wiki (link below) will guide you (at your own risk) on how to modify a few toggles to enable hardware accelerated video while our usual intel_gpu_top will show whether the GPU is working or not.

    Vimeo, for example, seems to be able to take advantage of this support, while YouTube requires a specific browser extension in order to disable the VP9 video codec.

    Similarly, WebRTC-based applications like Google Meet seem to work, if you also set media.webrtc.platformencoder to true. Mirosoft Teams is not supported under Firefox.

    That same extension exists for Chrome, but it seems it is not as effective as in Firefox.

    Wrap up

    It looks like hardware acceleration for video decoding is kicking and live in Linux.

    This would then point at bugs in the Chromium-based browser(s) more than in the environment.

    Maybe the future will be brighter. But not now.

    References

    Mainly from ArchLinux wiki, but I think those details can be applied to a large number of other distros.

    https://wiki.archlinux.org/title/Hardware_video_acceleration https://wiki.archlinux.org/title/Chromium#Hardware_video_acceleration https://wiki.archlinux.org/title/VLC_media_player#Hardware_video_acceleration https://wiki.archlinux.org/title/firefox#Hardware_video_acceleration

    • 2

相关问题

  • 通过 playonlinux 使用 Acrobat Reader DC 在 Firefox 或 Chrome 中打开 PDF 文件

  • 如何为 linix 构建 chromium dist(最好是 zip)?

  • 播放带有嵌入动画的 pdf

  • 来自 PNG 帧的 H.264/MPEG-4:如何以及如何调整压缩

  • 旋转网络摄像头和屏幕(纵向模式)

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve