View previous topic :: View next topic |
Author |
Message |
Adel Ahmed Veteran
Joined: 21 Sep 2012 Posts: 1523
|
Posted: Mon Aug 14, 2023 12:56 pm Post subject: vaapi acceleration not working |
|
|
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 |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4167 Location: Bavaria
|
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1663
|
Posted: Mon Aug 14, 2023 1:04 pm Post subject: |
|
|
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 |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2720
|
Posted: Mon Aug 14, 2023 4:50 pm Post subject: |
|
|
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 |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3347 Location: Rasi, Finland
|
Posted: Mon Aug 14, 2023 7:19 pm Post subject: |
|
|
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 |
|
|
Adel Ahmed Veteran
Joined: 21 Sep 2012 Posts: 1523
|
Posted: Tue Aug 15, 2023 10:01 am Post subject: |
|
|
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 |
|
|
Chiitoo Administrator
Joined: 28 Feb 2010 Posts: 2575 Location: Here and Away Again
|
Posted: Tue Aug 15, 2023 12:10 pm Post subject: |
|
|
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 |
|
|
Adel Ahmed Veteran
Joined: 21 Sep 2012 Posts: 1523
|
Posted: Wed Aug 16, 2023 8:34 am Post subject: |
|
|
thanks that works like a charm, what about HEVC or h.265? I cannot find the vaapi video codec for that |
|
Back to top |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2720
|
Posted: Wed Aug 16, 2023 11:31 am Post subject: |
|
|
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 |
|
|
Adel Ahmed Veteran
Joined: 21 Sep 2012 Posts: 1523
|
Posted: Wed Aug 16, 2023 12:25 pm Post subject: |
|
|
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 |
|
|
Chiitoo Administrator
Joined: 28 Feb 2010 Posts: 2575 Location: Here and Away Again
|
Posted: Wed Aug 16, 2023 12:45 pm Post subject: |
|
|
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 |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2720
|
Posted: Wed Aug 16, 2023 2:14 pm Post subject: |
|
|
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 |
|
|
Chiitoo Administrator
Joined: 28 Feb 2010 Posts: 2575 Location: Here and Away Again
|
Posted: Wed Aug 16, 2023 6:02 pm Post subject: |
|
|
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 |
|
|
Adel Ahmed Veteran
Joined: 21 Sep 2012 Posts: 1523
|
Posted: Sat Aug 19, 2023 4:11 am Post subject: |
|
|
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 |
|
|
|