Hardware-accelerated video playback

Just an update on hardware-accelerated video playback for Intel GPUs…

Ubuntu 17.10 beta 2 introduces out-of-the-box support for hardware acceleration as much as possible. However there are some caveats still so please refer to the updated wiki page:

The remaining totem performance issues are actually separate to the use of hardware acceleration, and additional fixes in that area are coming soon.


Some anecdotal screenshots:




When recommending to use MPV, I guess that using the GUI “Gnome MPV” will work also ?

No gnome-mpv is not recommended and does not “work” with respect to hardware acceleration.

For example when playing a 4K video I get:

  • gnome-mpv 300% CPU
  • mpv 6% CPU

So gnome-mpv would need some work. The problems appear to be:

  • Hardware-acceleration is not enabled by default.
  • If you enable hardware-acceleration then the window decoration and buttons flicker badly, but also CPU usage is still high.
  • gnome-mpv uses the GtkGLArea widget. In theory this is the right thing to do, however in practice app developers probably are not aware that GtkGLArea is very inefficient: https://bugzilla.gnome.org/show_bug.cgi?id=787704 Sadly app developers also have few other options for integrating a hardware surface into a GTK app. And the only alternative I can think of is also broken: https://bugzilla.gnome.org/show_bug.cgi?id=787001

So TL;DR - use only mpv, not gnome-mpv.


Thanks Will. Although I feel those screenshots understate the improvement that hardware acceleration can make. When playing heavier videos like 60 FPS and/or 4K I am seeing a 50X reduction in CPU usage.

1 Like

Pics or it didn’t happen. :wink:

Heh, OK. It’s worth noting gnome-shell and gnome-system-monitor do use significant CPU at times (check top). Also the CPU History graph is showing cores separately so the total CPU time should be imagined as the stacked sum of those two lines. Looking at the CPU usage of just the player process and ignoring any gnome-shell inefficiency (which we’ll fix in 18.04), the improvement is greater. Because after you turn on hardware acceleration mpv tends to use less CPU to decode the video than gnome-shell to composite the screen. The goal for this cycle was to fix the decoding. The shell performance is a whole other problem for next cycle.

Curious also that gnome-system-monitor is so inaccurate. On my 8-thread CPU it seemingly only reports per-process CPU values of 0% or 8% (never anything between). Maybe use top in future which seems to report more precision…

1 Like

In related news, a fix to halve totem’s CPU usage (assuming you have hardware acceleration working already) has just been released to 17.10:

1 Like

Does this apply to Wayland or only the X session? I was confused seeing no window decorations for mpv on Wayland, googled, found an issue/flamewar on GitHub and a post by Martin Gräßlin and was even more confused… so I tinkered with my mpv.conf and added it to gnome-mpv until I was somewhat happy with the result.

If I can get back mpv performance on Wayland comparable to what I had on X (opengl-hq/hwdec=vaapi) and with window decorations or a working close-this-window-functionality, that would be terrific!

I’m not sure what you’re referring to by “this”, so I’ll try to answer all possibilities. Yes, hardware accelerated video playback is available equally in Wayland and Xorg sessions. The high CPU fix mentioned above in theory applies to both, but in practice seems to be most significant in Wayland, because Wayland apparently lacks 2D blitting acceleration that Xorg has. And the lack of window decorations is indeed a Wayland-only problem.

I’m personally hopeful Wayland moves toward allowing the shell/WM to add-on the window decorations, as is the case for Xorg. But the bare mpv window in Wayland actually isn’t too bad. You can still move it with a mouse drag, and resize it with Action+middle-mouse-button (where Action is Super by default but is also configurable in gnome-tweak-tool).

P.S. You can quit mpv using the Q key at least (https://bugs.launchpad.net/ubuntu/+source/mpv/+bug/1720835).

1 Like

Does anyone have access to any of these devices?

  • iPhone 8 / 8 Plus / X
  • GoPro HERO6

If so and you would be willing to send me some test videos (straight off the camera), then please get in contact. In particular I would like to get some 4K 60FPS files from each (which I assume will all be H.265 HEVC).

Interestingly, an Intel engineer just pointed out that Intel has now open sourced their previously closed source VA-API driver. Apparently this one only supports Broadwell and later. I have no idea how else it’s different to the existing open source driver we use…

New: https://github.com/intel/media-driver
Current: https://github.com/01org/intel-vaapi-driver

In MPV news today: A fix is on the way to allow clicking/dragging/tiling of the MPV window in a Wayland session: https://bugzilla.gnome.org/show_bug.cgi?id=790309

Sorry I didn’t notice the issue sooner. I hope the fix lands in mutter 3.26.3.

As an added bonus, it appears mpv 0.28.0 provides fixes of its own. By rewriting the Wayland backend mpv 0.28 should work without needing the above mutter/gnome-shell fix.

Thanks for bringing this up! I had missed the original post and was unaware of these issues. FWIW I haven’t noticed a heavy CPU spike (no more than normal when viewing video) viewing.