PCsuggest

  • Quick tip
  • SECURITY
  • NETWORKING
  • OpenWrt
  • HARDWARE

Hardware accelerated video decoding in Chromium for Linux

Updated - October 19, 2017 by Arnab Satapathi

If you're using a laptop you may be familiar with playing videos on Chrome or Chromium sucks the battery pretty quick.

Well, Google Chrome or Chromium are not video players, but they can play almost  every video quite well.

And in case of watching youtube or other videos online, no one bothers to play that video with some other software that supports GPU accelerated video playback.

A laptop suffers most by this glitch in browsers, but even if you're on a desktop, you might want to take advantage of your GPU, let the GPU do what it deserved to do.

So, if you're planning to play youtube or other videos efficiently in Chromium browser, this tutorial is for you, let's get started ...

Contents

  • 1.  Why is this happening ?
  • 2. Install Chromium Beta with hardware acceleration enabled
  • 3. Checking hardware accelerated video decoding capability
  • Thoughts, Credits and Conclusion

1.  Why is this happening ?

It's simply because lack of proper H.264 decoding support in browsers, hardware accelerated video decoding is disabled in Chrome/Chromium for Linux.

There is another problem, most videos on youtube are encoded with VP9/VP8 codec, but older GPUs can't decode VP8 or VP9 at all, that could be fixed easily with the h264ify Chrome extension.

Though chrome://gpu URL says it can decode videos with GPU if Override software rendering list chrome flag is enabled, but actually it can't, more about this here.

chrome_gpu_decode1

Let's have a look at the chrome://flags URL for the Hardware-accelerated video decode flag. This feature is only available on Mac, Windows and Chrome OS, and there is no way to enable it with default Linux builds.

amazon prime logo
Try AmazonPrime for free
Enjoy free shipping and One-Day delivery, cancel any time.

chrome_gpu_decode_not_available

There is a workaround for this problem too, patch the source to enable chrome VAAPI support and rebuild, or use already patched Chromium builds, the second option is fairly easier.

2. Install Chromium Beta with hardware acceleration enabled

While patching chromium source and compiling it is the best choice for learning, but it's pretty impractical for most. Compiling Chromium from source also requires a descent hardware setup, you might want to check their official instruction.

So If you're running Ubuntu or Debian, why not use prebuilt Chromium Beta from Saikrishna Arcot's PPA ? Here the link to the PPA.

It's pretty simple to installing Chromium Beta with hardware acceleration enabled in Ubuntu,

sudo add-apt-repository ppa:saiarcot895/chromium-beta

sudo apt-get update

sudo apt-get install chromium-browser

You will also need proper GPU drivers for accelerated video decoding, for Intel GPUs install VA-API driver and relate shared libraries.

sudo apt-get install libva-glx1 libva-x11-1 i965-va-driver

Note: I was trying to use VDPAU for decoding videos with NVIDIA Optimus GPUs on Chromium, but that seems to be not possible at this moment.

3. Checking hardware accelerated video decoding capability

Now you can see the Hardware-accelerated video decode flag in enabled and it's available for Linux.

chromium_gpu_decode_enabled

You can confirm that accelerated decoding is working by running a local or online 1080p video encoded with h.264, may be VP9 if your GPU supports decoding that, testing that on the chrome://media-internals URL, Example screenshot below,

chromium_gpuvideodecoder Here yo can see video_decoder is GpuVideoDecoder , and the Video codec is avc.

Thoughts, Credits and Conclusion

No doubt that Saikrishna Arcot deserves a warm "thank you" for patching latest Chromium and maintaining the PPAs,  excellent work, seriously !!!!

It would be a little better if the Saikrishna fixes the Chromium API key related problem, or completely disabling it.

Hope you all enjoyed this this tutorial, don't forget to share if you think it's helpful.

Filed Under: featured, how to Tagged With: browser, chromium, webkit

Your comments
  1. Jakub says

    October 16, 2020

    Hi, this approach is not working anymore in 2020. Is there any updated tutorial? Thank you!

    Reply
  2. guige says

    May 6, 2019

    I had install step by step. but video decoder is 'VpxVideoDecoder' always.

    Reply
  3. Adrian says

    March 8, 2018

    Thanks very much for posting this. 1080p30 3mb/s High@L4.1 works great with GPU decoding on my Celeron N3000 which can barely handle 720p30 in software.

    Unfortunately Widevine content is still not accelerated. Netflix does work in these builds of Chromium, assuming you change to a Chrome user agent, but rendering is performed in software, even after disabling the GPU whitelist.

    Reply
    • Arnab Satapathi says

      March 8, 2018

      I think VA-API is not smart enough to decode widevine encrypted streams.

      Reply
      • Akarshan Biswas says

        September 15, 2018

        Unfortunately no! Protected videos are not hardware accelerated and there is no way to do that. 🙁 I'm a maintainer of chromium-vaapi for Fedora.

        Reply
        • Arnab Satapathi says

          September 15, 2018

          Glad to know!
          I appreciate your contribution for the Linux community.

          Reply
        • mrez says

          November 6, 2019

          Thanks Akarshan for the Fedora package. One question. I am using the chromium-beta package from the mentioned ppa. Even though I had no problem with chromium on Fedora on ubuntu after couple of seconds becasue of hardware acceleration youtube page won't open. When I desable hardware decode everything comes back to normal. Where do you think I can report this and have you heard of this issue?

          Reply
  4. Guy CLO says

    February 26, 2018

    Thank you very much.

    Reply
  5. Pierre says

    January 24, 2018

    FYI, the Chromium API key error message can be hidden with the parameters --disable-infobars

    Reply
    • Pierre says

      February 28, 2018

      Unfortunately it doesn't seems to work anymore since version 65...

      Reply
      • Arnab Satapathi says

        February 28, 2018

        Checked it with a 1080p video, on youtube and from the file:// URL, VA-API decoding is working on Chromium 65.0.3298.3 , Developer Build.

        Reply
  6. umbro says

    January 20, 2018

    My Desktop PC:- Asus P5KC Intel Q6600 2.4GHz 4Gb RAM DDR3 Geforce GT1030 Lubuntu 64bit Geforce GT1030 driver version:- 390.12

    Hi. I am using the right drivers from Linux Lubuntu CPU is 80% to 100% on YouTube 4K video

    on YouTube playing on 4K @60fps very high CPU i tried h264ify still lag and very high CPU tried different Internet browser, for example chrome, Firefox, Opera still lag and very high CPU. tried patched chromium still lag very high CPU

    i don't have this problem with windows 10 (64bit) on windows 10 64bit CPU usage is 10% or 20% to 30% on YouTube 4K video all web browsers work excellent on windows 10, only problem is Memory (RAM) on windows 10

    so that's why i tried Linux Lubuntu

    Reply
    • Arnab Satapathi says

      January 20, 2018

      I don't think that VA-API is yet supported with Nvidia cards at least on Linux.
      Yeah, Windows tends to perform much better in terms of video decoding on browsers, specially Edge browser.

      Reply
  7. Chocotov says

    November 29, 2017

    I've followed these instructions and got it working on my new Dell XPS 13 9360 (i7 8550u) with Ubuntu 16.04.

    I can see a reduced cpu usage when watching 1080p on youtube. Sadly, the power consumption is not positively affected currently on my setup. Powertop reports a power consumption of about 15 watts, regardless of accelerated video being active or not. The fan starts to blow after a while.

    In Windows with Chrome and Edge the accelerated video is so efficient that the fan doesn't need to blow, even at the highest setting of 2160p. I've verified with the stats for nerds that VP9 was being used.

    Reply
    • Benz says

      December 1, 2017

      Does chrome://media-internals show GpuVideoDecoder?

      Reply
      • Chocotov says

        December 9, 2017

        It shows GpuVideoDecoder.

        Reply
    • Arnab Satapathi says

      December 1, 2017

      Which codec is used while playing videos on Ubuntu?
      Seems like Windows is doing better at least in this case 🙂

      Reply
      • Chocotov says

        December 9, 2017

        Vp9 was used in youtube. At the moment software decoding running at full screen seems to have the lowest power consumption according to powertop (arround 9 watts). In a window its a bit higher. Hardware decoder is arround 15 watts for 1080p vp9.

        I noticed that hardware accelerated playback wasn't working with mpv and a vp9 video file. I'll investigate that further:

        # mpv --hwdec=vaapi --msg-level=vd=debug out9.webm

        [vd] Container reported FPS: 0.000000
        [vd] Codec list:
        [vd] lavc:vp9 - Google VP9
        [vd] lavc:libvpx-vp9 (vp9) - libvpx VP9
        [vd] Opening video decoder lavc:vp9
        [vd] Not trying to use hardware decoding: codec vp9 is not on whitelist, or does not support hardware acceleration.
        [vd] Using software decoding.
        [vd] Detected 8 logical cores.
        [vd] Requesting 9 threads for decoding.
        [vd] Selected video codec: Google VP9 [lavc:vp9]

        Reply
  8. Benz says

    October 19, 2017

    Unfortunately it doesn't work for me, still FFmpegVideoDecoder. (Debian Testing and HD4600)
    The link to kelvins blog ends up on a porn site, btw.

    Reply
    • Arnab Satapathi says

      October 19, 2017

      How you installed it on Debian? Downloaded the deb package from the PPA repo?
      I think there could be some shared library incompatibility.
      Quite unfortunate, the link, removing it.

      Reply
      • Benz says

        October 20, 2017

        Yes, I've installed chromium beta from saiarcot895.
        Hardware-accelerated video decode is enabled in chrome://flags.
        I don't get any error messages on stdout, I've no idea where to start.

        Reply
        • Arnab Satapathi says

          October 20, 2017

          To check VAAPI acceleration, run chromium from command line, you should get some output like below in the stdout.
          libva info: VA-API version 0.39.0
          libva info: va_getDriverName() returns 0
          libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
          libva info: Found init function __vaDriverInit_0_39
          libva info: va_openDriver() returns 0

          If there's no such output, then maybe some shared library conflict or mismatch. Also install the intel-microcode package, missing microcode could be an issue.

          Reply
          • Benz says

            October 20, 2017

            Unfortunately not. I only get an unrelated error message about root certs. Nothing about libva.
            vdpau is set up correctly and according to vdpauinfo it is able do decode h264.

          • Arnab Satapathi says

            October 20, 2017

            Nothing about libva while running chromium from command line?
            Here's the problem starts, however I'm clueless.
            Note: Chromium can't use VDPAU till now, hardware acceleration depends on VA-API, though there's some word around.
            Checked everything with chromium 63 on Ubuntu 16.04.3. it's working fine till now.

          • Benz says

            October 20, 2017

            Yeah it's weird that I don't get any messages regarding libva on stdout. Everybody seems to get either a positive or an error status message.

            Well, thanks anyway for the article and the tips. I think it's important that people are aware of this.

          • Benz says

            October 25, 2017

            I've reinstalled chromium and now i get at least the VA-API output on startup. But still it doesn't make use of it. Apparently a version mismatch:
            "This build of Chromium requires VA-API version 0.39, system version: 0.40"

          • Arnab Satapathi says

            October 25, 2017

            Thanks again for the feedback, seems like it's a shared library version mismatch related problem.

          • Benz says

            October 20, 2017

            vainfo output: https://pastebin.com/6jWzSB96

      • topdjgod says

        November 3, 2017

        How to install chromium beta on Debian? I try to use "sudo add-apt-repository ppa:saiarcot895/chromium-beta" but it seems that can't work on Debian.

        Reply
        • Arnab Satapathi says

          November 3, 2017

          You can directly add the PPA repo or download it from here. The Chromium beta channel is more active now.
          PPA repo,
          deb http://ppa.launchpad.net/saiarcot895/chromium-dev/ubuntu xenial main
          Download link,
          http://ppa.launchpad.net/saiarcot895/chromium-dev/ubuntu/pool/main/c/chromium-browser/
          Let me know if it works with Debian or not.

          Reply
          • topdjgod says

            November 6, 2017

            After fixing NO_PUBKEY issue, chromium-browser still needs a depends package libfontconfig1 (>= 2.11.94) but 2.11.0-6.7+b1 is to be installed on Debian 9 (Stretch).

          • Arnab Satapathi says

            November 6, 2017

            Yeah, such dependencies related problems are bound to happen, Ubuntu PPAs and Debian stable doesn't mix very well.

  9. Antonio says

    October 14, 2017

    Work ingreso in raspberry pi 3 with jessie

    Reply
  10. Tolly says

    July 14, 2017

    I have a question, can I install this Beta version with video decode accelerated on linux with ARM? I have do as floows :
    sudo add-apt-repository ppa:saiarcot895/chromium-beta

    sudo apt-get update

    sudo apt-get install chromium-browser

    But my chrome browser still could not enable accelerated video decode.
    Thank you.

    Reply
    • Arnab Satapathi says

      July 14, 2017

      Hi Tolly,
      No you can't do that on ARM hardware, as this hardare decoding process depends on VA-API.
      Any ARM SoC doesn't support VA-API till now.

      Reply
  11. Ikem says

    July 13, 2017

    > Here the _link to the PPA_.

    The "l" is not part of the link.

    Reply
    • Arnab Satapathi says

      July 13, 2017

      Thanks !
      My eyes skipped that every time, now fixed it.

      Reply
  12. George says

    July 8, 2017

    Hello,
    I have a question about the patch. Using the Chromium Beta with HW Accelators enabled , we will be able to use Intel HW for vpx video streams?
    Thank you in advance

    Reply
    • Arnab Satapathi says

      July 8, 2017

      Hi George, I've never tested any vpx encoded video on Chromium, as my laptops intel GPU doesn't support VPx decoding.

      But I beleive it's NOT possible yet, VPx codec implementation on Intel GPU is fairly recent, even Intel based chromebooks depends on CPU to decode VP9 streams.

      If you have the hardware, then please give it a try and share your results here.

      Reference:
      https://www.reddit.com/r/chromeos/comments/4j8jun/does_chromeos_support_hardware_decoding_for_vp9/
      https://www.reddit.com/r/chromeos/comments/4mfdy9/do_chromebooks_use_hardware_acceleration_vaapi_to/

      Reply
  13. Ubuntuuser says

    May 21, 2017

    Well, I just noticed that the video that causes the high cpu load is encoded with VP9 which apparently can't be decoded by my GTX 860m. So screw what I wrote above, the hardware acceleration should work after activating the flag. Also it would be helpful if comments on here could be edited 😀

    Reply
    • Arnab Satapathi says

      May 21, 2017

      Hey, thanks for the feedbacks.
      I doubt that any optimus GPU could be used for hardware accelerated video decoding in chrome.

      Latest intel GPUs can decode vp9, but i think it's not implemented in chrome yet.

      And thanks for the tip, I should implement editable commants.

      Reply
  14. Ubuntuuser says

    May 21, 2017

    You can just go to chrome://flags and enable the flag "Override software rendering list". That activates hardware acceleration too! 🙂 I think it would be nice if you'd update your post to include this because at first I really thought I'd have to use the PPA and Chromium Beta.

    Reply
    • Ubuntuuser says

      May 21, 2017

      Well, it seems like I've been glad too early - chrome://gpu shows that Video Decode and VPx Video Decode is enabled but my CPU usage still goes up to 60% when watching a YouTube video 🙁 But maybe my solution works for others. I'm using a latop with iGPU and a dedicated gpu (Nvidia GTX 860m) so that might be why it still doesn't work.

      Reply
    • Ubuntuuser says

      May 21, 2017

      I meant that Video Decode and VPx Video Decode is Hardware accelerated according to chrome://gpu. Apparently it still isn't though :/

      Reply
      • AngryPenguin says

        September 16, 2017

        No. If u use only "Override software rendering list" then HW decoding won't work for u but you can see that HW is enabled but trust me its not. You need for this manually compiling Chromium with patch for VAAPI support or use ppa for Ubuntu maintained by Saikrishna Arcot. Then all should work and "Override software..." should be enabled in default.
        Soon should be release official Chrome/Chromium with VAAPI but this only as experiment and then you need manually enabled special vaapi decode flag in chrome:flags but I think we need wait two or three more chromium/chrome version.

        Reply
        • Arnab Satapathi says

          September 16, 2017

          Fabulous!

          Reply
  15. Marius Dalacu says

    February 13, 2017

    Hi Arnab, if i am tring to use this on a system with NVIDIA card, should it work? Both vainfo and vdpauinfo have correct output but in Chromium, every file i throw at it is decoded with ffmpegvideodecoder. Also the flags are properly set.

    Reply
    • Arnab says

      February 13, 2017

      Accelerated video decoding (h.264 and vp9) on Chromium is a mixed success, it works for few people while refuses to work for some.

      If you NVIDIA card is Optimus, then it's not supported at all, unfortunately my NVIDIA GPU is Optimus, so I cant even test it.

      Anyway if you can get it work, please don't forget to notify me.

      Reply
  16. linuxscouser says

    January 27, 2017

    So I'm still not getting gpuvideodecoder on media-internals. It's showing either vpxvideodecoder on youtube, or ffmpegvideodecoder on twitch. Performance seems to be better but I'm wondering if I'm not fully utilising my GPU. I notice sometimes, my GPU will go back to low performance and 60 fps videos will drop to 30 fps.

    Reply
    • Arnab says

      January 27, 2017

      Thanks ! Chrome behaves really weird in Linux.

      May be your GPU supports both H.264 and VP9 decoding, and chrome is choosing VP9.

      And I've no idea about what is twitch, just heard the name.

      Reply
    • AngryPenguin says

      September 16, 2017

      It shows VPX decoder because your browser prefer VP9 instead h264. You need use h264ify addon to disable VP9, then your browser start prefer H264 and then you should see GPUVideodecoder. Worth to add VP9 is not hardwared acceleration on Linux still (only for new NVIDIA GPU on Windows but this also with many issues).
      So for now stay with h264.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © PCsuggest.com · All rights reserved.

  • Home
  • About
  • Contact
  • Privacy Policy
  • Sitemap