Hardware acceleration wtih Intel and VAAPI

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
tabascoz
Posts: 3
Joined: Tue Nov 30, 2021 3:22 pm

Hardware acceleration wtih Intel and VAAPI

Post by tabascoz »

Hi,

I've been trying for quite a long time to activate VAAPI hardware decode support in ZM, but I'm facing an issue where half of the cam video is green.

I'm running Zoneminder 1.36.11, Gentoo linux, kernel 5.15 and looks vaapi support is ok at the box.

Here's a screenshot of the video after activating VAAPI hardware support on Source tab settings.
Screenshot from 2021-11-30 12-11-58.png
Screenshot from 2021-11-30 12-11-58.png (431.32 KiB) Viewed 6679 times
If i disable vaapi support, image is fine and everything works as expected. I Appreciate any guidance and I'm happy to provide any additional information required.

A few more info about the system:

Hw: Lenovo Thinkpad X250
FFMPEG: V4.4.1-r1
VA Driver: x11-libs/libva-intel-media-driver git version (tried also with stable)

VAinfo output:

Code: Select all

libva info: VA-API version 1.13.0
libva info: Trying to open /usr/lib64/va/drivers/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.13 (libva 2.13.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.4.3 (4de68bfa)
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileVP8Version0_3          :	VAEntrypointVLD
moholstein
Posts: 5
Joined: Fri Nov 12, 2021 1:57 pm

Re: Hardware acceleration wtih Intel and VAAPI

Post by moholstein »

ls -lR /dev/dri

you'll pobably see 644 root:renderr on ./rednderD128. Add your zm iniit user (apaache www-data or whaetever) to the "render" and 'dri" groups and restart it.
in moitor setup uue vaupi and /dev/dri/renderD128 (or whatever yours is).

Personally I've just given up on letting zoneminder do motion detection an do it directly in Nvidia/ffmpeg a a seperate process and call the trigger. Same is true for capture it;s easier to just stream it to disk from ffpmeg and use zoneminder as a wapper to keep track of what's where.

But this isn't my project and I'm not triyingto cause problems.

Depending on what disro you use and how paanoid the are try adding the string for all the sceptere/etc mirocode problems an disable all the mitigations in your grubb cmdline and see if that helps. just setup nginx to reerse proxy into your ZM system with LE public cert and selfsign for client auth, use fail2ban, and don' run it on tcp/443.
tabascoz
Posts: 3
Joined: Tue Nov 30, 2021 3:22 pm

Re: Hardware acceleration wtih Intel and VAAPI

Post by tabascoz »

Hi Moholstein - thanks for jumping in !
moholstein wrote: Wed Dec 01, 2021 11:43 pm ls -lR /dev/dri

Code: Select all

Pro ~ # ls -lR /dev/dri
/dev/dri:
total 0
drwxr-xr-x 2 root root         80 nov 30 11:15 by-path
crw-rw---- 1 root video  226,   0 nov 30 11:15 card0
crw-rw-rw- 1 root render 226, 128 nov 30 11:15 renderD128

/dev/dri/by-path:
total 0
lrwxrwxrwx 1 root root  8 nov 30 11:15 pci-0000:00:02.0-card -> ../card0
lrwxrwxrwx 1 root root 13 nov 30 11:15 pci-0000:00:02.0-render -> ../renderD128
Pro ~ # groups apache
video render apache
Pro ~ #
(zm runs under apache user)

All ok - permissions are fine and i can see activity if i issue an intel_gpu_top command - that is a solid indication that the hw acceleration is running, so i truly believe there's nothing wrong with the settings and permissions
moholstein wrote: Wed Dec 01, 2021 11:43 pm Depending on what disro you use and how paanoid the are try adding the string for all the sceptere/etc mirocode problems an disable all the mitigations in your grubb cmdline and see if that helps. just setup nginx to reerse proxy into your ZM system with LE public cert and selfsign for client auth, use fail2ban, and don' run it on tcp/443.
Already running the box with mitigations=off parameter, vlc playback with hw acceleration doesn´t present the bug, i am suspecting something with zoneminder, but i am unsure how to isolate the issue - ex. is this a FFmpeg reproducible bug ? how to test it.

What i tried so far was to use all git versions of libva/intel drivers, change kernel/drm settings and play with anything related to intel but got nothing except the annoying green stripe.

Cheers
tabascoz
Posts: 3
Joined: Tue Nov 30, 2021 3:22 pm

Re: Hardware acceleration wtih Intel and VAAPI

Post by tabascoz »

Hello there,

Does anyone have a clue? Tried to play with all i915 kernel boot params without success... all the times i had the same results. VLC vaapi decodes and display videos fine.

Thanks
User avatar
iconnor
Posts: 2881
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Hardware acceleration wtih Intel and VAAPI

Post by iconnor »

I havn't seen this. The ok part of the image looks like colours are off too though.

Are you using 24bit or 32bit Target colorspace?
Post Reply