Skip to content

This article provides some background on video playback in Arch Linux.


Table of contents:
  1. Introduction
  2. Verification
  3. Configuring mpv
  4. Recommended software

Introduction

Hardware video acceleration makes it possible for the video card to decode/encode video, thus offloading the CPU and saving power.

There are several ways to achieve this on Linux:

  • VA-API – is a specification and open source library to provide both hardware accelerated video encoding and decoding, developed by Intel.
  • VDPAU – is an open source library and API to offload portions of the video decoding process and video post-processing to the GPU video-hardware, developed by NVIDIA.
  • NVDECODE/NVENCODE – NVIDIA’s proprietary APIs for hardware video acceleration, used by NVIDIA GPUs from Fermi onwards.

Verification

Your system may work perfectly out-of-the-box without needing any configuration. Therefore it is a good idea to start with this section to see that it is the case.

  • mpv with its command-line support is great for testing hardware acceleration. Look at the log of mpv --hwdec=auto video_filename and see hwdec for more details.
  • For Intel GPU, use intel-gpu-tools and run intel_gpu_top as root to monitor the GPU activity during video playback for example. The video bar being above 0% indicates GPU video decoder/encoder usage.
  • For AMD GPU, use radeontop to monitor GPU activity. Unlike intel-gpu-tools, there is currently no way to see decode/encode usage on radeontop.
  • For any GPU, you can compare CPU usage with a tool like htop. Especially for higher resolution videos (4k+), CPU usage when VA-API is enabled and working should be dramatically lower on laptops and other relatively low-power devices.
 TIP: When watching a YouTube video, right-click the video and select "stats for nerds". This pop-up displays useful information like media codecs, dropped frames, etc.

VA-API

Verify the settings for VA-API by running vainfo, which is provided by libva-utils:

vainfo

VAEntrypointVLD means that your card is capable to decode this format, VAEntrypointEncSlice means that you can encode to this format.

In this example the i965 driver is used, as you can see in this line:

vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.7.3 

If the following error is displayed when running vainfo you need to configure the correct driver:

libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

VDPAU

Install vdpauinfo to verify if the VDPAU driver is loaded correctly and retrieve a full report of the configuration:

vdpauinfo

Configuring mpv

Example configuration file:
~/.config/mpv/mpv.conf

# Use GPU-accelerated video output by default.
vo=gpu
# Use quotes for text that can contain spaces:
term-status-msg="Time: ${time-pos}"

Hardware accelerated video decoding is available via hwdec=API option. For list of all supported APIs and other required options see relevant manual section.

For Wayland use gpu-context=wayland option. For list of other available GPU APIs see manual.


vlc: Multi-platform MPEG, VCD/DVD, and DivX player.

pacman -S vlc

mpv: a free, open source, and cross-platform media player.

pacman -S mpv

ff2mpv: This is a Firefox addon for playing URLs in MPV.

yay -S ff2mpv-native-messaging-host-git
https://addons.mozilla.org/en-US/firefox/addon/ff2mpv/

enhanced-h264ify: Extension for Firefox/Chrome which blocks YouTube VP8/VP9 codecs, to use H264 only.

https://addons.mozilla.org/en-US/firefox/addon/enhanced-h264ify/
https://chrome.google.com/webstore/detail/enhanced-h264ify/omkfmpieigblcllmkgbflkikinpkodlk

youtube-dl-git: A small command-line program to download videos from YouTube and a few more sites.
yt-dlp: A youtube-dl fork with additional features and fixes.

yay -S youtube-dl-git
yay -S yt-dlp-drop-in

Sources / Further reading:
https://wiki.archlinux.org/title/Hardware_video_acceleration

Video playback

  • by