[HOWTO] Hardware accel via VA-API in VLC

Share your own howto's etc. Not for support questions!

[HOWTO] Hardware accel via VA-API in VLC

Postby Wheelerof4te » 2019-05-09 15:00

I find it funny how all this time I didn't know that hardware acceleration in VLC was disabled if multithreading is enabled. It really boggles my mind how this basic feature of modern video cards gets sidelined in Linux. Luckily, we have a fix for that, which should work with both VA-API and VDPAU. To disable multithreading:

Go to Tools -->Preferences -->Input/Codecs -->(select all in the lower left) -->under Input/Codecs on the left panel click on downward arrow in the first option "Video Codecs" -->click on FFmpeg -->find option called "Threads" and set it from 0 to 1 -->Save.

Now close and open VLC and play your videos. They should now be properly hardware accelerated.
In the end, you can choose between software multithreading and hardware decode. Thank FFmpeg developer for that.
Why? See this mail-list thread: https://ffmpeg.org/pipermail/ffmpeg-dev ... 87494.html

For mpv player, use --hwdec=vaapi option in the terminal, because hardware decoding is disabled by default.

This was tested using VA-API on Intel card using GNOME Wayland. Somehow, using my Radeon card (radeon drm driver) tears heavily some videos.
Why is video tearing present on Wayland is a mystery, but who cares, right?
Wheelerof4te
 
Posts: 1423
Joined: 2015-08-30 20:14

Re: [HOWTO] Hardware accel via VA-API in VLC

Postby stevepusser » 2019-05-09 18:22

Va-api acceleration with the ffmpeg threads set to 0 (automatic) works for me with hardware decoding also set to automatic--perhaps it's smart enough to set the threading to one in that case. Don't forget that Intel users will also need to install i965-va-driver. Va-api also seems to be sensitive to versions of Mesa, libva, ffmpeg, and if they were all compiled against each other, so any of those from stretch-backports may break it--at least in my experience backporting those for MX Linux.

vlc using va-api for a test 4K HEVC video, plays smoothly while all cores are at 100% usage backporting the 4.19.37 kernel from Sid:

Code: Select all
$ vlc '/home/steve/Desktop/2160p Demo - 3840x2160 pixel_4k Video - a timelapse project by Florian Friedrich (4ksamples.com).mp4'
VLC media player 3.0.6 Vetinari (revision 3.0.6-0-g5803e85f73)
[0000564edf630140] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Could not resolve property : linearGradient4837
Could not resolve property : linearGradient4837
Could not resolve property : linearGradient4837
libva info: VA-API version 1.3.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_3
libva info: va_openDriver() returns 0
[00007fcdd8c0c200] avcodec decoder: Using Intel i965 driver for Intel(R) Coffee Lake - 2.2.0 for hardware decoding
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Clipgrab 3.8.6, Hedgewars 1.0.0, PulseEffects 4.6.8, Telegram-desktop 1.8.15, Pale Moon 28.7.2, KeepassXC 2.5.1
User avatar
stevepusser
 
Posts: 11295
Joined: 2009-10-06 05:53

Re: [HOWTO] Hardware accel via VA-API in VLC

Postby Head_on_a_Stick » 2019-05-09 18:26

Wheelerof4te wrote:This was tested using VA-API on Intel card using GNOME Wayland

Apologies for the off-topic post but totem provides hardware acceleration OOTB (using the gstreamer backend) and that is the video player for GNOME.
Don't break DebianHow to report bugs

SharpBang GNU/Linux — a pre-configured Openbox/Tint2 desktop running on Debian stable
User avatar
Head_on_a_Stick
 
Posts: 10675
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: [HOWTO] Hardware accel via VA-API in VLC

Postby Wheelerof4te » 2019-05-09 19:16

@stevepusser:
Could be, here is the screenshot when changing "Threads" option back to 0:
Image
Note the 4 threads are below 10%, only Chromium with few tabs and GNOME Files were open. Plus Pulseaudio. This is on 1080p video.
Both Hardware acceleration and Video Output are set to automatic. Maybe I was wrong, here is the article I read about disabling multithreading:
https://wiki.debian.org/HardwareVideoAcceleration
EDIT:
I added some command line proof that hardware decoding is working:
Code: Select all
vlc Shingeki\ no\ Kyojin\ -\ S03E13\ -\ The\ Town\ Where\ Everything\ Began.mkv
VLC media player 3.0.6 Vetinari (revision 3.0.6-0-g5803e85f73)
[000055d36f5c3570] main libvlc: VLC је покренут са подразумеваним интерфејсом. Команда „cvlc“ отвара VLC без интерфејса.
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[ass] Shaper: FriBidi 0.19.7 (SIMPLE) HarfBuzz-ng 2.3.1 (COMPLEX)
[ass] Using font provider fontconfig
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns -1
libva error: va_getDriverName() failed with unknown libva error,driver_name=(null)
[00007f3b84003400] glconv_vaapi_x11 gl error: vaInitialize: unknown libva error
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva info: va_openDriver() returns 0
[b][00007f3b94c14d30] avcodec decoder: Using Intel i965 driver for Intel(R) Broadwell - 2.3.0 for hardware decoding
[/b][ass] fontselect: (Arial, 700, 0) -> /usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf, 0, LiberationSans-Bold


Head_on_a_Stick wrote:Apologies for the off-topic post but totem provides hardware acceleration OOTB (using the gstreamer backend) and that is the video player for GNOME.

No offense, but that player sucks donkey lips.
EDIT2: Proof that GNOME Videos suck donkey lips:
Image
Wheelerof4te
 
Posts: 1423
Joined: 2015-08-30 20:14

Re: [HOWTO] Hardware accel via VA-API in VLC

Postby stevepusser » 2019-05-09 23:33

Maybe it needs one thread in Wayland, I don't know. I think you also need to be using the "intel" DDX video driver and not the modesetting one that Debian will default to, for Intel GPUs, but I'm not sure--is that what you're using?

I'm also using
Code: Select all
hwdec=auto-copy
in my mpv.conf for 0.29.1 and for it to work with SVP4Linux, which is pretty cool, but I had to rebuild mpv with vapoursynth support to get that to work with SVP, too. SVP4Linux eats up a lot of CPU cycles to do its interpolating anyway, so any hardware decoding is hidden when using mpv with it.

As for a GNOME player, I forgot if I got hwdec working with gnome-mpv, but I like that better than Totem. I'll have to wait for a lot of kernels to finish building before I test that, though.

Edit: not working in gnome-mpv, but I can't find any real configuration for it. It does work with the MX Linux mpc-qt and libmpv1 0.29.1, though...lots of buttons and sliders to play with in its options.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Clipgrab 3.8.6, Hedgewars 1.0.0, PulseEffects 4.6.8, Telegram-desktop 1.8.15, Pale Moon 28.7.2, KeepassXC 2.5.1
User avatar
stevepusser
 
Posts: 11295
Joined: 2009-10-06 05:53

Re: [HOWTO] Hardware accel via VA-API in VLC

Postby Wheelerof4te » 2019-05-10 08:05

stevepusser wrote:Maybe it needs one thread in Wayland, I don't know. I think you also need to be using the "intel" DDX video driver and not the modesetting one that Debian will default to, for Intel GPUs, but I'm not sure--is that what you're using?

If you are asking for VLC, then I am indeed using modesetting driver. And it's clearly working.
Code: Select all
inxi -G
Graphics:
  Device-1: Intel HD Graphics driver: i915 v: kernel
  Device-2: AMD Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330 / M430]
  driver: amdgpu v: kernel
  Display: wayland server: X.Org 1.20.3 driver: amdgpu
  resolution: 1366x768~60Hz
  OpenGL: renderer: Mesa DRI Intel Broadwell GT1 v: 4.5 Mesa 18.3.4

stevepusser wrote:As for a GNOME player, I forgot if I got hwdec working with gnome-mpv, but I like that better than Totem. I'll have to wait for a lot of kernels to finish building before I test that, though.

I like plain mpv better and I would only use it over VLC on minimal WM setups.
Wheelerof4te
 
Posts: 1423
Joined: 2015-08-30 20:14

Re: [HOWTO] Hardware accel via VA-API in VLC

Postby stevepusser » 2019-05-10 17:27

Nice to see that it also works with modesetting--thanks for testing!

So far, the players I've got it working on are:

VLC
mpv
SMPlayer using mpv backend
Kodi
MPC-Qt
QMPlay2

But I haven't even bothered testing Totem (movie player).
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Clipgrab 3.8.6, Hedgewars 1.0.0, PulseEffects 4.6.8, Telegram-desktop 1.8.15, Pale Moon 28.7.2, KeepassXC 2.5.1
User avatar
stevepusser
 
Posts: 11295
Joined: 2009-10-06 05:53


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable