Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Youtube - Chromium / Firefox - vaapi hw acceleration

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
heracle
Posts: 5
Joined: 2019-11-13 08:57

Youtube - Chromium / Firefox - vaapi hw acceleration

#1 Post by heracle »

Hi guys,
my problem is that i have very high CPU consumption when watching youtube.
Now before you crucify me let me say in short, that iv'e googled A LOT, tried A LOT of things, checked the forum here, and decided to write, because i'm sure most of you have the same problem as me.

To be more precise, i have 2 Thinkpad's T450 (debian stretch) and T490 (debian bullseye). When playing youtube let's say this link 1080p ( https://www.youtube.com/watch?v=DW4KWSfcGRU&t=50s ), the T450 has 25-35% load (top, process load)
and the newer T490 has 150%-250% (top, process load). Chromium is stock on both, no addons, no vaapi or whatsoever.
That brings me to doubt the installed codecs, since video is the same in chrome://media-internals i can see that different video_decoder is used, T450 - FFmpegVideoDecoder and T490 - VpxVideoDecoder (and there probably is some ffmpeg h264 VP8/VP9 youtube stream sorcery included).
Below are the packages i have installed_

Code: Select all

dpkg -la | grep ffmpeg
ii  cmus-plugin-ffmpeg                            2.8.0-2                              amd64        lightweight ncurses audio player (FFmpeg plugin)
ii  ffmpeg                                        7:4.2.1-2                            amd64        Tools for transcoding, streaming and playing of multimedia files
ii  ffmpeg2theora                                 0.30-1+b3                            amd64        Theora video encoder using ffmpeg
ii  gstreamer1.0-libav:amd64                      1.16.1-1                             amd64        ffmpeg plugin for GStreamer
ii  libffmpegthumbnailer4v5                       2.1.1-0.2+b1                         amd64        shared library for ffmpegthumbnailer
ii  libffms2-4:amd64                              2.23-4                               amd64        Cross platform ffmpeg wrapper library
ii  libxine2-ffmpeg:amd64                         1.2.9-1+b3                           amd64        MPEG-related plugins for libxine2

Code: Select all

dpkg -la | grep libav
ii  gstreamer1.0-libav:amd64                      1.16.1-1                             amd64        ffmpeg plugin for GStreamer
ii  libavahi-client3:amd64                        0.7-4+b1                             amd64        Avahi client library
ii  libavahi-common-data:amd64                    0.7-4+b1                             amd64        Avahi common data files
ii  libavahi-common3:amd64                        0.7-4+b1                             amd64        Avahi common library
ii  libavahi-core7:amd64                          0.7-4+b1                             amd64        Avahi's embeddable mDNS/DNS-SD library
ii  libavahi-glib1:amd64                          0.7-4+b1                             amd64        Avahi GLib integration library
ii  libavc1394-0:amd64                            0.5.4-5                              amd64        control IEEE 1394 audio/video devices
ii  libavcodec-dev:amd64                          7:4.2.1-2                            amd64        FFmpeg library with de/encoders for audio/video codecs - development files
ii  libavcodec-extra                              7:4.2.1-2                            all          FFmpeg library with extra codecs (metapackage)
ii  libavcodec-extra58:amd64                      7:4.2.1-2                            amd64        FFmpeg library with additional de/encoders for audio/video codecs
ii  libavdevice-dev:amd64                         7:4.2.1-2                            amd64        FFmpeg library for handling input and output devices - development files
ii  libavdevice58:amd64                           7:4.2.1-2                            amd64        FFmpeg library for handling input and output devices - runtime files
ii  libavfilter-dev:amd64                         7:4.2.1-2                            amd64        FFmpeg library containing media filters - development files
ii  libavfilter7:amd64                            7:4.2.1-2                            amd64        FFmpeg library containing media filters - runtime files
ii  libavformat-dev:amd64                         7:4.2.1-2                            amd64        FFmpeg library with (de)muxers for multimedia containers - development files
ii  libavformat58:amd64                           7:4.2.1-2                            amd64        FFmpeg library with (de)muxers for multimedia containers - runtime files
ii  libavresample-dev:amd64                       7:4.2.1-2                            amd64        FFmpeg compatibility library for resampling - development files
ii  libavresample4:amd64                          7:4.2.1-2                            amd64        FFmpeg compatibility library for resampling - runtime files
ii  libavutil-dev:amd64                           7:4.2.1-2                            amd64        FFmpeg library with functions for simplifying programming - development files
ii  libavutil56:amd64                             7:4.2.1-2                            amd64        FFmpeg library with functions for simplifying programming - runtime files

Code: Select all

dpkg -la | grep 264
ii  libx264-155:amd64                             2:0.155.2917+git0a84d98-2            amd64        x264 video coding library
ii  x264                                          2:0.155.2917+git0a84d98-2            amd64        video encoder for the H.264/MPEG-4 AVC standard

dpkg -la | grep 265
ii  libde265-0:amd64                              1.0.3-1+b1                           amd64        Open H.265 video codec implementation
ii  libde265-dev:amd64                            1.0.3-1+b1                           amd64        Open H.265 video codec implementation - development files
ii  libde265-examples                             1.0.3-1+b1                           amd64        Open H.265 video codec implementation - examples
ii  libx265-179:amd64                             3.2-2                                amd64        H.265/HEVC video stream encoder (shared library)
ii  x265                                          3.2-2                                amd64        H.265/HEVC video stream encoder
I'll compare the packages this evening from my T450 and post differences here (i doubt any)
I would appreciate if any one can point me the right direction or what i'm doing wrong. Thank you!

p.s. from chrome://media-internals/ i can see T450 uses "video_codec_name h264 " and T490 "video_codec_name VP9"

Update: checked packages on T450 that might be related with codecs/encoding/multimedia, seems like there is no difference in installed packages. T450 Chromium version is 73.0.3683.75 and T490 is 76.0.3809.100.
Last edited by heracle on 2019-11-18 10:57, edited 1 time in total.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox

#2 Post by stevepusser »

I haven't managed to get va-api working for any browser video, even with an Iridium browser native build that incorporates the Chromium patches that enable it, and changing the settings that enable it. Firefox doesn't support that at all.

I do have va-api working in various players that can also play Youtube streams, and some include a Youtube browser. You can also paste a Youtube URL into VLC and watch the video with va-api. The programs that work for me include Minitube, mpv, SMPlayer/SMTube using the mpv backend, Kodi with a Youtube extension, and QMPlay2. Some of these may not be in Debian, or have old versions in Buster, but I plan to make a Buster multimedia backport repo like I did for Stretch to remedy that situation within a week or two.

If your hardware supports va-api but you're not using it, I would suggest getting that working first.
MX Linux packager and developer

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox

#3 Post by stevepusser »

Well, I take that back--the latest Debian Chromium, which was just recently backported to Buster for security reasons, is supposed to support va-api. Now to remember how you're supposed to enable that.

Code: Select all

chromium (78.0.3904.97-1) unstable; urgency=medium

  * New upstream security release.
  * Enable vaapi (closes: #940074).
  * Fix crash during profile manager shutdown.
  * Drop libglewmx-dev build dependency (closes: #941050).

 -- Michael Gilbert <mgilbert@debian.org>  Sat, 09 Nov 2019 03:33:52 +0000
Edit--hold on, Buster is a bit behind with 78.0.3904.87--so no patch. Well, I know what I'll be backporting tomorrow!
MX Linux packager and developer

heracle
Posts: 5
Joined: 2019-11-13 08:57

Re: Youtube - Chromium / Firefox

#4 Post by heracle »

stevepusser wrote:I haven't managed to get va-api working for any browser video, even with an Iridium browser native build that incorporates the Chromium patches that enable it, and changing the settings that enable it. Firefox doesn't support that at all.

I do have va-api working in various players that can also play Youtube streams, and some include a Youtube browser. You can also paste a Youtube URL into VLC and watch the video with va-api. The programs that work for me include Minitube, mpv, SMPlayer/SMTube using the mpv backend, Kodi with a Youtube extension, and QMPlay2. Some of these may not be in Debian, or have old versions in Buster, but I plan to make a Buster multimedia backport repo like I did for Stretch to remedy that situation within a week or two.

If your hardware supports va-api but you're not using it, I would suggest getting that working first.
Hi stevepusser, thank you for the ideas. I did tried streaming the same video I've mentioned before thru VLC (1080p) and the cpu load for the process was between 10%-20%. I can see vainfo/vdpauinfo and according to stuff iv'e googled the output seems to correspond to examples for HW acceleration.

I did tried iridium browser, options regarding hw acceleration can be found under chrome://flags. There are some options that could be enabled, but they didn't made any difference in cpu load.
I find your last post quite interesting. I think that the problem is in chromium itself, debian(bullseye)/drivers/codecs work as they should. Just for fun I do plan to check "ungoogled-chromium" (https://ungoogled-software.github.io/un ... ses/debian) iv'e read somewhere that they have hw acc enabled, also just for curiosity i'll try fedora and arch (at some point they had chromium packages with hw acc).
I'll get back here if i have any news.

heracle
Posts: 5
Joined: 2019-11-13 08:57

Re: Youtube - Chromium / Firefox

#5 Post by heracle »

Update: Seems like work to enable vaapi is on the way:
https://bugs.debian.org/cgi-bin/bugrepo ... bug=940074

however, i'm not sure what is really going on regarding the content in this link:
https://tracker.debian.org/pkg/chromium

Update: AFAIK for testing (bullseye)..... version in which hw acc. was enabled in "78.0.3904.97-1" however due to bug they stopped and returned to stable "76.0.3809.100-1" yesterday. :oops:
Now it's clear to me why when i tried to reinstall chromium last night i got error (installed version was higher than the one i was "--reinstall") , :x :oops: .
Anyway, i can confirm hw. acc (vaapi) was not working in 78.0.3904.97-1 :lol:

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox

#6 Post by stevepusser »

Yes, the chromium situation does seem to be rather active at the moment. This morning, 78.0.3904.97-1 is available as a security update in Buster, but the changelog doesn't say anything about enabling va-api.

I would guess that whatever they did really didn't work upstream, and they pulled that version.

You should be able to see if va-api is working on the command line by playing some 4K h.264 sample video off the net, or downloaded from Youtube. Here's what I get from a 4K movie trailer:

Code: Select all

$ vlc Elysium_trailer_1-4K-HDTN\(4ksamples.com\).mp4 
VLC media player 3.0.8 Vetinari (revision 3.0.8-0-gf350b6b5a7)
[0000564ac5e50750] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
qt.svg: /usr/share/icons/Obsidian/apps/96/vlc.svg:1052: Could not resolve property: linearGradient4837
qt.svg: /usr/share/icons/Obsidian/apps/96/vlc.svg:1052: Could not resolve property: linearGradient4837
qt.svg: /usr/share/icons/Obsidian/apps/96/vlc.svg:1052: Could not resolve property: linearGradient4837
libva info: VA-API version 1.5.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_1_4
libva info: va_openDriver() returns 0
[00007f74fcd72570] avcodec decoder: Using Intel i965 driver for Intel(R) Coffee Lake - 2.3.0 for hardware decoding
I'm using a newer libva and Mesa that I backported from Bullseye for MX 19 test repo, along with a VLC that I rebuilt against those to keep va-api working, but if it's working correctly, the output for vanilla Buster should be similar.

10%-20% CPU usage seems way high for a working va-api, though...with this 4K clip, my CPU stays at near its 800 MHz minimum speed and use only goes up a few percent. Even without va-api, VLC is still more efficient than playing video in a browser, though. If you have the sharpening video filter enabled in VLC, it will use more CPU, even with va-api, but I can use sharpening in QMPlay2 without any CPU use penalty...go figure.
MX Linux packager and developer

heracle
Posts: 5
Joined: 2019-11-13 08:57

Re: Youtube - Chromium / Firefox

#7 Post by heracle »

Hmm, guess i had higher load due to mouse/window drag movement, didn't wait enough for vlc to settle. This 4k video (https://www.youtube.com/watch?v=PfPWIdH4Wcs), produces similar load/Mhz as you pointed out.

Code: Select all

cvlc https://youtu.be/PfPWIdH4Wcs
VLC media player 3.0.8 Vetinari (revision 3.0.8-0-gf350b6b5a7)
[00005591055d7a50] dummy interface: using the dummy interface module...
[00007fa8840015b0] http stream error: local stream 1 error: Cancellation (0x8)
libva info: VA-API version 1.5.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_1_4
libva info: va_openDriver() returns 0
[00007fa88534cf50] avcodec decoder: Using Intel i965 driver for Intel(R) Coffee Lake - 2.3.0 for hardware decoding
Thank's for sharing this info!

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#8 Post by stevepusser »

Apparently they figured out the va-api problem in Sid's newer Chromium today, so if it doesn't make it to Buster in a day or so, I'll backport it for MX myself. It just takes several hours of my laptop running full out--at least it has a very robust cooling system for its six-core CPU, plus I undervolt it with iuvolt.
MX Linux packager and developer

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#9 Post by stevepusser »

I rebuilt Sid's Chromium on vanilla Buster, and it does support va-api on my system! Woot!

It's a fairly straightforward backport, since all the build-deps are in Buster, but the build will try and use all your cores by default for the build, and that may overflow your RAM and force use of swap--slowing the build down hundreds of times and essentially locking up your system. You should keep the number of threads down to just a little over a third of your RAM in GB--so if you have a 4 core-8 GB system, limiting the build threads to 2 or 3 is recommended--2 if you want to use a browser at the same time. This can be done by passing the "-JN" flag to the build command (not lower case j), where "N" is the number of threads to use for the build. The build also goes quite quickly at first, counting off each object built out of 21083, but then slows down when you get to the 17000's, and the 17000's is where the most RAM is used, too.
MX Linux packager and developer

heracle
Posts: 5
Joined: 2019-11-13 08:57

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#10 Post by heracle »

I can confirm that chromium hw. acceleration is enabled and working in latest sid package (78.0.3904.108-1).

@stevepusser thank you for tips m8 !!

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1388
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 65 times

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#11 Post by None1975 »

Today in Debian Buster chromium has been updated to version 78.0.3904.108-1~deb10u1.
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#12 Post by stevepusser »

None1975 wrote:Today in Debian Buster chromium has been updated to version 78.0.3904.108-1~deb10u1.
Yes, though they didn't mention anything about va-api in the changelog, I just took a look at the build-depends and build-configuration, and it looks like it is also built with the support.

It doesn't use it automatically, though, and if your hardware doesn't support va-api for the VP9 codec, which youtube is now pushing by default, you'll have to install an extension like h264ify to make sure you get the h.264 video instead.
MX Linux packager and developer

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#13 Post by stevepusser »

I looked closer at how it was backported for Buster, and they disabled the vaapi patch, so you're not going to get it with that version. :( You should be able to install the MX 19 debs, since I built those on stock Buster pbuild environments.

http://mxrepo.com/mx/testrepo/pool/test/c/chromium/
MX Linux packager and developer

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#14 Post by stevepusser »

I backported the latest Chromium release from Experimental for MX 19 on my own machine, and it also supports va-api and seems well behaved. I'm trying backports for Buster, testing, & Sid here: https://build.opensuse.org/package/show ... m/chromium
MX Linux packager and developer

alpat
Posts: 1
Joined: 2019-12-27 08:46

Re: Youtube - Chromium / Firefox - vaapi hw acceleration

#15 Post by alpat »

Look, I need a suggestion on Youtube Live streaming problem, actually, I have an encounter with streaming error code rge-1001 and resolve it, But watching live youtube experience is terrible lots of buffering, Any thoughts?

Post Reply