Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
vaapi acceleration not working
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1523

PostPosted: Mon Aug 14, 2023 12:56 pm    Post subject: vaapi acceleration not working Reply with quote

Hi everyone,
I'm trying to encode a video using vaapi but I get the following error:
Code:
adel@t14 ~ $ ffmpeg -y -hwaccel vaapi -f x11grab -framerate 25 -video_size 1920x1200 -i :0.0 -vcodec h264  /media/ssd/recordings/output.mp4
[AVHWDeviceContext @ 0x562b49e14400] libva: /usr/lib64/va/drivers/i965_drv_video.so init failed
[AVHWDeviceContext @ 0x562b49e14400] Failed to initialise VAAPI connection: -1 (unknown libva error).
Device creation failed: -5.
[rawvideo @ 0x562b49e14f80] No device available for decoder: device type vaapi needed for codec rawvideo.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Device setup failed for decoder on input stream #0:0 : Input/output error

I am using a Intel® Iris® Xe Graphics GPU, and here are some use flags:

Code:
[ebuild   R    ] media-libs/mesa-23.0.3-r1::gentoo  USE="X gles1 gles2 llvm opencl vaapi vulkan -d3d9 -debug -lm-sensors -osmesa -proprietary-codecs (-selinux) -test -unwind -valgrind -vdpau -vulkan-overlay -wayland -xa -zink -zstd" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse2" VIDEO_CARDS="intel -d3d12 (-freedreno) (-lima) -nouveau (-panfrost) -r300 -r600 -radeon -radeonsi (-v3d) (-vc4) -virgl (-vivante) -vmware" 0 KiB
[ebuild   R    ] media-libs/libva-2.18.0-r1:0/2::gentoo  USE="X -wayland" ABI_X86="(64) -32 (-x32)" 0 KiB

Code:
adel@t14 ~ $ vainfo
Trying display: x11
libva info: VA-API version 1.18.0
libva info: Trying to open /usr/lib64/va/drivers/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_18
libva error: /usr/lib64/va/drivers/i965_drv_video.so init failed
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit


any idea what I'm missing here?
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4167
Location: Bavaria

PostPosted: Mon Aug 14, 2023 1:03 pm    Post subject: Reply with quote

=> https://wiki.gentoo.org/wiki/Talk:VAAPI
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1663

PostPosted: Mon Aug 14, 2023 1:04 pm    Post subject: Reply with quote

When media-libs/libva is installed, part of the message says, roughly:
Code:
To support "Older Intel GPU support up to Gen8", install media-libs/libva-intel-driver
To support "Newer Intel GPU support from Gen9+", install media-libs/libva-intel-media-driver
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2720

PostPosted: Mon Aug 14, 2023 4:50 pm    Post subject: Reply with quote

fwiw may want to try -c:v h264_vaapi video codec rather than -hwaccel so it doesn't trip on the rawvideo thing, albeit if it doesn't init at all that likely won't help
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3347
Location: Rasi, Finland

PostPosted: Mon Aug 14, 2023 7:19 pm    Post subject: Reply with quote

To me the command looks like you're trying to do vaapi hardware accelerated raw video decoding, not encoding.

Try Ionen's suggestion. And if neccessary add -hwaccel vaapi after you have specified the input (after -i :0.0).
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1523

PostPosted: Tue Aug 15, 2023 10:01 am    Post subject: Reply with quote

thanks grknight, I have installed libva-intel-media-driver and vainfo is working now
as for hardware acceleration of the encoding I modified the command as follows:
Code:
adel@t14 ~ $ ffmpeg -y  -f x11grab -framerate 25 -video_size 1920x1200 -i :0.0 -c:v h264_vaapi  /media/ssd/recordings/output.mp4

but I encountered:
Code:
[x11grab @ 0x565106841940] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0':
  Duration: N/A, start: 1692093486.298151, bitrate: 1843200 kb/s
  Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1200, 1843200 kb/s, 25 fps, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2575
Location: Here and Away Again

PostPosted: Tue Aug 15, 2023 12:10 pm    Post subject: Reply with quote

Try adding

-vaapi_device /dev/dri/renderD128

before input and

-vf 'hwupload,scale_vaapi=format=nv12'

after input as shown in the example here: https://trac.ffmpeg.org/wiki/Hardware/VAAPI#ScreenCapture

Code:
ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -video_size 1920x1080 -i :0 -vf 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi -qp 24 output.mp4

_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1523

PostPosted: Wed Aug 16, 2023 8:34 am    Post subject: Reply with quote

thanks that works like a charm, what about HEVC or h.265? I cannot find the vaapi video codec for that
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2720

PostPosted: Wed Aug 16, 2023 11:31 am    Post subject: Reply with quote

Adel Ahmed wrote:
thanks that works like a charm, what about HEVC or h.265? I cannot find the vaapi video codec for that
There should be -c:v hevc_vaapi, and afaik it should be supported with your hardware (albeit don't use vaapi myself, on nvidia, so not entirely sure)
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1523

PostPosted: Wed Aug 16, 2023 12:25 pm    Post subject: Reply with quote

doesn't seem to work:
Code:
[x11grab @ 0x55c137c29ac0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0':
  Duration: N/A, start: 1692188680.194391, bitrate: 1843200 kb/s
  Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1200, 1843200 kb/s, 25 fps, 1000k tbr, 1000k tbn, 1000k tbc
[NULL @ 0x55c137c37440] Unable to find a suitable output format for 'hevc_vaapi'
hevc_vaapi: Invalid argument

I see it's supported in vainfo though:
Code:
adel@t14 ~ $ vainfo
Trying display: x11
libva info: VA-API version 1.18.0
libva info: Trying to open /usr/lib64/va/drivers/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_18
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.18 (libva 2.18.2)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.6 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :   VAEntrypointVideoProc
      VAProfileNone                   :   VAEntrypointStats
      VAProfileMPEG2Simple            :   VAEntrypointVLD
      VAProfileMPEG2Main              :   VAEntrypointVLD
      VAProfileH264Main               :   VAEntrypointVLD
      VAProfileH264Main               :   VAEntrypointEncSliceLP
      VAProfileH264High               :   VAEntrypointVLD
      VAProfileH264High               :   VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           :   VAEntrypointVLD
      VAProfileJPEGBaseline           :   VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:   VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:   VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :   VAEntrypointVLD
      VAProfileHEVCMain               :   VAEntrypointVLD
      VAProfileHEVCMain               :   VAEntrypointEncSliceLP
      VAProfileHEVCMain10             :   VAEntrypointVLD
      VAProfileHEVCMain10             :   VAEntrypointEncSliceLP
      VAProfileVP9Profile0            :   VAEntrypointVLD
      VAProfileVP9Profile0            :   VAEntrypointEncSliceLP
      VAProfileVP9Profile1            :   VAEntrypointVLD
      VAProfileVP9Profile1            :   VAEntrypointEncSliceLP
      VAProfileVP9Profile2            :   VAEntrypointVLD
      VAProfileVP9Profile2            :   VAEntrypointEncSliceLP
      VAProfileVP9Profile3            :   VAEntrypointVLD
      VAProfileVP9Profile3            :   VAEntrypointEncSliceLP
      VAProfileHEVCMain12             :   VAEntrypointVLD
      VAProfileHEVCMain422_10         :   VAEntrypointVLD
      VAProfileHEVCMain422_12         :   VAEntrypointVLD
      VAProfileHEVCMain444            :   VAEntrypointVLD
      VAProfileHEVCMain444            :   VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         :   VAEntrypointVLD
      VAProfileHEVCMain444_10         :   VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         :   VAEntrypointVLD
      VAProfileHEVCSccMain            :   VAEntrypointVLD
      VAProfileHEVCSccMain            :   VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          :   VAEntrypointVLD
      VAProfileHEVCSccMain10          :   VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         :   VAEntrypointVLD
      VAProfileHEVCSccMain444         :   VAEntrypointEncSliceLP
      VAProfileAV1Profile0            :   VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :   VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :   VAEntrypointEncSliceLP
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2575
Location: Here and Away Again

PostPosted: Wed Aug 16, 2023 12:45 pm    Post subject: Reply with quote

Is it missing from FFmpeg perhaps?

Try 'ffmpeg -encoders | grep vaapi'.

Example output:

Code:
 V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V....D hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V....D mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
 V....D mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V....D vp8_vaapi            VP8 (VAAPI) (codec vp8)
 V....D vp9_vaapi            VP9 (VAAPI) (codec vp9)

_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2720

PostPosted: Wed Aug 16, 2023 2:14 pm    Post subject: Reply with quote

Maybe the format=nv12 or so is not valid for it? Sounds to me hevc_vaapi itself is reporting an error rather than not being found.

The page chiitoo linked gives some hevc examples too, may want to check these.
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2575
Location: Here and Away Again

PostPosted: Wed Aug 16, 2023 6:02 pm    Post subject: Reply with quote

Ionen wrote:
Sounds to me hevc_vaapi itself is reporting an error rather than not being found.

Oh, yeah, probably...

I did try

Code:
ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -video_size 1920x1080 -i :0 -vf 'hwupload,scale_vaapi=format=nv12' -c:v hevc_vaapi -qp 24 output.mp4

which works here with an AMD RX 5700 XT / amdgpu, but yeah, maybe the format is not right for everything.

One of the examples mentions "recent hardware required - Kaby Lake or later Intel"... not sure what that means here, if anything. :]
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1523

PostPosted: Sat Aug 19, 2023 4:11 am    Post subject: Reply with quote

the encoder is present in ffmpeg:
Code:
 V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V....D hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V....D mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
 V....D mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V....D vp8_vaapi            VP8 (VAAPI) (codec vp8)
 V....D vp9_vaapi            VP9 (VAAPI) (codec vp9)


I'll look at the exmaples and try them out
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum