published on
tags: linux xps fedora hw-accel

Hardware accelerated playback in MPV

The way of the roadwarrior

Getting more battery time out of your laptop is a constant uphill battle against Slack, Jira and other browser based trojans. But who would expect that playing a local media file would consume so much CPU?

For example playing this 4K video:

 mpv "https://www.youtube.com/watch?v=K1QICrgxTjA"

will consume ~110% cpu on a premium I7 Laptop

But if there is a will there is a way

If you’re on wayland and on modern Intel GFX hardware this could work for you.

dnf install -y ffmpeg intel-media-driver libva-utils

running:

 vainfo

should output the supported profiles available for hardware offloading if all is well.

enable HW decoding in MPV:

mkdir -p ~/.config/mpv/ && echo hwdec=auto >> ~/.config/mpv/mpv.conf

and now the same playback should consume ~13% cpu

~ Yours truly, Coitus Maximus