主要需要安装media-driver和它的依赖。
开源,在github上
github 上下下来后,切下版本分支, 然后cmake直接编。
– The C compiler identification is GNU 8.3.0
– The CXX compiler identification is GNU 8.3.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– CMAKE_INSTALL_PREFIX = /usr/local
– Found PkgConfig: /usr/bin/pkg-config (found version “0.29.1”)
– Checking for module ‘libva>=1.0.0’
-- No package 'libva' found
CMake Error at /usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:452 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal)
cmrtlib/linux/CMakeLists.txt:56 (pkg_check_modules)
– Configuring incomplete, errors occurred!
checking for DRM… no
configure: error: Package requirements(libdrm >= 2.4)
were not met:
No package ‘libdrm’ found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables DRM_CFLAGS
and DRM_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
autoreconf: Entering directory .
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4 ${ACLOCAL_FLAGS}
configure.ac:34: error: must install xorg-macros 1.12 or later before running autoconf/autogen
configure.ac:34: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1
checking which warning flags were supported… -Wall -Wextra -Werror=undef -Wsign-compare -Werror-implicit-function-declaration -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wpacked -Wswitch-enum -Wmissing-format-attribute -Wstrict-aliasing=2 -Winit-self -Wdeclaration-after-statement -Wold-style-definition -Wno-unused-parameter -Wno-attributes -Wno-long-long -Winline -Wshadow -Wno-missing-field-initializers
checking for native atomic primitives… Intel
checking for PCIACCESS… no
configure: error: Package requirements (pciaccess >= 0.10) were not met:
No package 'pciaccess' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables PCIACCESS_CFLAGS
and PCIACCESS_LIBS to avoid the need to call pkg-config.
这两个库装好后,回来安装media-drive
CMake Error at media_driver/media_top_cmake.cmake:114 (add_subdirectory):
add_subdirectory given source
“/home/sola/server_source/vaapi-driv/media-driver/…/gmmlib/Source/GmmLib”
which is not an existing directory.
Call Stack (most recent call first):
media_driver/CMakeLists.txt:95 (include)
CMake Error at media_driver/media_top_cmake.cmake:117 (message):
gmm library not found on the system
Call Stack (most recent call first):
media_driver/CMakeLists.txt:95 (include)
– Configuring incomplete, errors occurred!
clone 一份下来 编译安装
注意 sudo apt-get install libigdgmm-dev
这样安装的话,最后编译media-drive的时候会出问题。
装完gmm就能编过了,一切完工。
可以使用vaninfo 查看libva 信息,
然后你可能会遇到这种错误:
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit
你会发现没有 这个 /usr/lib/dri/i965_drv_video.so 库文件, 我尝试做了个软连接 然后就能正常工作了
vainfo
sola@:~/vaapi-driv/media-driver$ vainfo
libva info: VA-API version 1.6.0
libva info: va_getDriverName() returns -1
libva info: User requested driver 'i965'
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit
sola@:~/vaapi-driv/media-driver$
sola@:~/vaapi-driv/media-driver$ cd /usr/local/lib/dri/
sola@:/usr/local/lib/dri$ ls
iHD_drv_video.so
sola@:/usr/local/lib/dri$ sudo ln -s iHD_drv_video.so i965_drv_video.so
sola@:/usr/local/lib/dri$ cd -
/home/sola/vaapi-driv/media-driver
sola@:~/vaapi-driv/media-driver$ vainfo
libva info: VA-API version 1.6.0
libva info: va_getDriverName() returns -1
libva info: User requested driver 'i965'
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.6 (libva 2.4.0)
vainfo: Driver version: Intel iHD driver - 1.0.0
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
VAProfileVP8Version0_3 : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
但这不是正道呀,google了下发现了下面信息。
链接 : https://wiki.archlinux.org/index.php/Hardware_video_acceleration
原来我们只需要配置下这个环境变量即可
export LIBVA_DRIVER_NAME=iHD
最后尝试ffmpeg进行vaapi硬解。
打开 vaapi : ./configure --enable-hwaccel=h264_vaapi --enable-gpl --disable-x86asm --enable-shared
test : ffmpeg -v trace -vaapi_device /dev/dri/card0 -i 720p.mp4 -vf 'format=nv12,hwupload' -c:v h264_vaapi output.mp4
gpu-top