Mpv, video hardware acceleration, wayland

I have an oldish laptop running EndeavourOS KDE Plasma in Wayland mode fairly well.

This is the output of inxi -SMCGca --no-host:

System:
  Kernel: 5.15.2-arch1-1 x86_64 bits: 64 compiler: gcc
  v: 11.1.0
  parameters: BOOT_IMAGE=/boot/vmlinuz-linux
  root=UUID=4b6f4202-342c-4853-9fff-4539f296ad3c rw quiet
  loglevel=3 nowatchdog
  Desktop: KDE Plasma 5.23.3 tk: Qt 5.15.2 wm: kwin_wayland
  vt: 2 dm: LightDM 1.30.0, SDDM Distro: EndeavourOS
  base: Arch Linux
Machine:
  Type: Laptop System: Dell product: Inspiron 15-3567 v: N/A
  serial: <superuser required> Chassis: type: 9
  serial: <superuser required>
  Mobo: Dell model: 0FGN4M v: A00
  serial: <superuser required> UEFI: Dell v: 01.07.00
  date: 04/07/2017
CPU:
  Info: Dual Core model: Intel Core i3-6006U bits: 64
  type: MCP arch: Skylake family: 6 model-id: 4E (78)
  stepping: 3 microcode: EA cache: L2: 3 MiB
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3
  vmx
  bogomips: 8003
  Speed: 800 MHz min/max: 400/2000 MHz Core speeds (MHz):
  1: 800 2: 861
  Vulnerabilities: Type: itlb_multihit
  status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional
  cache flushes, SMT disabled
  Type: mds mitigation: Clear CPU buffers; SMT disabled
  Type: meltdown mitigation: PTI
  Type: spec_store_bypass mitigation: Speculative Store
  Bypass disabled via prctl and seccomp
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and
  __user pointer sanitization
  Type: spectre_v2 mitigation: Full generic retpoline, IBPB:
  conditional, IBRS_FW, RSB filling
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel Skylake GT2 [HD Graphics 520] vendor: Dell
  driver: i915 v: kernel bus-ID: 00:02.0 chip-ID: 8086:1916
  class-ID: 0300
  Device-2: Realtek Integrated_Webcam_HD type: USB
  driver: uvcvideo bus-ID: 1-5:2 chip-ID: 0bda:5769
  class-ID: 0e02 serial: 200901010001
  Display: wayland server: X.Org 1.21.1.3
  compositor: kwin_wayland driver: loaded: intel
  unloaded: fbdev,modesetting,vesa display-ID: :1 screens: 1
  Screen-1: 0 s-res: 1366x768 s-dpi: 96
  s-size: 361x203mm (14.2x8.0") s-diag: 414mm (16.3")
  Monitor-1: XWAYLAND0 res: 1366x768 hz: 60 dpi: 102
  size: 340x190mm (13.4x7.5") diag: 389mm (15.3")
  OpenGL: renderer: Mesa Intel HD Graphics 520 (SKL GT2)
  v: 4.6 Mesa 21.2.5 direct render: Yes

So this laptop does not have nvidia, just Intel.

I’m wondering if it’s possible to have “hardware acceleration” available when I’m playing videos via mpv.

I don’t have mpv.conf in ~/.config or in /etc/mpv.

This is what I see with just mpv:

 (+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p
AV: 00:00:13 / 00:14:08 (2%) A-V:  0.000

Exiting... (Quit)

And this is what I see with both mpv --hwdec=auto or with mpv --hwdec=vaapi:

 (+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
[ffmpeg] AVHWDeviceContext: Failed to query surface attributes: 20 (the requested function is not implemented).
[vo/gpu/vaapi-egl] failed to retrieve libavutil frame constraints
Cannot load libcuda.so.1
[ffmpeg/video] vp9: No support for codec vp9 profile 0.
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p
AV: 00:00:02 / 00:14:08 (0%) A-V:  0.000

Exiting... (Quit)

The video in question was downloaded from YouTube as a .webm file.

The ArchWiki on mpv suggests using --gpu-context=wayland but mpv --gpu-context=wayland or mpv --gpu-context=wayland --hwdec=auto mpv --gpu-context=wayland --hwdec=vaapi don’t make a difference as seen by running sudo intel_gpu_top:

intel-gpu-top

Does my laptop allow for hardware acceleration? If it does, are there additional packages that need to be installed?

$ pacman -Q | grep -E "(intel|mesa)"
intel-gmmlib 21.3.2-1
intel-gpu-tools 1.26-1
intel-media-driver 21.4.1-1
intel-ucode 20210608-1
libva-intel-driver 2.4.1-1
libva-mesa-driver 21.2.5-1
mesa 21.2.5-1
mesa-demos 8.4.0-4
xf86-video-intel 1:2.99.917+916+g31486f40-2
$

In case it helps, here’s the output of vainfo:

Summary
$ vainfo
vainfo: VA-API version: 1.13 (libva 2.13.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.4.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
$ 

Archwiki also give some info about gpu intel hardware acceleration:

Also see Hardware video acceleration.

Note: Some (Debian & Ubuntu, Fedora, KDE) recommend not installing the xf86-video-intel driver, and instead falling back on the modesetting driver for Gen4 and newer GPUs (GMA 3000 from 2006 and newer). See [1], [2], Xorg#Installation, and modesetting(4). However, the modesetting driver can cause problems such as Chromium Issue 370022 and vsync jitter/video stutter in mpv.

Needs to be enabled at Hardware level maybe?

Also this can be interesting:
https://wiki.archlinux.org/title/Hardware_video_acceleration#Intel

The video in question is VP9 encoded, which isn’t supported on Skylake.

You can get partial support by tinkering with https://aur.archlinux.org/packages/intel-hybrid-codec-driver/

1 Like

That makes sense because I have another laptop with Kaby Lake running Kubuntu 20.04 and mpv is just fine there with --hwdec=auto.

I installed intel-hybrid-codec-driver (2.0.0.r169.edead0c-4) and libva-intel-driver-hybrid (2.4.1-1) which required that libva-intel-driver (2.4.1-1) be removed.

I’m still getting:

$ mpv --gpu-context=wayland --hwdec=auto test.webm
 (+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
[ffmpeg] AVHWDeviceContext: Failed to query surface attributes: 20 (the requested function is not implemented).
[vo/gpu/vaapi-egl] failed to retrieve libavutil frame constraints
Cannot load libcuda.so.1
[ffmpeg/video] vp9: No support for codec vp9 profile 0.
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p
AV: 00:00:25 / 00:14:08 (3%) A-V:  0.000

Exiting... (Quit)

Not sure how the hybrid solution is supposed to work or show up. Does video acceleration work at all for other codecs, like AVC or h.264? What does va-info show? Just to make sure hardware-acceleration is working at all, before starting to fiddle with mpv.

1 Like

This is the output of vainfo:

vainfo: VA-API version: 1.13 (libva 2.13.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.4.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointFEI

Re. AVC or h.264, I found this site and downloaded the 1 MB file.

Looks like it worked based on the presence of Using hardware decoding (vaapi). in the terminal output and also what I see with sudo intel_gpu_top

~/Downloads $ mpv --gpu-context=wayland --hwdec=auto Big_Buck_Bunny_1080_10s_1MB.mp4 
 (+) Video --vid=1 (*) (h264 1920x1080 30.000fps)
File tags:
 Artist: Blender Foundation 2008, Janus Bager Kristensen 2013
 Comment: Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
 Composer: Sacha Goedegebure
 Genre: Animation
 Title: Big Buck Bunny, Sunflower version
[ffmpeg] AVHWDeviceContext: Failed to query surface attributes: 20 (the requested function is not implemented).
[vo/gpu/vaapi-egl] failed to retrieve libavutil frame constraints
Cannot load libcuda.so.1
Using hardware decoding (vaapi).
VO: [gpu] 1920x1080 vaapi[nv12]
V: 00:00:09 / 00:00:10 (100%)

Exiting... (End of file)

I guess the bottom line is to stay with .mp4 and not to expect too much of the Sky Lake CPU. This CPU works fairly decently otherwise.

Thanks for the help!!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.