Merge pull request #10168 from GraveAccent/master

GraveAccent完成翻译
This commit is contained in:
Martin♡Adele 2018-09-12 21:40:05 +08:00 committed by GitHub
commit d0ea975387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 112 additions and 113 deletions

View File

@ -1,113 +0,0 @@
Grave Accent翻译中 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint
======
You may have noticed that watching HD videos from Youtube and other similar websites in Google Chrome or Chromium browsers on Linux considerably increases your CPU usage and, if you use a laptop, it gets quite hot and the battery drains very quickly. That's because Chrome / Chromium (Firefox too but there's no way to force this) doesn't support hardware accelerated video decoding on Linux.
**This article explains how to install a Chromium development build which includes a patch that enables VA-API on Linux, bringing support for GPU accelerated video decoding, which should significantly decrease the CPU usage when watching HD videos online. The instructions cover only Intel and Nvidia graphics cards, as I don't have an ATI/AMD graphics card to try this, nor do I have experience with such graphics cards.**
This is Chromium from the Ubuntu (18.04) repositories without GPU accelerated video decoding playing a 1080p YouTube video:
![](https://4.bp.blogspot.com/-KtUQni2PMvE/W3KlJ62yLLI/AAAAAAAABW4/NrNVFaTAkZ8AmwqWwRvWD6czT51ni-R-gCLcBGAs/s1600/chromium-default-no-accel.png)
The same 1080p YouTube video playing in Chromium with the VA-API patch and hardware accelerated video decode enabled on Ubuntu 18.04:
![](https://4.bp.blogspot.com/-0c-wb4UNhW8/W3KlQBfeFnI/AAAAAAAABW8/WVUAYzM6hA8wRTlCcrPXPMpoXoFVR6b1QCLcBGAs/s1600/chromium-hardware-acceleration-enabled.png)
Notice the CPU usage in the screenshots. Both screenshots were taken on my old, but still quite powerful desktop. On my laptop, the Chromium CPU usage without hardware acceleration goes way higher.
The _Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only_ " was was initially submitted to Chromium more than a year ago, but it has yet to be merged.
Chrome has an option to override the software rendering list (
`#ignore-gpu-blacklist`
), but this option does not enable hardware accelerated video decoding. After enabling this option, you may find the following when visiting
`chrome://gpu`
: " _Video Decode: Hardware accelerated_ ", but this does not mean it actually works. Open a HD video on YouTube and check the CPU usage in a tool such as
`htop`
(this is what I'm using in the screenshots above to check the CPU usage) - you should see high CPU usage because GPU video decoding is not actually enabled. There's also a section below for how to check if you're actually using hardware accelerated video decoding.
**The patches used by the Chromium Ubuntu builds with VA-API enabled used in this article are available[here][1].**
### Installing and using Chromium browser with VA-API support on Ubuntu or Linux Mint
**It should be clear to everyone reading this that Chromium Dev Branch is not considered stable. So you might find bugs, it may crash, etc. It works fine right now but who knows what may happen after some update.**
**What's more, the Chromium Dev Branch PPA requires you to perform some extra steps if you want to enable Widevine support** (so you can play Netflix videos and paid YouTube videos, etc.), **or if you need features like Sync** (which needs registering an API key and setting it up on your system). Instructions for performing these tweaks are explained in the
Chromium with the VA-API patch is also available for some other Linux distributions, in third-party repositories, like
**1\. Install Chromium Dev Branch with VA-API support.**
There's a Chromium Beta PPA with the VA-API patch, but it lacks vdpau-video for Ubuntu 18.04. If you want, you can use the `vdpau-va-driver` from the You can add the Chromium
```
sudo add-apt-repository ppa:saiarcot895/chromium-dev
sudo apt-get update
sudo apt install chromium-browser
```
**2\. Install the VA-API driver**
For Intel graphics cards, you'll need to install the `i965-va-driver` package (it may already be installed):
```
sudo apt install i965-va-driver
```
For Nvidia graphics cards (it should work with both the open source Nouveau drivers and the proprietary Nvidia drivers), install `vdpau-va-driver` :
```
sudo apt install vdpau-va-driver
```
**3\. Enable the Hardware-accelerated video option in Chromium.**
Copy and paste the following in the Chrome URL bar: `chrome://flags/#enable-accelerated-video` (or search for the `Hardware-accelerated video` option in `chrome://flags`) and enable it, then restart Chromium browser.
On a default Google Chrome / Chromium build, this option shows as unavailable, but you'll be able to enable it now because we've used the VA-API enabled Chromium build.
**4\. Install[h264ify][2] Chrome extension.**
YouTube (and probably some other websites as well) uses VP8 or VP9 video codecs by default, and many GPUs don't support hardware decoding for this codec. The h264ify extension will force YouTube to use H.264, which should be supported by most GPUs, instead of VP8/VP9.
This extension can also block 60fps videos, useful on lower end machines.
You can check the codec used by a YouTube video by right clicking on the video and selecting `Stats for nerds` . With the h264ify extension enabled, you should see avc / mp4a as the codecs. Without this extension, the codec should be something like vp09 / opus.
### How to check if Chromium is using GPU video decoding
Open a video on YouTube. Next, open a new tab in Chromium and enter the following in the URL bar: `chrome://media-internals` .
On the `chrome://media-internals` tab, click on the video url (in order to expand it), scroll down and look under `Player Properties` , and you should find the `video_decoder` property. If the `video_decoder` value is `GpuVideoDecoder` it means that the video that's currently playing on YouTube in the other tab is using hardware-accelerated video decoding.
![](https://4.bp.blogspot.com/-COBJWVT_Y0Q/W3KnG7AeHsI/AAAAAAAABXM/W2XAJA_S0BIHug4eQKTMOdIfXHhgkXhhQCLcBGAs/s1600/chromium-gpuvideodecoder-linux.png)
If it says `FFmpegVideoDecoder` or `VpxVideoDecoder` , accelerated video decoding is not working, or maybe you forgot to install or disabled the h264ify Chrome extension.
If it's not working, you could try to debug it by running `chromium-browser` from the command line and see if it shows any VA-API related errors. You can also run `vainfo` (install it in Ubuntu or Linux Mint: `sudo apt install vainfo`) and `vdpauinfo` (for Nvidia; install it in Ubuntu or Linux Mint: `sudo apt install vdpauinfo`) and see if it shows an error.
--------------------------------------------------------------------------------
via: https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html
作者:[Logix][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://plus.google.com/118280394805678839070
[1]:https://github.com/saiarcot895/chromium-ubuntu-build/tree/master/debian/patches
[2]:https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal
[3]:https://chromium-review.googlesource.com/c/chromium/src/+/532294
[4]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev
[5]:https://aur.archlinux.org/packages/?O=0&SeB=nd&K=chromium+vaapi&outdated=&SB=n&SO=a&PP=50&do_Search=Go
[6]:https://aur.archlinux.org/packages/libva-vdpau-driver-chromium/
[7]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta
[8]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev/+packages

View File

@ -0,0 +1,112 @@
如何在 Ubuntu 或 Linux Mint 启用硬件加速的视频解码
======
你或许已经注意到了,在 Linux 上使用 Google Chrome 或 Chromium 浏览器在 YouTube 或其它类似网站观看高清视频会增加你的 CPU 使用率如果你用的是笔记本电脑会发热而且电池会很快用完。这是因为Chrome/ChromiumFirefox 也是如此,但是 Firefox 的问题没有办法解决)在 Linux 上不支持硬件加速的视频解码。
**这篇文章讲述了如何在 Linux 环境安装带有 VA-API 补丁的 Chromium 开发版,它支持 GPU 加速的视频解码,可以显著减少观看在线高清视频时的 CPU 使用率,这篇教程只适用于 Intel 和 Nvidia 的显卡,我没有 ATI/AMD 的显卡可以试验,也没有使用过这几种显卡。**
这是 Chromium 浏览器在 Ubuntu18.04 中,没有 GPU 加速视频解码时正在播放一个 1080p 的 YouTube 视频:
![](https://4.bp.blogspot.com/-KtUQni2PMvE/W3KlJ62yLLI/AAAAAAAABW4/NrNVFaTAkZ8AmwqWwRvWD6czT51ni-R-gCLcBGAs/s1600/chromium-default-no-accel.png)
这是带有 VA-API 补丁的 Chromium 浏览器在 Ubuntu18.04 中GPU 加速视频解码时正在播放同样的 1080p 的 YouTube 视频:
![](https://4.bp.blogspot.com/-0c-wb4UNhW8/W3KlQBfeFnI/AAAAAAAABW8/WVUAYzM6hA8wRTlCcrPXPMpoXoFVR6b1QCLcBGAs/s1600/chromium-hardware-acceleration-enabled.png)
注意截图中的 CPU 使用率。两张截图都是在我老旧而依然强大的桌面上捕捉的。在我的笔记本上,没有硬件加速的 Chromium 带来更高的CPU使用率。
"只需 VAAPI 即可在 Linux 启用 VAVDAVAVEA 和 VAJDA" 这篇文章在一年多以前就提交给了Chromium但是它还没有合并请求。
Chrome有一个选项可以覆盖软件渲染列表
`#ignore-gpu-blacklist`
),但是这个选项不能启用硬件加速的视频解码。启用这个选项以后,你或许会在访问
`chrome://gpu`
时发现这些信息“_Video Decode: Hardware accelerated_ “,然而这个并不意味着真的有效。在 YouTube 打开一个高清视频并用工具查看CPU使用率如
`htop`
(这是我在以上截图中用来查看 CPU 使用率的)。因为 GPU 视频解码没有真的被启用,你应该看到较高的 CPU 使用率。下面有一个部分是关于你是否真的在使用硬件加速的视频解码的。
**文中使用的 Chromium 浏览器 Ubuntu 版启用 VA-API 的补丁在[这个地址][1]可以获得**
### 在 Ubuntu 和 Linux Mint 安装和使用带有 VA-API 支持的 Chromium 浏览器
**每个人都该知道 Chromium 开发版本没有理想中那么稳定。所以你可能发现 bug它可能会发生崩溃等情况。它现在可能正常运行但是谁知道几次更新以后会发生什么。**
**还有,如果你想启用 Widevine 支持(这样你才能观看 Netflix 视频和 YouTube 付费视频Chromium dev 分支 PPA 要求你执行一些额外步骤。 ** **如果你想要一些功能,比如同步,也是如此**(需要注册 API key还要在你的系统上设置好。执行这些任务的说明在本文中被详细解释了。
带有 VA-API 补丁的 Chromium 在其它Linux发行版本也可以获得但是这里选择 Ubuntu。
**1\. 安装带有 VA-API 补丁的 Chromium **
有一个带 VA-API 补丁的 Chromium Beta但是它缺少适用于 Ubuntu 18.04 的 vdpau-video。
```
sudo add-apt-repository ppa:saiarcot895/chromium-dev
sudo apt-get update
sudo apt install chromium-browser
```
**2\. 安装 VA-API 驱动**
对于Intel的显卡你需要安装 `i965-va-driver` 这个包(它可能早就安装好了)
```
sudo apt install i965-va-driver
```
对于 Nvidia 的显卡(在开源和闭源的 Nvidia 驱动上,它应该都有效), 安装`vdpau-va-driver` :
```
sudo apt install vdpau-va-driver
```
**3\. 在 Chromium 启用硬件加速视频选项**
复制这串地址,粘贴进 Chromium 的 URL 栏: `chrome://flags/#enable-accelerated-video` (或者在 `chrome://flags` 搜索 `Hardware-accelerated video` )并启用它,然后重启 Chromium 浏览器。
在默认的 Google Chrome / Chromium 版本,这个选项不可用,但是你可以在启用了 VP-API 的 Chromium 版本启用它。
**4\. 安装 [h264ify][2] Chrome 扩展**
YouTube可能还有其它一些网址也是如此默认使用 VP8 或 VP9 编码解码器,许多 GPU 不支持这种编码解码器的硬件解码。h264ify 会强制 YouTube 使用大多数 GPU 都支持的 H.264 而不是 VP8/VP9。
这个扩展还能阻塞 60fps 的视频,对低性能机器有用。
你可以点击这个视频并且选择 `Stats for nerds` 以查看编码解码器,如果启用了 h264ify 扩展,你可以看到编码解码器是 avc / mp4a。如果没有启用编码解码器应该是 vp09 / opus。
### 如何检查 Chromium 是否在使用 GPU 视频解码
在 YouTube 打开一个视频,然后,在 Chromium 打开一个新的标签页并将以下地址输入 URL 栏:
`chrome://media-internals`
`chrome://media-internals` 标签页中点击视频的URL为了展开它 往下滚动查看 `Player Properties` 的下面,你应该可以找到 `video_decoder` 属性。如果`video_decoder` 的值是 `GpuVideoDecoder` ,这说明当前在另一个标签页播放的 YouTube 视频正在使用硬件加速的的视频解码。
![](https://4.bp.blogspot.com/-COBJWVT_Y0Q/W3KnG7AeHsI/AAAAAAAABXM/W2XAJA_S0BIHug4eQKTMOdIfXHhgkXhhQCLcBGAs/s1600/chromium-gpuvideodecoder-linux.png)
如果它显示的是 `FFmpegVideoDecoder``VpxVideoDecoder` ,说明加速视频解码无效或者你忘记安装或禁用了 h264ify 这个 Chrome 扩展。
如果无效,你可以通过在命令行运行 `chromium-browser` ,通过查看是否有 VA-API 相关的错误显示出来以调试。你也可以运行`vainfo` (在 Ubuntu 或 Linux Mint 安装:`sudo apt install vainfo`)和 `vdpauinfo` (对于 Nvidia在 Ubuntu 或 Linux Mint 安装:`sudo apt install vdpauinfo`)并且查看是否有显示任何错误。
--------------------------------------------------------------------------------
via: https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html
作者:[Logix][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[GraveAccent](https://github.com/GraveAccent)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://plus.google.com/118280394805678839070
[1]:https://github.com/saiarcot895/chromium-ubuntu-build/tree/master/debian/patches
[2]:https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal
[3]:https://chromium-review.googlesource.com/c/chromium/src/+/532294
[4]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev
[5]:https://aur.archlinux.org/packages/?O=0&SeB=nd&K=chromium+vaapi&outdated=&SB=n&SO=a&PP=50&do_Search=Go
[6]:https://aur.archlinux.org/packages/libva-vdpau-driver-chromium/
[7]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta
[8]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev/+packages