I like using Linux. I use it on my desktop – especially now that League of Legends runs incredibly well on Linux thanks to the Lutris and League of Linux reddit community. I’d also like to use Linux on my laptop (an XPS 13 9370), but here I run into a major hurdle that despite a lot of trials and tribulations, I have been unable to overcome: playing video.
Of course, Linux – in my case, Linux Mint – can play any format under the sun just fine, either locally, on-demand, or streaming, and in my case, it’s YouTube video that matters (720p-1080p). The problem lies not in what desktop Linux can play, but in how it does so. Decoding video on my laptop running Linux is apparently remarkably inefficient, to the point where the processor reaches temperatures of 60-70°C, and since the fan kicks in at around 60°C, watching video on Linux means constant fan noise. When playing the same videos on Windows on the exact same laptop, temperatures stay comfortably below 40°C, without ever even coming close to spinning up a fan.
I have tried everything. Here’s an itemised list of things I’ve tried, including multiple different combinations:
- I’ve installed tlp. This has had no effect.
- I’ve manually configured my processor – through tlp – to make sure it doesn’t turbo beyond 50%. This has had no effect.
- I’ve disabled Intel Turbo Boost in UEFI altogether. This has had no effect.
- I’ve undervolted my CPU. This gives me maybe 1-2 degrees every now and then, so effectively it hasn’t helped.
- I’ve tried the latest mainline kernel just to see if there’s been improvements in power management or any Intel drivers. This has had no effect.
- I’ve tried the Chromium builds with VAAPI support to enable hardware acceleration on YouTube video. This has had no effect.
- I’ve tried downloading YouTube videos with youtube-dl and playing them back locally. This has had no effect.
- I’ve tried forcing H264 on YouTube. This has had no effect.
There’s probably things I’ve tried that I’ve forgotten about and thus aren’t on this list. As you can imagine, my past few days and weeks have been frustrating, to say the least. I even decided to install Linux Mint on my Surface Pro 4 to see if similar problems pop-up there, and lo and behold, that device, too, sees massive temperature spikes when using Linux instead of Windows.
I understand and can accept if Linux isn’t as efficient as Windows when it comes to power management and decoding video, and am okay with a few degrees here and there. However, I just cannot understand nor accept a 20-30°C difference with something as elemental as decoding video.
After all of this, I can only conclude that desktop Linux has an incredibly bad video decoding pipeline compared to Windows, and considering I’ve been struggling with this several times over the past few years without any noticeable improvement, it seems like it’s not something high on anybody’s list of things to improve. Linux’ inefficient video decoding pipeline won’t be much of an issue on desktop machines – playing video has virtually no material temperature impact on my desktop since my custom watercooled GTX 1070 and i7-7700K are way overkill – but on thermally constrained laptops, the problem becomes massively apparent.
It is frustrating. I prefer Linux over Windows, I want to use it on my laptop, but as it stands now, I simply can’t. I’m at my wits’ end.
You need to check vainfo
https://www.ivanov.biz/2019/howto-optimize-intel-graphics-performance-fedora-kde-linux-laptop/
If vaapi is not working of course is falls back to using the cpu that not that effective. Cause if it not working not having all the require packages installed or having too old of kernel.
vaapi working under Linux should be using less power and making less heat than running under windows. So its more finding what is not installed if everything software is in fact installed. Its updating kernel or updating firmware if kernel does not enable vaapi.
Windows is as bad when intel driver has not properly installed as well
VAAPI is working.
Did vainfo list the h264 acceleration as available. With intel particular cpus with particular kernels result in no h264 acceleration.
Yes. I got the basics covered.
Hmm I can remember that a couple of years ago I had that issue with quite a few programs but nowadays I can’t complain. Youtube works fine too on my not so fresh anymore quad-core i5 Thinkpad. I’m running Solus 4 btw.
Thom Holwerda,
I realize that someone probably suggested you look at power management or bios tweaking, but I can tell you this has nothing to do with power management. It’s all about hardware acceleration and lack thereof.
I get your frustration and I too have spent time fighting linux graphics problems
In my case I’m using nvidia discrete graphics cards…but maybe someone here has experience with intel GPUs on linux.
It could be helpful if you install “vainfo” and “vdpauinfo” packages and dump their output…
I don’t know why my nvidia driver gives an error here, but HD youtube playback still works for me (my GPU show 18% load through nvidia-smi).
If the drivers on your system don’t enable H264 decoders, then software like chrome and firefox will fallback to software decoding, which is what seems to be happening to you.
This page shows what output should look like with the intel i965 driver
https://wiki.archlinux.org/index.php/Hardware_video_acceleration
If your drivers support h264, then it may be an issue with your browser software, but we can cross that bridge if the evidence suggests a problem. If your drivers don’t support h264, then that’s clearly the problem but you need to find out why.
Is “i965-va-driver” installed?
Searching online, I found this, says problem was solved.
https://forums.linuxmint.com/viewtopic.php?t=260484
The information is dated now but it suggests installing “xserver-xorg-video-intel”.
I’m not sure why these wouldn’t already be installed, but it doesn’t hurt to check.
I doubt anyone will respond, but does anyone here have intel GPU acceleration running under linux? If so it would be very helpful to compare configurations.
VAAPI is working, H264 (and even VPx) are properly accelerated. Sadly, Chrome/Vivaldi do not support hardware video acceleration on Linux by default; you need a patched Chromium build for that. That, too, lists VAAPI as working perfectly.
Thom Holwerda,
I am confused by this line, which lead me to believe that the downloaded videos still did not work accelerated under local linux software: “I’ve tried downloading YouTube videos with youtube-dl and playing them back locally. This has had no effect.”
Can you tell me how you verified that video acceleration is working properly outside of chrome?
Anyways, I just noticed something on my system: when I playing the same youtube video at the same resolution on firefox-esr and and chromium, I looked at the UPS power consumption meter and it shows that chromium consumes roughly an extra 40watts of power. I repeated this test making sure the video was cached and not downloading, it is repeatable. This may not mean anything for you given that you have a different configuration, but have you tried firefox?
Incidentally, I just noticed that for the same videos on youtube chromium maxed out at 1080p whereas firefox enables up to 4k. Does anyone know what that’s about? I never noticed this before because I don’t normally use chromium.
I was confused as well. Firefox has no ability to use GPU decode currently and Chrome only has the patched Chromium vaapi build which is spotty, but if I stream Youtube or download the file locally and play it via VLC I have full hardware acceleration and very low GPU usage. The fan doesn’t even spin up on my laptop when I play this way. In the browser though, I get high CPU usage and high temperatures.
Try https://mpv.io/
more specifically, enable hardware decoding by adding hwdec=auto (or vaapi) in ~/.config/mpv/mpv.conf, and use the play-with firefox extension to send the video URL to mpv. kinda clunky, but it works. seeking is seamless too, as mpv doesn’t immediately discard the buffer upon skipping.
Something you can try.
Firefox does not appear to enable video hardware acceleration by default. This causes tearing and high CPU usage playing videos.
Changing a configuration item cured the issue on both my desktop (Lubuntu 18.04, Intel 2600K, nVidia 1060), and a Stinkpad 420s (Mint 19.2).
Open configuration tab: about:config
layers.acceleration.force-enabled to true
Restart Firefox and play any of the offending videos.
It appears that video acceleration isn’t actually enabled without that item set to true. Everything was being done by the CPU instead of being offloaded to the GPU.
1) Check chrome://gpu in Chromium.
2) If “Video Decode” is not “Hardware accelerated” install Chromium beta: https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta
3) Play a video on Youtube and check chrome://media-internals/ in another tab.
4) If the value for video_decoder is not MojoVideoDecoder or GpuVideoDecoder, the GPU is not used. Then try to install h264ify Chrome extension and reload the video.
PS: I think it can be cool if you could benchmark the differences on different hardware
Yup, I tested these things already, and yup, it says video decoding is GPU accelerated, as mentioned in the article.
Hello Thom.
1) Make sure you have intel vaapi driver installed – I’ve no idea what’s the package name in Mint – libva-intel-vaapi-driver ? This is absolutely important – without it nothing will work.
2) install mpv
3) Run
mpv -v -v --log-file=/tmp/logfile.txt --hwdec=auto
video_file.mkv (any video with H.264 codec)Upload logfile.txt anywhere you want and let us grab it.
Also upload
vdpauinfo
output.I said this earlier too, but I’d like to see the output for comparison with a working configuration.
Here you go.
https://www.osnews.com/wp-content/uploads/2019/11/logs.zip
Thanks
Does anyone know which h264 profiles are typically used on youtube? I’m having trouble finding an authoritative answer.
Obviously, from your output:
Wikipedia has a good list what features are supported by each profile.
https://en.wikipedia.org/wiki/Advanced_Video_Coding#Profiles
I tried to download a video off youtube to analyze it myself, but apparently video download helper’s companion app is broken for many people at the moment, so I failed. If you are able to download y/t video, can you play it using ffplay and share the output? I’m especially interested in the bolded line, which indicates which h264 profile and pixel format was used.
Downloaded from Y/T yesterday… and yes, Y/T has been a little b*tch about downloading videos for about six months now, breaking all the current downloading plugins every three or four weeks. They’re just playing whack-a-mole.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘Temporal Anomaly – A Star Trek Fan Production (Part 1) (2019).mp4’:
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2019-04-09T06:18:11.000000Z
Duration: 00:26:46.64, start: 0.000000, bitrate: 345 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280×544 [SAR 1:1 DAR 40:17], 214 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
creation_time : 2019-04-09T06:18:11.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 04/08/2019.
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
creation_time : 2019-04-09T06:18:11.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 04/08/2019.
I haven’t had any more problems than usual with the youtube-dl command-line app.
Occasionally, I’ll run into a recent vevo video that requires me to run it with
-U
to trigger a self-update (Vevo seems to be more aggressive about releasing new obfuscations) but no more than it ever has been and, generally speaking, the only issue has been that the 1280p pre-muxed H.264 stream type is buggy on some videos, and youtube-dl isn’t smart enough to consider that a reason to choose the next entry in the fallback chain, which is to pull the DASH audio and video streams and mux them itself.(Specifically,
-f 22
on things like a brand new Lazy Game Reviews video is likely to stop part-way through when the server closes the connection when asked for a specific chunk, which remains consistent across multiple attempts but it eventually gets fixed because, if I come back months later without having updated youtube-dl and try to complete the .part file I left lying around, it works.)According to your log hw decoding was enabled and worked:
[ 0.108][i][vd] Using hardware decoding (vaapi).
You can verify that by pressing i/I and seeing (hwdec: vaapi) next to video.
I’m not sure why it doesn’t work for you in Chromimum but to save my battery I just watch youtube videos using mpv.
mpv --hwdec=auto URL
To make it work
sudo apt install youtube-dl
That’s it. If you want to avoid typing hwdec=auto every time, put it in your config ~/.mpv/config
Here’s my config:
$ cat ~/.mpv/config
# Write your default config options here!
volume-max=150
hwdec = auto
[extension.mov]
af=acompressor
[extension.avi]
af=acompressor
[extension.mkv]
af=acompressor
[extension.mp4]
af=acompressor
[extension.mp3]
vo = null
vd = null
[extension.flac]
vo = null
vd = null
[extension.ogg]
vo = null
vd = null
[extension.m4a]
vo = null
vd = null
[extension.aac]
vo = null
vd = null
[extension.wav]
vo = null
vd = null
I blame hardware. It sounds like you’ve done all you can to trouble shoot the software. It kind of sounds like the problems people had with pulse audio. Where the linux drivers were doing everything by the book, but the hardware had subtle flaws that didn’t allow them to work as specified. Where as with the windows drivers, they didn’t make use of the same functionality in quite the same way. So it was often reports of “pulse audio is junk”, when the reality was a little more complex. I suspect something similar is happening here.
I have two exact same hardware computers, one on windows and one on ubuntu. I’ll take a look tonight to see if I have the same problems Thom described. I suspect not.
tldr; yes it sucks and sure you can blame “linux” but I think its deeper than that.
Bill Shooter of Bul,
Excellent, it’s a lot easier to identify problems when you have a known good system to compare it to
You are right it is deeper than that, but I hazard a guess that in this particular case the intel GPU hardware is not at fault and it’s a linux/software support problem. I remain open to evidence to the contrary though.
I’m pretty sure you’re right. Everything seems to be setup correctly, everything is self-reporting to be working as intended, and yet, the offloading to the GPU clearly isn’t working properly, but since everything claims to be working, it’s nigh-on impossible to determine where the fault lies (unless you’re a skilled developer and can dive deep into the complicated GPU/media code and the way it runs on my specific system).
If hardware video decoding is working than it has to be something else in the render pipeline – have you checked all the other stuff (compositor, etc.)?
It’d be cool if we could help Thom solve this. The thing is I use discrete graphics on all of my computers including laptops. If anyone believes they have chromium video acceleration working on an intel GPU under linux, do speak up because comparing the libraries in use could help isolate the differences between the acceleration working versus being broken.
Totally forgot to run the comparison last night… But will get to it.
When people ask me “You run Windows? You pay so much money for an OS which ships with a mediocre media player and an okay browser?” I reply to them “No, I paid for the platform to run the apps I want as well as possible”.
In Windows, DXVA works, all drivers are required to support it (which means all you have to do is install them), and hence software vendors like Chrome and Firefox have are activating DXVA on their software knowing it won’t cause any bug reports that aren’t indeed bugs with their apps. So… lo and behold, thanks to the platform, every laptop made within the last 10 years can play video hardware accelerated and keep your CPU at <5% usage.
A benefit of central authority. Linux doesn’t have that.
What a BS excuse instead of having a standard hw accelerated video decoding API which just works everywhere all the time like it does in Windows, Android, MacOS and iOS.
NVIDIA released VDPAU as open source yet open source developers decided it wasn’t good enough and created VAAPI (with a lot of crazy requirements – it does not just work). Now we have two standards and all sorts of issues.
No other vendor in their right mind is going to implement nVidia’s “open” standard. That’s a trap, and everyone knows it.
People really rag on windows for its browser and media player? That’s so bizarre. Although I’m not sure what you would complain about. The registry still sucks?!? Its a popular target for malware?
Its basically good, so is linux. There are some valid reasons why you might prefer either.
I rag on Windows for other reasons – their browser is fine really. It’s their security model which requires everything be run with admin privs, and thus requires Anti-virus always slowing down literally everything. Their over protection of legacy app compatibility, which prevents them from updating core components to anything reasonably modern. And their horrible outdated desktop environment. Their desktop is outdated at best, the compositor is herky jerky, they can’t keep track of the size of windows, position of windows (things literally get lost off the edges of the screen, requiring desktop res adjustments, which then results in icon cache corruption, and on and on). Their multi-monitor support is hacky at best, and don’t get me started on their support for high color gamut monitors. Neither Linux nor macOS have these problems – they are solved problems, except on Windows.
That said, Windows has come a long way. It’s not the worst thing ever any more.
I wonder if this could be somewhere else in the render pipeline. If the video is hardware decoded, then run through an inefficient render pipeline, you’d see similar fan/CPU activity. Is everything else successfully hardware accelerated (desktop and browser)?
Another question I’d ask is have you tried any other distro on the machine. Mint is great, but it’s base software is old now. Maybe try Ubuntu or Fedora and see if you get any different results if you haven’t It would at least rule out distro specific bugs etc.
Sometimes it’s just that “new” hardware takes a while for the software to get all the bugs ironed out. I bought an AMD A9 laptop in Dec 2017 that wouldn’t run on Ubuntu 16.04… it NEEDED 17.10 just the run, and even then, I had issues with things on it. It didn’t work the way it was supposed to until 18.04, which is what I run on it now (dual boots W10 and Xubuntu 18.04).
Thom,
Have you tried installing Ubuntu LTS with the Dell repositories? Just to rule out that Dell does something special somewhere. I have the developer edition of the 9360 and I haven’t noticed issues… I’m not a 100% sure whether I played HD YouTube videos though I’ll test.
Thom, no issues on Ubuntu 18 LTS, 19.04 and 19.10 on my 9360. Both CPU and temperature stay very low on both 720p and 1080p YouTube videos.
Sounds a bit unfair to blame linux. I can decode 4k video just fine without my CPU going over a few percentage points in Kodi, VLC, and other applications. I’ve got a problem with amdgpu and Ryzen GPU’s, but that’s a different issue.
This sounds like the browsers aren’t properly implementing hardware decoding.
My linux desktop (Manjaro + Ryzen 5 + NVidia) plays HD videos off of youtube and never breaks 5% CPU load, so there’s obviously something strange going on.
Thank you Thom for noticing this, which let me to investigate and finally find a fix for me.
I didn’t notice because I’m using more a desktop than a laptop and I didn’t pay much attention.
The real issue is that even if you enable hardware video decoding on chromium, youtube still sends the video in vp9 codec which for example vaapi didn’t support, at least for me, to solve this you can use the extension h264ify:
https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal
And to check if it’s working play a video in one tab and open another tab and go to chrome://media-internals and you can check in which codec is the video playing.
With this I reduced the cpu usage from 80% to 15% on chromium.
The most valuable tips I found was on this article:
https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html
Another great tip which I found here on the comments was using the mpv video player and edit it’s configuration file on .mpv/config and add this:
vo = vaapi
hwdec = auto
Playing a youtube video with mpv it’s even more cpu efficient than chromium, for me it takes 8% with mpv.
Hope that this can help you.
“2019-11-25 11:12 am
lakerssuperman2
I was confused as well. Firefox has no ability to use GPU decode currently”
Wasn’t there a big stink about this under Firefox and breaking audio support under Linux some years back?
I have the same laptop. I watch YouTube daily and don’t remember the fans ever kicking in for that.
At the moent I have YouTube running on FF and this is the output from sensors:
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +44.0°C (high = +100.0°C, crit = +100.0°C)
Core 0: +42.0°C (high = +100.0°C, crit = +100.0°C)
Core 1: +44.0°C (high = +100.0°C, crit = +100.0°C)
Core 2: +42.0°C (high = +100.0°C, crit = +100.0°C)
Core 3: +44.0°C (high = +100.0°C, crit = +100.0°C)
TLP was pre-installed (I got the developer edition with 16.04 – have since upgraded to 18.04 – but had no problem with 16.04 either)..
I did nothing special to codecs. It’s all Ubuntu default AFAIR.
But I just noticed that you have the 4K screen (my model has the FHD screen – by choice) – so that might explain the difference.
I just gave up and ended up going Win 10 on my netbook as I had the same issue only worse as on a netbook you HAVE to have the hardware decoder working or its gonna seriously drag. I tried multiple distros, tried every tweak and trick listed, nope never could get it to work. Say what you will about Win 10 but at least the hardware decoder works which is frankly amazing as AMD only released a single beta driver for Win 10 on the Brazos based netbooks but hey, it works.
It is basically drivers for your computer or the lack thereof. The rules of installing any OS are in order:
1. Install Operating System
2. Install MOBO driver
3. Install GPU driver
4. Install driver
5. etc.
You must do this, especially if your OS is Windows.
Now for Linux, drivers are available “built-in” for almost all devices recognized in your Linux kernel. However, in my limited point of view with regards to Linux and the supported hardware, if you have Intel GPU, then it’s supported by default in my understanding. Nvidia/AMD, you need to specifically install the proprietary driver if you need a stable GPU performance on par with Windows, so that decoding and encoding videos will work as expected.
However, I humbly suggest you buy Dell’s linux supported laptop or from System76 if you need a stable Linux laptop.