添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
瘦瘦的西瓜  ·  wpf prism viewmodel详解 ...·  2 月前    · 
时尚的海豚  ·  Python字典 ...·  4 月前    · 
无邪的蟠桃  ·  调适 - Zotero Forums·  7 月前    · 

【系统】4.4.131-20200604.kylin.desktop.android-generic

【apt源地址】

deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.0 main restricted universe multiverse
deb http://archive.kylinos.cn/kylin/partner juniper main

【CPU】飞腾D2000/8

【显卡】XXX

【驱动版本】XXX

1.2 问题现象

使用mpv命令行尝试硬解播放视频时出现报错。无法正常播放。

mpv --vo=vaapi --hwdec=vaapi 3840x2160_60fps_Main_h264.mp4
Playing: 3840x2160_60fps_Main_h264.mp4
 (+) Video --vid=1 (*) (h264)
 (+) Audio --aid=1 --alang=und (*) (aac)
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/aarch64-linux-gnu/dri/XXXX_drv_video.so
libva error: /usr/lib/aarch64-linux-gnu/dri/XXXX_drv_video.so has no function __vaDriverInit_0_32
libva info: va_openDriver() returns -1
[vaapi] vaInitialize(): unknown libva error
Error opening/initializing the selected video_out (-vo) device.
Video: no video
AO: [alsa] 48000Hz stereo 2ch float
A: 00:00:01 / 00:03:59 (0%)
Exiting... (Quit)

2 问题定位

XXX显卡支持vaapi标准,使用vaapi硬件加速需要libva的库。该系统自带的libva版本为:1.7.0

dpkg -l | grep libva
ii  libva-wayland1:arm64                        1.7.0-1kord                                   arm64        Video Acceleration (VA) API for Linux -- Wayland runtime
ii  libva-x11-1:arm64                           1.7.0-1kord                                   arm64        Video Acceleration (VA) API for Linux -- X11 runtime
ii  libva1:arm64                                1.7.0-1kord                                   arm64        Video Acceleration (VA) API for Linux -- runtime

而XXX支持的libva的最低版本为2.1.0,该系统上的libva版本不满足要求,故无法正常使用硬解。

3 机理分析

libva1.x.x的版本和2.x.x版本之间存在重大变更,因此2.x.x版本不能向后兼容1.x.x版本。

issue中的问题类似,可以进行参考:github.com/intel/media…

4 解决措施

4.1 源码编译libva、ffmpeg、mpv、ffvademo(后面太长不看版)

libva

tar -xvf libva-2.1.0.tar.gz
cd libva-2.1.0
./autogen.sh -with-drivers-path=/usr/lib/aarch64-linux-gnu/dri
sudo make install

ffmpeg

tar -xvf FFmpeg-n4.2.2.tar.gz
cd FFmpeg-n4.2.2
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./configure --enable-debug --enable-shared
make -j8
sudo make install
sudo ldconfig
ffmpeg -hwaccels
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/XXX
export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
#sudo apt install liblua5.1-0-dev libass-dev libbluray-dev libuchardet-dev librubberband-dev liblcms2-dev libpulse-dev libalsa-ocaml-dev libgbm-dev libx11-dev libxinerama-dev libxv-dev x11proto-scrnsaver-dev libxss-dev libcaca-dev libxrandr-dev libxtst-dev libxi-dev
tar -xvf mpv-depends.tar.gz
cd mpv-depends
sudo dpkg -i *.deb
cd ../
tar -xvf mpv-0.32.0-Waf.tar.gz
cd  mpv-0.32.0
./waf configure --enable-libmpv-shared
./waf build
sudo ./waf install
mpv --vo=gpu --hwdec=vaapi /home/kylin/videos/3840x2160_60fps_Main_h264.mp4

ffvademo

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/XXXX
export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
unzip ffvademo-master.zip
cd ffvademo-master
mkdir build
cd build
cmake ..
make -j8
./ffvademo /home/kylin/videos/3840x2160_60fps_Main_h264.mp4

4.2 源码编译libva

将源码包libva-2.1.0.tar.gz拷贝到系统中,解压并进入解压后的路径内。

tar -xvf libva-2.1.0.tar.gz
cd libva-2.1.0

利用源码包内自带的脚本进行依赖检测以及生成MakeFile文件,执行命令:./autogen.sh

./autogen.sh -with-drivers-path=/usr/lib/aarch64-linux-gnu/dri
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4 ${ACLOCAL_FLAGS}
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf
autoreconf: running: /usr/bin/autoheader
autoreconf: running: automake --add-missing --copy --no-force
configure.ac:166: installing './compile'
configure.ac:166: installing './config.guess'
configure.ac:166: installing './config.sub'
configure.ac:93: installing './install-sh'
configure.ac:93: installing './missing'
va/Makefile.am: installing './depcomp'
va/wayland/Makefile.am:30: warning: source file '../drm/va_drm_utils.c' is in a subdirectory,
va/wayland/Makefile.am:30: but option 'subdir-objects' is disabled
automake: warning: possible forward-incompatibility.
automake: At least a source file is in a subdirectory, but the 'subdir-objects'
automake: automake option hasn't been enabled.  For now, the corresponding output
automake: object file(s) will be placed in the top-level directory.  However,
automake: this behaviour will change in future Automake versions: they will
automake: unconditionally cause object files to be placed in the same subdirectory
automake: of the corresponding sources.
automake: You are advised to start using 'subdir-objects' option throughout your
automake: project, to avoid future incompatibilities.
autoreconf: Leaving directory `.'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert aarch64-unknown-linux-gnu file names to aarch64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert aarch64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for a sed that does not truncate output... (cached) /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ANSI C header files... (cached) yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether __attribute__((visibility())) is supported... yes
checking for DRM... yes
checking for X11... yes
checking for GLX... yes
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glx.h usability... yes
checking GL/glx.h presence... yes
checking for GL/glx.h... yes
checking for glXCreateContext in -lGL... yes
checking for WAYLAND... yes
checking for wayland-scanner... /usr/bin/wayland-scanner
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating pkgconfig/Makefile
config.status: creating pkgconfig/libva-drm.pc
config.status: creating pkgconfig/libva-glx.pc
config.status: creating pkgconfig/libva-wayland.pc
config.status: creating pkgconfig/libva-x11.pc
config.status: creating pkgconfig/libva.pc
config.status: creating va/Makefile
config.status: creating va/drm/Makefile
config.status: creating va/glx/Makefile
config.status: creating va/va_version.h
config.status: creating va/wayland/Makefile
config.status: creating va/x11/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
libva - 2.1.0 (VA-API 1.1.0)
Installation prefix .............. : /usr/local
Default driver path .............. : /usr/lib/aarch64-linux-gnu/dri
Extra window systems ............. : drm x11 glx wayland
Build documentation .............. : no
Build with messaging ............. : yes
Now type 'make' to compile libva.

编译并安装,执行命令:sudo make install

sudo make install
Making install in va
make[1]: Entering directory '/home/kylin/libva/libva-2.1.0/va'
Making install in drm
make[2]: Entering directory '/home/kylin/libva/libva-2.1.0/va/drm'
  CC       va_drm.lo
  CC       va_drm_auth.lo
  CC       va_drm_utils.lo
  CC       va_drm_auth_x11.lo
  CCLD     libva_drm.la
ar: `u' modifier ignored since `D' is the default (see `U')
make[3]: Entering directory '/home/kylin/libva/libva-2.1.0/va/drm'
make[3]: Nothing to be done for 'install-exec-am'.
 /bin/mkdir -p '/usr/local/include/va'
 /usr/bin/install -c -m 644 va_drm.h '/usr/local/include/va'
make[3]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/drm'
make[2]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/drm'
Making install in x11
make[2]: Entering directory '/home/kylin/libva/libva-2.1.0/va/x11'
  CC       dri2_util.lo
  CC       va_dri2.lo
  CC       va_dricommon.lo
  CC       va_fglrx.lo
  CC       va_nvctrl.lo
  CC       va_x11.lo
  CCLD     libva_x11.la
ar: `u' modifier ignored since `D' is the default (see `U')
make[3]: Entering directory '/home/kylin/libva/libva-2.1.0/va/x11'
make[3]: Nothing to be done for 'install-exec-am'.
 /bin/mkdir -p '/usr/local/include/va'
 /usr/bin/install -c -m 644 va_dri2.h va_dricommon.h '/usr/local/include/va'
make[3]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/x11'
make[2]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/x11'
Making install in glx
make[2]: Entering directory '/home/kylin/libva/libva-2.1.0/va/glx'
  CC       va_glx.lo
  CC       va_glx_impl.lo
  CCLD     libva_glx.la
ar: `u' modifier ignored since `D' is the default (see `U')
make[3]: Entering directory '/home/kylin/libva/libva-2.1.0/va/glx'
make[3]: Nothing to be done for 'install-exec-am'.
 /bin/mkdir -p '/usr/local/include/va'
 /usr/bin/install -c -m 644 va_backend_glx.h va_glx.h '/usr/local/include/va'
make[3]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/glx'
make[2]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/glx'
Making install in wayland
make[2]: Entering directory '/home/kylin/libva/libva-2.1.0/va/wayland'
  GEN      wayland-drm-client-protocol.h
  GEN      wayland-drm-client-protocol-export.c
  GEN      wayland-drm-client-protocol.c
make  install-am
make[3]: Entering directory '/home/kylin/libva/libva-2.1.0/va/wayland'
  CC       va_wayland.lo
  CC       va_wayland_drm.lo
  CC       va_wayland_emgd.lo
  CC       va_drm_utils.lo
  CC       wayland-drm-client-protocol.lo
  CCLD     libva_wayland.la
ar: `u' modifier ignored since `D' is the default (see `U')
make[4]: Entering directory '/home/kylin/libva/libva-2.1.0/va/wayland'
make[4]: Nothing to be done for 'install-exec-am'.
 /bin/mkdir -p '/usr/local/include/va'
 /usr/bin/install -c -m 644 va_backend_wayland.h va_wayland.h '/usr/local/include/va'
make[4]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/wayland'
make[3]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/wayland'
make[2]: Leaving directory '/home/kylin/libva/libva-2.1.0/va/wayland'
make[2]: Entering directory '/home/kylin/libva/libva-2.1.0/va'
  CC       va.lo
  CC       va_compat.lo
  CC       va_fool.lo
  CC       va_str.lo
  CC       va_trace.lo
  CCLD     libva.la
  CCLD     libva-drm.la
  CCLD     libva-x11.la
  CCLD     libva-glx.la
  CCLD     libva-wayland.la
make[3]: Entering directory '/home/kylin/libva/libva-2.1.0/va'
 /bin/mkdir -p '/usr/local/lib'
 /bin/bash ../libtool   --mode=install /usr/bin/install -c   libva.la libva-drm.la libva-x11.la libva-glx.la libva-wayland.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libva.so.2.100.0 /usr/local/lib/libva.so.2.100.0
libtool: install: (cd /usr/local/lib && { ln -s -f libva.so.2.100.0 libva.so.2 || { rm -f libva.so.2 && ln -s libva.so.2.100.0 libva.so.2; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libva.so.2.100.0 libva.so || { rm -f libva.so && ln -s libva.so.2.100.0 libva.so; }; })
libtool: install: /usr/bin/install -c .libs/libva.lai /usr/local/lib/libva.la
libtool: warning: relinking 'libva-drm.la'
libtool: install: (cd /home/kylin/libva/libva-2.1.0/va; /bin/bash "/home/kylin/libva/libva-2.1.0/libtool"  --silent --tag CC --mode=relink gcc -g -O2 -version-info 102:0:100 -o libva-drm.la -rpath /usr/local/lib libva.la drm/libva_drm.la -ldrm -ldl )
libtool: install: /usr/bin/install -c .libs/libva-drm.so.2.100.0T /usr/local/lib/libva-drm.so.2.100.0
libtool: install: (cd /usr/local/lib && { ln -s -f libva-drm.so.2.100.0 libva-drm.so.2 || { rm -f libva-drm.so.2 && ln -s libva-drm.so.2.100.0 libva-drm.so.2; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libva-drm.so.2.100.0 libva-drm.so || { rm -f libva-drm.so && ln -s libva-drm.so.2.100.0 libva-drm.so; }; })
libtool: install: /usr/bin/install -c .libs/libva-drm.lai /usr/local/lib/libva-drm.la
libtool: warning: relinking 'libva-x11.la'
libtool: install: (cd /home/kylin/libva/libva-2.1.0/va; /bin/bash "/home/kylin/libva/libva-2.1.0/libtool"  --silent --tag CC --mode=relink gcc -g -O2 -version-info 102:0:100 -o libva-x11.la -rpath /usr/local/lib libva.la x11/libva_x11.la -lX11 -lXext -lXfixes -ldrm -ldl )
libtool: install: /usr/bin/install -c .libs/libva-x11.so.2.100.0T /usr/local/lib/libva-x11.so.2.100.0
libtool: install: (cd /usr/local/lib && { ln -s -f libva-x11.so.2.100.0 libva-x11.so.2 || { rm -f libva-x11.so.2 && ln -s libva-x11.so.2.100.0 libva-x11.so.2; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libva-x11.so.2.100.0 libva-x11.so || { rm -f libva-x11.so && ln -s libva-x11.so.2.100.0 libva-x11.so; }; })
libtool: install: /usr/bin/install -c .libs/libva-x11.lai /usr/local/lib/libva-x11.la
libtool: warning: relinking 'libva-glx.la'
libtool: install: (cd /home/kylin/libva/libva-2.1.0/va; /bin/bash "/home/kylin/libva/libva-2.1.0/libtool"  --silent --tag CC --mode=relink gcc -g -O2 -version-info 102:0:100 -o libva-glx.la -rpath /usr/local/lib libva.la glx/libva_glx.la libva-x11.la -lGL -lX11 -ldl )
libtool: install: /usr/bin/install -c .libs/libva-glx.so.2.100.0T /usr/local/lib/libva-glx.so.2.100.0
libtool: install: (cd /usr/local/lib && { ln -s -f libva-glx.so.2.100.0 libva-glx.so.2 || { rm -f libva-glx.so.2 && ln -s libva-glx.so.2.100.0 libva-glx.so.2; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libva-glx.so.2.100.0 libva-glx.so || { rm -f libva-glx.so && ln -s libva-glx.so.2.100.0 libva-glx.so; }; })
libtool: install: /usr/bin/install -c .libs/libva-glx.lai /usr/local/lib/libva-glx.la
libtool: warning: relinking 'libva-wayland.la'
libtool: install: (cd /home/kylin/libva/libva-2.1.0/va; /bin/bash "/home/kylin/libva/libva-2.1.0/libtool"  --silent --tag CC --mode=relink gcc -g -O2 -version-info 102:0:100 -o libva-wayland.la -rpath /usr/local/lib libva.la wayland/libva_wayland.la -lwayland-client -ldrm -ldl )
libtool: install: /usr/bin/install -c .libs/libva-wayland.so.2.100.0T /usr/local/lib/libva-wayland.so.2.100.0
libtool: install: (cd /usr/local/lib && { ln -s -f libva-wayland.so.2.100.0 libva-wayland.so.2 || { rm -f libva-wayland.so.2 && ln -s libva-wayland.so.2.100.0 libva-wayland.so.2; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libva-wayland.so.2.100.0 libva-wayland.so || { rm -f libva-wayland.so && ln -s libva-wayland.so.2.100.0 libva-wayland.so; }; })
libtool: install: /usr/bin/install -c .libs/libva-wayland.lai /usr/local/lib/libva-wayland.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/include/va'
 /usr/bin/install -c -m 644 va.h va_backend.h va_backend_vpp.h va_compat.h va_dec_hevc.h va_dec_jpeg.h va_dec_vp8.h va_dec_vp9.h va_drmcommon.h va_egl.h va_enc_hevc.h va_enc_h264.h va_enc_jpeg.h va_enc_vp8.h va_fei.h va_fei_h264.h va_enc_mpeg2.h va_fei_hevc.h va_enc_vp9.h va_str.h va_tpi.h va_version.h va_vpp.h va_x11.h '/usr/local/include/va'
make[3]: Leaving directory '/home/kylin/libva/libva-2.1.0/va'
make[2]: Leaving directory '/home/kylin/libva/libva-2.1.0/va'
make[1]: Leaving directory '/home/kylin/libva/libva-2.1.0/va'
Making install in pkgconfig
make[1]: Entering directory '/home/kylin/libva/libva-2.1.0/pkgconfig'
make[2]: Entering directory '/home/kylin/libva/libva-2.1.0/pkgconfig'
make[2]: Nothing to be done for 'install-exec-am'.
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libva.pc libva-drm.pc libva-x11.pc libva-glx.pc libva-wayland.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory '/home/kylin/libva/libva-2.1.0/pkgconfig'
make[1]: Leaving directory '/home/kylin/libva/libva-2.1.0/pkgconfig'
make[1]: Entering directory '/home/kylin/libva/libva-2.1.0'
make[2]: Entering directory '/home/kylin/libva/libva-2.1.0'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/kylin/libva/libva-2.1.0'
make[1]: Leaving directory '/home/kylin/libva/libva-2.1.0'

4.2.1 libva库结构分析(过程记录)

麒麟系统自带版本(1.7.0)

系统自带的libva库位于/usr/lib/aarch64-linux-gnu/

ll /usr/lib/aarch64-linux-gnu/ | grep libva.so
lrwxrwxrwx   1 root root       17 11月 29 11:14 libva.so.1 -> libva.so.1.3900.0
-rw-r--r--   1 root root   100712 4月  26  2016 libva.so.1.3900.0

自编译版本(2.1.0)

自编译的libva库位于/usr/local/lib/

ll /usr/local/lib/ | grep libva
lrwxrwxrwx  1 root root      16 11月 30 09:54 libva.so -> libva.so.2.100.0*
lrwxrwxrwx  1 root root      16 11月 30 09:54 libva.so.2 -> libva.so.2.100.0*
-rwxr-xr-x  1 root root  518344 11月 30 09:54 libva.so.2.100.0*

系统自带的libva库和自编译的libva库存在比较明显的区别

系统自带的libva库对外暴露的是libva.so.1的软链接

自编译的libva库对外暴露的是libva.solibva.so.2的软链接

4.2.2 vainfo测试(过程记录)

使用vainfo,可以打印libva库相关的信息。

如果没有vainfo,需要安装:sudo apt install vainfo

由于需要使用自编译版本,环境变量需要指定

export LD_LIBRARY_PATH=/usr/local/lib
export LIBVA_DRIVER_NAME=XXX
vainfo
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/aarch64-linux-gnu/dri/XXXX_drv_video.so
libva error: /usr/lib/aarch64-linux-gnu/dri/XXX_drv_video.so has no function __vaDriverInit_0_32
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

指定环境变量之后,发现还是跟之前一样的报错,查看一下vainfo的动态库依赖

export LD_LIBRARY_PATH=/usr/local/lib
export LIBVA_DRIVER_NAME=XXX
ldd /usr/bin/vainfo | grep libva
libva.so.1 => /usr/lib/aarch64-linux-gnu/libva.so.1 (0x0000007f95ca8000)
libva-x11.so.1 => /usr/lib/aarch64-linux-gnu/libva-x11.so.1 (0x0000007f95c93000)
libva-drm.so.1 => /usr/lib/aarch64-linux-gnu/libva-drm.so.1 (0x0000007f95b58000)
libva-wayland.so.1 => /usr/lib/aarch64-linux-gnu/libva-wayland.so.1 (0x0000007f95b44000)

发现是通过libva.so.1来找系统中的库,自编译的libva库对外暴露的是libva.solibva.so.2的软链接,自然就无法链接到程序上。

4.2.3 mpv测试(过程记录)

再来测试下mpv

export LD_LIBRARY_PATH=/usr/local/lib
export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
mpv --vo=vaapi --hwdec=vaapi 3840x2160_60fps_Main_h264.mp4
Playing: 3840x2160_60fps_Main_h264.mp4
 (+) Video --vid=1 (*) (h264)
 (+) Audio --aid=1 --alang=und (*) (aac)
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/aarch64-linux-gnu/dri/XXX_drv_video.so
libva error: /usr/lib/aarch64-linux-gnu/dri/XXX_drv_video.so has no function __vaDriverInit_0_32
libva info: va_openDriver() returns -1
[vaapi] vaInitialize(): unknown libva error
Error opening/initializing the selected video_out (-vo) device.
Video: no video
AO: [alsa] 48000Hz stereo 2ch float
A: 00:00:01 / 00:03:59 (0%)
Exiting... (Quit)

错误打印是和之前一样的,同样查看一下mpv的动态库依赖

export LD_LIBRARY_PATH=/usr/local/lib
export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
ldd /usr/bin/mpv | grep libva
libva.so.1 => /usr/lib/aarch64-linux-gnu/libva.so.1 (0x0000007f939d8000)
libva-x11.so.1 => /usr/lib/aarch64-linux-gnu/libva-x11.so.1 (0x0000007f93966000)
libva-wayland.so.1 => /usr/lib/aarch64-linux-gnu/libva-wayland.so.1 (0x0000007f938a4000)

vainfo现象相同

4.2.4 ffvademo测试(过程记录)

vainfompv都是系统提供的软件,可能在源码编译时使用的libva版本就为1.7.0

由于libva库的2.x.x版本不能向后兼容1.x.x版本,所以手动编译的版本也不能被vainfompv用上。

那么手动编译的的程序,能否选择指定的libva库?

这里选择ffvademo进行测试。ffvademoIntel提供的一个简单的基于vaapi标准的播放器。

github仓库地址:github.com/intel/ffvad…

因为这个demo仓库已经多年不维护,实际编译过程中会出现一些问题,需要修改demo的源码

(另外涉及到XXXX相关特性)

建议使用文章内提供的ffvademo版本:文章后续将未进行改动的版本叫做原始版本以作区分

此处仅使用demo对硬件解码的可行性进行验证,下面仅记录影响原始版本编译的两处改动,其余代码改动不进行分析。

4.2.4.1 依赖安装

需要提前安装ffmpeg的相关依赖库

sudo apt install libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev
# 实际安装的库
libavutil-ffmpeg54 libavutil-dev libswresample-ffmpeg1 libavcodec-ffmpeg56 libswresample-dev libavcodec-dev libavformat-ffmpeg56 libavformat-dev libavresample-ffmpeg2 libpostproc-ffmpeg53 libswscale-ffmpeg3 libavfilter-ffmpeg5 libavresample-dev libpostproc-dev libswscale-dev libavfilter-dev
4.2.4.2 源码编译

修改后的版本提供了CMakeLists.txt文件,可以使用cmake进行编译

unzip ffvademo-master.zip
cd ffvademo-master
mkdir build
cd build
cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.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
-- os is Linux
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kylin/test/ffvademo-master/build
export LD_LIBRARY_PATH=/usr/local/lib
make -j8
Scanning dependencies of target ffvademo
[ 16%] Building C object CMakeFiles/ffvademo.dir/src/ffmpeg_utils.c.o
[ 16%] Building C object CMakeFiles/ffvademo.dir/src/ffvafilter.c.o
[ 25%] Building C object CMakeFiles/ffvademo.dir/src/ffvarenderer_drm.c.o
[ 33%] Building C object CMakeFiles/ffvademo.dir/src/ffvademo.c.o
[ 41%] Building C object CMakeFiles/ffvademo.dir/src/ffvadisplay.c.o
[ 50%] Building C object CMakeFiles/ffvademo.dir/src/ffvarenderer_x11.c.o
[ 58%] Building C object CMakeFiles/ffvademo.dir/src/ffvarenderer_egl.c.o
[ 66%] Building C object CMakeFiles/ffvademo.dir/src/ffvadecoder.c.o
/home/kylin/test/ffvademo-master/src/ffvademo.c:55:0: warning: "DEFAULT_RENDERER" redefined
 #define DEFAULT_RENDERER FFVA_RENDERER_TYPE_X11
/home/kylin/test/ffvademo-master/src/ffvademo.c:52:0: note: this is the location of the previous definition
 #define DEFAULT_RENDERER FFVA_RENDERER_TYPE_DRM
[ 75%] Building C object CMakeFiles/ffvademo.dir/src/ffvarenderer.c.o
[ 83%] Building C object CMakeFiles/ffvademo.dir/src/ffvasurface.c.o
[ 91%] Building C object CMakeFiles/ffvademo.dir/src/vaapi_utils.c.o
[100%] Linking C executable ffvademo
/usr/bin/ld: warning: libva.so.1, needed by /usr/lib/gcc/aarch64-linux-gnu/5/../../../aarch64-linux-gnu/libavcodec.so, may conflict with libva.so.2
[100%] Built target ffvademo

查看ffvademo的动态库依赖。这里就比较奇怪了,libva.so.2libva.so.1都链接上去了。

根据之前编译的打印:warning: libva.so.1, needed by /usr/lib/gcc/aarch64-linux-gnu/5/../../../aarch64-linux-gnu/libavcodec.so, may conflict with libva.so.2

libva.so.1被链接上去的原因是libavcodec.so这个ffmpeg的库所需的

ldd ffvademo | grep libva
libva.so.2 => /usr/local/lib/libva.so.2 (0x0000007f7a567000)
libva-x11.so.2 => /usr/local/lib/libva-x11.so.2 (0x0000007f7927f000)
libva.so.1 => /usr/lib/aarch64-linux-gnu/libva.so.1 (0x0000007f78a48000)

还是试一下能否正常播放

./ffvademo /home/kylin/videos/3840x2160_60fps_Main_h264.mp4
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/XXX_drv_video.so
libva info: va_openDriver() returns -1
error: vaInitialize(): unknown libva error
[FFVADemo @ 0xe676370] failed to create VA display

播放失败了,想要完全屏蔽系统libva库的影响,还需要源码编译ffmpeg

4.2.4.3 原始版本编译错误记录

ffvademo-master/src/ffvarenderer_egl.c:29:10: fatal error: drm_fourcc.h: 没有那个文件或目录

29 | #include <drm_fourcc.h>

29 | #include <drm/drm_fourcc.h>

库文件位置变动,需要修改

ffvademo-master/src/ffvadecoder.c:389:40: error: ‘CODEC_CAP_DR1’ undeclared (first use in this function); did you mean ‘AV_CODEC_CAP_DR1’?

389 | if (!(avctx->codec->capabilities & CODEC_CAP_DR1))

389 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1))

ffmpeg版本相关,高版本需要如此修改

4.2.5 强行替换软链接测试(过程记录)

这里是一点邪恶的想法,如果强行替换libva.so.1的软链接,将直接链接到libva.so.2上,能否有效?

libva1.7.02.1.0是否就真的不兼容?

以下操作有风险,谨慎操作

首先备份原来的软链接

sudo mv /usr/lib/aarch64-linux-gnu/libva.so.1.3900.0 /home/kylin/libva/libva.so.1.3900.0
sudo mv /usr/lib/aarch64-linux-gnu/libva-wayland.so.1.3900.0 /home/kylin/libva/libva-wayland.so.1.3900.0
sudo mv /usr/lib/aarch64-linux-gnu/libva-x11.so.1.3900.0 /home/kylin/libva/libva-x11.so.1.3900.0
sudo mv /usr/lib/aarch64-linux-gnu/libva-drm.so.1.3900.0 /home/kylin/libva/libva-drm.so.1.3900.0

拷贝自编译的libva相关库到系统路径下,创建新的libva.so.1软链接指向自编译的libva.so.2软链接上

sudo cp /usr/local/lib/libva* /usr/lib/aarch64-linux-gnu/
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva.so.2.100.0 /usr/lib/aarch64-linux-gnu/libva.so.2
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-wayland.so.2.100.0 /usr/lib/aarch64-linux-gnu/libva-wayland.so.2
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-x11.so.2.100.0 /usr/lib/aarch64-linux-gnu/libva-x11.so.2
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-drm.so.2.100.0 /usr/lib/aarch64-linux-gnu/libva-drm.so.2
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-glx.so.2.100.0 /usr/lib/aarch64-linux-gnu/libva-glx.so.2
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva.so.2 /usr/lib/aarch64-linux-gnu/libva.so.1
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-wayland.so.2 /usr/lib/aarch64-linux-gnu/libva-wayland.so.1
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-x11.so.2 /usr/lib/aarch64-linux-gnu/libva-x11.so.1
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-drm.so.2 /usr/lib/aarch64-linux-gnu/libva-drm.so.1
sudo ln -sf /usr/lib/aarch64-linux-gnu/libva-glx.so.2 /usr/lib/aarch64-linux-gnu/libva-glx.so.1
sudo ldconfig

查看一下链接状态

ll /usr/lib/aarch64-linux-gnu/ | grep libva
-rwxr-xr-x   1 root root      981 11月 30 15:35 libva-drm.la*
-rwxr-xr-x   1 root root    54568 11月 30 15:35 libva-drm.so*
lrwxrwxrwx   1 root root       41 11月 30 15:42 libva-drm.so.1 -> /usr/lib/aarch64-linux-gnu/libva-drm.so.2*
lrwxrwxrwx   1 root root       47 11月 30 15:42 libva-drm.so.2 -> /usr/lib/aarch64-linux-gnu/libva-drm.so.2.100.0*
-rwxr-xr-x   1 root root    54568 11月 30 15:35 libva-drm.so.2.100.0*
-rwxr-xr-x   1 root root     1036 11月 30 15:35 libva-glx.la*
-rwxr-xr-x   1 root root    91824 11月 30 15:35 libva-glx.so*
lrwxrwxrwx   1 root root       41 11月 30 15:42 libva-glx.so.1 -> /usr/lib/aarch64-linux-gnu/libva-glx.so.2*
lrwxrwxrwx   1 root root       47 11月 30 15:42 libva-glx.so.2 -> /usr/lib/aarch64-linux-gnu/libva-glx.so.2.100.0*
-rwxr-xr-x   1 root root    91824 11月 30 15:35 libva-glx.so.2.100.0*
-rwxr-xr-x   1 root root      927 11月 30 15:35 libva.la*
-rwxr-xr-x   1 root root   518344 11月 30 15:35 libva.so*
lrwxrwxrwx   1 root root       37 11月 30 15:42 libva.so.1 -> /usr/lib/aarch64-linux-gnu/libva.so.2*
lrwxrwxrwx   1 root root       43 11月 30 15:42 libva.so.2 -> /usr/lib/aarch64-linux-gnu/libva.so.2.100.0*
-rwxr-xr-x   1 root root   518344 11月 30 15:35 libva.so.2.100.0*
-rwxr-xr-x   1 root root     1022 11月 30 15:35 libva-wayland.la*
-rwxr-xr-x   1 root root    90464 11月 30 15:35 libva-wayland.so*
lrwxrwxrwx   1 root root       45 11月 30 15:42 libva-wayland.so.1 -> /usr/lib/aarch64-linux-gnu/libva-wayland.so.2*
lrwxrwxrwx   1 root root       51 11月 30 15:42 libva-wayland.so.2 -> /usr/lib/aarch64-linux-gnu/libva-wayland.so.2.100.0*
-rwxr-xr-x   1 root root    90464 11月 30 15:35 libva-wayland.so.2.100.0*
-rwxr-xr-x   1 root root     1003 11月 30 15:35 libva-x11.la*
-rwxr-xr-x   1 root root   179424 11月 30 15:35 libva-x11.so*
lrwxrwxrwx   1 root root       41 11月 30 15:42 libva-x11.so.1 -> /usr/lib/aarch64-linux-gnu/libva-x11.so.2*
lrwxrwxrwx   1 root root       47 11月 30 15:42 libva-x11.so.2 -> /usr/lib/aarch64-linux-gnu/libva-x11.so.2.100.0*
-rwxr-xr-x   1 root root   179424 11月 30 15:35 libva-x11.so.2.100.0*

vainfo,看一下打印信息。发现存在部分<unknown profile>

export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
vainfo
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'XXX'
libva info: Trying to open /usr/lib/aarch64-linux-gnu/dri/XXX_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.1 (libva 1.7.0)
vainfo: Driver version: XX XXX driver for XX XXXX Encoder XXENC V6.2 /Decoder XXDEC  - 1.1.2
vainfo: Supported profile and entrypoints
      VAProfileH264Baseline           : VAEntrypointVLD
      VAProfileH264Baseline           : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      <unknown profile>               : VAEntrypointVLD
      <unknown profile>               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      <unknown profile>               : VAEntrypointVLD
      <unknown profile>               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD

mpv试试。段错误了,还是不太行。还是得源码编译ffmpeg

export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
mpv --vo=vaapi --hwdec=vaapi 3840x2160_60fps_Main_h264.mp4
Playing: 3840x2160_60fps_Main_h264.mp4
 (+) Video --vid=1 (*) (h264)
 (+) Audio --aid=1 --alang=und (*) (aac)
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'XXX'
libva info: Trying to open /usr/lib/aarch64-linux-gnu/dri/XXX_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva info: va_openDriver() returns 0
*** Error in `mpv': malloc(): memory corruption: 0x0000007f84331e10 ***
已放弃 (核心已转储)

4.3 源码编译ffmpeg

github仓库地址:github.com/FFmpeg/FFmp…

将源码包FFmpeg-n4.2.2.tar.gz拷贝到系统中,解压并进入解压后的路径内。

tar -xvf FFmpeg-n4.2.2.tar.gz
cd  FFmpeg-n4.2.2

编译时使用的是自编译的libva库,需要注意指定PKG_CONFIG的路径

利用configure进行依赖检测以及生成MakeFile文件,执行命令:./configure --enable-debug --enable-shared

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./configure --enable-debug --enable-shared
install prefix            /usr/local
source path               .
C compiler                gcc
C library                 glibc
ARCH                      aarch64 (generic)
big-endian                no
runtime cpu detection     yes
NEON enabled              yes
VFP enabled               yes
debug symbols             yes
strip symbols             yes
optimize for size         no
optimizations             yes
static                    yes
shared                    yes
postprocessing support    no
network support           yes
threading support         pthreads
safe bitstream reader     yes
texi2html enabled         no
perl enabled              yes
pod2man enabled           yes
makeinfo enabled          no
makeinfo supports HTML    no
External libraries:
alsa                    iconv                   libxcb                  libxcb_shape            libxcb_xfixes           xlib                    zlib
External libraries providing hardware acceleration:
v4l2_m2m                vaapi
Libraries:
avcodec                 avdevice                avfilter                avformat                avutil                  swresample              swscale
Programs:
ffmpeg                  ffprobe
Enabled decoders:
aac                     anm                     dsd_lsbf                h264_v4l2m2m            mpc7                    pcm_s64le               sgirle                  vmdaudio
aac_fixed               ansi                    dsd_lsbf_planar         hap                     mpc8                    pcm_s8                  sheervideo              vmdvideo
aac_latm                ape                     dsd_msbf                hcom                    mpeg1_v4l2m2m           pcm_s8_planar           shorten                 vmnc
aasc                    apng                    dsd_msbf_planar         hevc                    mpeg1video              pcm_u16be               sipr                    vorbis
ac3                     aptx                    dsicinaudio             hnm4_video              mpeg2_v4l2m2m           pcm_u16le               smackaud                vp3
ac3_fixed               aptx_hd                 dsicinvideo             hq_hqa                  mpeg2video              pcm_u24be               smacker                 vp4
adpcm_4xm               arbc                    dss_sp                  hqx                     mpeg4                   pcm_u24le               smc                     vp5
adpcm_adx               ass                     dst                     huffyuv                 mpeg4_v4l2m2m           pcm_u32be               smvjpeg                 vp6
adpcm_afc               asv1                    dvaudio                 hymt                    mpegvideo               pcm_u32le               snow                    vp6a
adpcm_agm               asv2                    dvbsub                  iac                     mpl2                    pcm_u8                  sol_dpcm                vp6f
adpcm_aica              atrac1                  dvdsub                  idcin                   msa1                    pcm_vidc                sonic                   vp7
adpcm_ct                atrac3                  dvvideo                 idf                     mscc                    pcm_zork                sp5x                    vp8
adpcm_dtk               atrac3al                dxa                     iff_ilbm                msmpeg4v1               pcx                     speedhq                 vp8_v4l2m2m
adpcm_ea                atrac3p                 dxtory                  ilbc                    msmpeg4v2               pgm                     srgc                    vp9
adpcm_ea_maxis_xa       atrac3pal               dxv                     imc                     msmpeg4v3               pgmyuv                  srt                     vplayer
adpcm_ea_r1             atrac9                  eac3                    imm4                    msrle                   pgssub                  ssa                     vqa
adpcm_ea_r2             aura                    eacmv                   indeo2                  mss1                    pictor                  stl                     wavpack
adpcm_ea_r3             aura2                   eamad                   indeo3                  mss2                    pixlet                  subrip                  wcmv
adpcm_ea_xas            avrn                    eatgq                   indeo4                  msvideo1                pjs                     subviewer               webp
adpcm_g722              avrp                    eatgv                   indeo5                  mszh                    png                     subviewer1              webvtt
adpcm_g726              avs                     eatqi                   interplay_acm           mts2                    ppm                     sunrast                 wmalossless
adpcm_g726le            avui                    eightbps                interplay_dpcm          mvc1                    prores                  svq1                    wmapro
adpcm_ima_amv           ayuv                    eightsvx_exp            interplay_video         mvc2                    prosumer                svq3                    wmav1
adpcm_ima_apc           bethsoftvid             eightsvx_fib            jacosub                 mwsc                    psd                     tak                     wmav2
adpcm_ima_dat4          bfi                     escape124               jpeg2000                mxpeg                   ptx                     targa                   wmavoice
adpcm_ima_dk3           bink                    escape130               jpegls                  nellymoser              qcelp                   targa_y216              wmv1
adpcm_ima_dk4           binkaudio_dct           evrc                    jv                      nuv                     qdm2                    tdsc                    wmv2
adpcm_ima_ea_eacs       binkaudio_rdft          exr                     kgv1                    on2avc                  qdmc                    text                    wmv3
adpcm_ima_ea_sead       bintext                 ffv1                    kmvc                    opus                    qdraw                   theora                  wmv3image
adpcm_ima_iss           bitpacked               ffvhuff                 lagarith                paf_audio               qpeg                    thp                     wnv1
adpcm_ima_oki           bmp                     ffwavesynth             loco                    paf_video               qtrle                   tiertexseqvideo         wrapped_avframe
adpcm_ima_qt            bmv_audio               fic                     lscr                    pam                     r10k                    tiff                    ws_snd1
adpcm_ima_rad           bmv_video               fits                    m101                    pbm                     r210                    tmv                     xan_dpcm
adpcm_ima_smjpeg        brender_pix             flac                    mace3                   pcm_alaw                ra_144                  truehd                  xan_wc3
adpcm_ima_wav           c93                     flashsv                 mace6                   pcm_bluray              ra_288                  truemotion1             xan_wc4
adpcm_ima_ws            cavs                    flashsv2                magicyuv                pcm_dvd                 ralf                    truemotion2             xbin
adpcm_ms                ccaption                flic                    mdec                    pcm_f16le               rasc                    truemotion2rt           xbm
adpcm_mtaf              cdgraphics              flv                     metasound               pcm_f24le               rawvideo                truespeech              xface
adpcm_psx               cdxl                    fmvc                    microdvd                pcm_f32be               realtext                tscc                    xl
adpcm_sbpro_2           cfhd                    fourxm                  mimic                   pcm_f32le               rl2                     tscc2                   xma1
adpcm_sbpro_3           cinepak                 fraps                   mjpeg                   pcm_f64be               roq                     tta                     xma2
adpcm_sbpro_4           clearvideo              frwu                    mjpegb                  pcm_f64le               roq_dpcm                twinvq                  xpm
adpcm_swf               cljr                    g2m                     mlp                     pcm_lxf                 rpza                    txd                     xsub
adpcm_thp               cllc                    g723_1                  mmvideo                 pcm_mulaw               rscc                    ulti                    xwd
adpcm_thp_le            comfortnoise            g729                    motionpixels            pcm_s16be               rv10                    utvideo                 y41p
adpcm_vima              cook                    gdv                     movtext                 pcm_s16be_planar        rv20                    v210                    ylc
adpcm_xa                cpia                    gif                     mp1                     pcm_s16le               rv30                    v210x                   yop
adpcm_yamaha            cscd                    gremlin_dpcm            mp1float                pcm_s16le_planar        rv40                    v308                    yuv4
agm                     cyuv                    gsm                     mp2                     pcm_s24be               s302m                   v408                    zero12v
aic                     dca                     gsm_ms                  mp2float                pcm_s24daud             sami                    v410                    zerocodec
alac                    dds                     h261                    mp3                     pcm_s24le               sanm                    vb                      zlib
alias_pix               dfa                     h263                    mp3adu                  pcm_s24le_planar        sbc                     vble                    zmbv
als                     dirac                   h263_v4l2m2m            mp3adufloat             pcm_s32be               scpr                    vc1
amrnb                   dnxhd                   h263i                   mp3float                pcm_s32le               screenpresso            vc1_v4l2m2m
amrwb                   dolby_e                 h263p                   mp3on4                  pcm_s32le_planar        sdx2_dpcm               vc1image
amv                     dpx                     h264                    mp3on4float             pcm_s64be               sgi                     vcr1
Enabled encoders:
a64multi                asv1                    flashsv2                mp2fixed                pcm_s16be_planar        pcm_vidc                snow                    vp8_vaapi
a64multi5               asv2                    flv                     mpeg1video              pcm_s16le               pcx                     sonic                   vp9_vaapi
aac                     avrp                    g723_1                  mpeg2_vaapi             pcm_s16le_planar        pgm                     sonic_ls                wavpack
ac3                     avui                    gif                     mpeg2video              pcm_s24be               pgmyuv                  srt                     webvtt
ac3_fixed               ayuv                    h261                    mpeg4                   pcm_s24daud             png                     ssa                     wmav1
adpcm_adx               bmp                     h263                    mpeg4_v4l2m2m           pcm_s24le               ppm                     subrip                  wmav2
adpcm_g722              cinepak                 h263_v4l2m2m            msmpeg4v2               pcm_s24le_planar        prores                  sunrast                 wmv1
adpcm_g726              cljr                    h263p                   msmpeg4v3               pcm_s32be               prores_aw               svq1                    wmv2
adpcm_g726le            comfortnoise            h264_v4l2m2m            msvideo1                pcm_s32le               prores_ks               targa                   wrapped_avframe
adpcm_ima_qt            dca                     h264_vaapi              nellymoser              pcm_s32le_planar        qtrle                   text                    xbm
adpcm_ima_wav           dnxhd                   hevc_vaapi              opus                    pcm_s64be               r10k                    tiff                    xface
adpcm_ms                dpx                     huffyuv                 pam                     pcm_s64le               r210                    truehd                  xsub
adpcm_swf               dvbsub                  jpeg2000                pbm                     pcm_s8                  ra_144                  tta                     xwd
adpcm_yamaha            dvdsub                  jpegls                  pcm_alaw                pcm_s8_planar           rawvideo                utvideo                 y41p
alac                    dvvideo                 ljpeg                   pcm_dvd                 pcm_u16be               roq                     v210                    yuv4
alias_pix               eac3                    magicyuv                pcm_f32be               pcm_u16le               roq_dpcm                v308                    zlib
amv                     ffv1                    mjpeg                   pcm_f32le               pcm_u24be               rv10                    v408                    zmbv
apng                    ffvhuff                 mjpeg_vaapi             pcm_f64be               pcm_u24le               rv20                    v410
aptx                    fits                    mlp                     pcm_f64le               pcm_u32be               s302m                   vc2
aptx_hd                 flac                    movtext                 pcm_mulaw               pcm_u32le               sbc                     vorbis
ass                     flashsv                 mp2                     pcm_s16be               pcm_u8                  sgi                     vp8_v4l2m2m
Enabled hwaccels:
h263_vaapi              hevc_vaapi              mpeg2_vaapi             vc1_vaapi               vp9_vaapi
h264_vaapi              mjpeg_vaapi             mpeg4_vaapi             vp8_vaapi               wmv3_vaapi
Enabled parsers:
aac                     bmp                     dpx                     g723_1                  h264                    mpegvideo               sbc                     vp8
aac_latm                cavsvideo               dvaudio                 g729                    hevc                    opus                    sipr                    vp9
ac3                     cook                    dvbsub                  gif                     mjpeg                   png                     tak                     xma
adx                     dca                     dvd_nav                 gsm                     mlp                     pnm                     vc1
av1                     dirac                   dvdsub                  h261                    mpeg4video              rv30                    vorbis
avs2                    dnxhd                   flac                    h263                    mpegaudio               rv40                    vp3
Enabled demuxers:
aa                      bit                     flic                    image_j2k_pipe          matroska                paf                     rtp                     truehd
aac                     bmv                     flv                     image_jpeg_pipe         mgsts                   pcm_alaw                rtsp                    tta
ac3                     boa                     fourxm                  image_jpegls_pipe       microdvd                pcm_f32be               s337m                   tty
acm                     brstm                   frm                     image_pam_pipe          mjpeg                   pcm_f32le               sami                    txd
act                     c93                     fsb                     image_pbm_pipe          mjpeg_2000              pcm_f64be               sap                     ty
adf                     caf                     g722                    image_pcx_pipe          mlp                     pcm_f64le               sbc                     v210
adp                     cavsvideo               g723_1                  image_pgm_pipe          mlv                     pcm_mulaw               sbg                     v210x
ads                     cdg                     g726                    image_pgmyuv_pipe       mm                      pcm_s16be               scc                     vag
adx                     cdxl                    g726le                  image_pictor_pipe       mmf                     pcm_s16le               sdp                     vc1
aea                     cine                    g729                    image_png_pipe          mov                     pcm_s24be               sdr2                    vc1t
afc                     codec2                  gdv                     image_ppm_pipe          mp3                     pcm_s24le               sds                     vividas
aiff                    codec2raw               genh                    image_psd_pipe          mpc                     pcm_s32be               sdx                     vivo
aix                     concat                  gif                     image_qdraw_pipe        mpc8                    pcm_s32le               segafilm                vmd
amr                     data                    gsm                     image_sgi_pipe          mpegps                  pcm_s8                  ser                     vobsub
amrnb                   daud                    gxf                     image_sunrast_pipe      mpegts                  pcm_u16be               shorten                 voc
amrwb                   dcstr                   h261                    image_svg_pipe          mpegtsraw               pcm_u16le               siff                    vpk
anm                     dfa                     h263                    image_tiff_pipe         mpegvideo               pcm_u24be               sln                     vplayer
apc                     dhav                    h264                    image_webp_pipe         mpjpeg                  pcm_u24le               smacker                 vqf
ape                     dirac                   hcom                    image_xpm_pipe          mpl2                    pcm_u32be               smjpeg                  w64
apng                    dnxhd                   hevc                    image_xwd_pipe          mpsub                   pcm_u32le               smush                   wav
aptx                    dsf                     hls                     ingenient               msf                     pcm_u8                  sol                     wc3
aptx_hd                 dsicin                  hnm                     ipmovie                 msnwc_tcp               pcm_vidc                sox                     webm_dash_manifest
aqtitle                 dss                     ico                     ircam                   mtaf                    pjs                     spdif                   webvtt
asf                     dts                     idcin                   iss                     mtv                     pmp                     srt                     wsaud
asf_o                   dtshd                   idf                     iv8                     musx                    pva                     stl                     wsd
ass                     dv                      iff                     ivf                     mv                      pvf                     str                     wsvqa
ast                     dvbsub                  ifv                     ivr                     mvi                     qcp                     subviewer               wtv
au                      dvbtxt                  ilbc                    jacosub                 mxf                     r3d                     subviewer1              wv
avi                     dxa                     image2                  jv                      mxg                     rawvideo                sup                     wve
avr                     ea                      image2_alias_pix        kux                     nc                      realtext                svag                    xa
avs                     ea_cdata                image2_brender_pix      live_flv                nistsphere              redspark                swf                     xbin
avs2                    eac3                    image2pipe              lmlm4                   nsp                     rl2                     tak                     xmv
bethsoftvid             epaf                    image_bmp_pipe          loas                    nsv                     rm                      tedcaptions             xvag
bfi                     ffmetadata              image_dds_pipe          lrc                     nut                     roq                     thp                     xwma
bfstm                   filmstrip               image_dpx_pipe          lvf                     nuv                     rpl                     threedostr              yop
bink                    fits                    image_exr_pipe          lxf                     ogg                     rsd                     tiertexseq              yuv4mpegpipe
bintext                 flac                    image_gif_pipe          m4v                     oma                     rso                     tmv
Enabled muxers:
a64                     codec2raw               g722                    ivf                     mpeg2svcd               pcm_s16be               rtp_mpegts              tta
ac3                     crc                     g723_1                  jacosub                 mpeg2video              pcm_s16le               rtsp                    uncodedframecrc
adts                    dash                    g726                    latm                    mpeg2vob                pcm_s24be               sap                     vc1
adx                     data                    g726le                  lrc                     mpegts                  pcm_s24le               sbc                     vc1t
aiff                    daud                    gif                     m4v                     mpjpeg                  pcm_s32be               scc                     voc
amr                     dirac                   gsm                     matroska                mxf                     pcm_s32le               segafilm                w64
apng                    dnxhd                   gxf                     matroska_audio          mxf_d10                 pcm_s8                  segment                 wav
aptx                    dts                     h261                    md5                     mxf_opatom              pcm_u16be               singlejpeg              webm
aptx_hd                 dv                      h263                    microdvd                null                    pcm_u16le               smjpeg                  webm_chunk
asf                     eac3                    h264                    mjpeg                   nut                     pcm_u24be               smoothstreaming         webm_dash_manifest
asf_stream              f4v                     hash                    mkvtimestamp_v2         oga                     pcm_u24le               sox                     webp
ass                     ffmetadata              hds                     mlp                     ogg                     pcm_u32be               spdif                   webvtt
ast                     fifo                    hevc                    mmf                     ogv                     pcm_u32le               spx                     wtv
au                      fifo_test               hls                     mov                     oma                     pcm_u8                  srt                     wv
avi                     filmstrip               ico                     mp2                     opus                    pcm_vidc                stream_segment          yuv4mpegpipe
avm2                    fits                    ilbc                    mp3                     pcm_alaw                psp                     sup
avs2                    flac                    image2                  mp4                     pcm_f32be               rawvideo                swf
bit                     flv                     image2pipe              mpeg1system             pcm_f32le               rm                      tee
caf                     framecrc                ipod                    mpeg1vcd                pcm_f64be               roq                     tg2
cavsvideo               framehash               ircam                   mpeg1video              pcm_f64le               rso                     tgp
codec2                  framemd5                ismv                    mpeg2dvd                pcm_mulaw               rtp                     truehd
Enabled protocols:
async                   data                    gopher                  icecast                 pipe                    rtp                     tee
cache                   ffrtmphttp              hls                     md5                     prompeg                 srtp                    udp
concat                  file                    http                    mmsh                    rtmp                    subfile                 udplite
crypto                  ftp                     httpproxy               mmst                    rtmpt                   tcp                     unix
Enabled filters:
abench                  anequalizer             channelmap              detelecine              hdcd                    minterpolate            scale_vaapi             superequalizer
abitscope               anlmdn                  channelsplit            dilation                headphone               mix                     select                  surround
acompressor             anoisesrc               chorus                  displace                hflip                   movie                   selectivecolor          swaprect
acontrast               anull                   chromahold              doubleweave             highpass                negate                  sendcmd                 swapuv
acopy                   anullsink               chromakey               drawbox                 highshelf               nlmeans                 separatefields          tblend
acrossfade              anullsrc                chromashift             drawgraph               hilbert                 noformat                setdar                  telecine
acrossover              apad                    ciescope                drawgrid                histogram               noise                   setfield                testsrc
acrusher                aperms                  codecview               drmeter                 hqx                     normalize               setparams               testsrc2
acue                    aphasemeter             color                   dynaudnorm              hstack                  null                    setpts                  threshold
adeclick                aphaser                 colorbalance            earwax                  hue                     nullsink                setrange                thumbnail
adeclip                 apulsator               colorchannelmixer       ebur128                 hwdownload              nullsrc                 setsar                  tile
adelay                  arealtime               colorhold               edgedetect              hwmap                   oscilloscope            settb                   tlut2
aderivative             aresample               colorkey                elbg                    hwupload                overlay                 sharpness_vaapi         tmix
adrawgraph              areverse                colorlevels             entropy                 hysteresis              pad                     showcqt                 tonemap
aecho                   aselect                 colorspace              equalizer               idet                    pal100bars              showfreqs               tpad
aemphasis               asendcmd                compand                 erosion                 il                      pal75bars               showinfo                transpose
aeval                   asetnsamples            compensationdelay       extractplanes           inflate                 palettegen              showpalette             transpose_vaapi
aevalsrc                asetpts                 concat                  extrastereo             interleave              paletteuse              showspatial             treble
afade                   asetrate                convolution             fade                    join                    pan                     showspectrum            tremolo
afftdn                  asettb                  convolve                fftdnoiz                lagfun                  perms                   showspectrumpic         trim
afftfilt                ashowinfo               copy                    fftfilt                 lenscorrection          pixdesctest             showvolume              unpremultiply
afifo                   asidedata               crop                    field                   life                    pixscope                showwaves               unsharp
afir                    asoftclip               crossfeed               fieldhint               limiter                 premultiply             showwavespic            vectorscope
aformat                 asplit                  crystalizer             fieldmatch              loop                    prewitt                 shuffleframes           vflip
agate                   astats                  cue                     fieldorder              loudnorm                procamp_vaapi           shuffleplanes           vfrdet
agraphmonitor           astreamselect           curves                  fifo                    lowpass                 pseudocolor             sidechaincompress       vibrance
ahistogram              atadenoise              datascope               fillborders             lowshelf                psnr                    sidechaingate           vibrato
aiir                    atempo                  dcshift                 firequalizer            lumakey                 qp                      sidedata                vignette
aintegral               atrim                   dctdnoiz                flanger                 lut                     random                  signalstats             vmafmotion
ainterleave             avectorscope            deband                  floodfill               lut1d                   readeia608              silencedetect           volume
alimiter                avgblur                 deblock                 format                  lut2                    readvitc                silenceremove           volumedetect
allpass                 bandpass                decimate                fps                     lut3d                   realtime                sinc                    vstack
allrgb                  bandreject              deconvolve              framepack               lutrgb                  remap                   sine                    w3fdif
allyuv                  bass                    dedot                   framerate               lutyuv                  removegrain             smptebars               waveform
aloop                   bbox                    deesser                 framestep               mandelbrot              removelogo              smptehdbars             weave
alphaextract            bench                   deflate                 freezedetect            maskedclamp             replaygain              sobel                   xbr
alphamerge              biquad                  deflicker               gblur                   maskedmerge             reverse                 spectrumsynth           xmedian
amerge                  bitplanenoise           deinterlace_vaapi       gradfun                 maskfun                 rgbashift               split                   xstack
ametadata               blackdetect             dejudder                graphmonitor            mcompand                rgbtestsrc              sr                      yadif
amix                    blend                   denoise_vaapi           greyedge                mergeplanes             roberts                 ssim                    yuvtestsrc
amovie                  bm3d                    derain                  haas                    mestimate               rotate                  stereotools             zoompan
amplify                 bwdif                   deshake                 haldclut                metadata                scale                   stereowiden
amultiply               cellauto                despill                 haldclutsrc             midequalizer            scale2ref               streamselect
Enabled bsfs:
aac_adtstoasc           dump_extradata          h264_mp4toannexb        imx_dump_header         mpeg2_metadata          remove_extradata        vp9_raw_reorder
av1_frame_split         eac3_core               h264_redundant_pps      mjpeg2jpeg              mpeg4_unpack_bframes    text2movsub             vp9_superframe
av1_metadata            extract_extradata       hapqa_extract           mjpega_dump_header      noise                   trace_headers           vp9_superframe_split
chomp                   filter_units            hevc_metadata           mov2textsub             null                    truehd_core
dca_core                h264_metadata           hevc_mp4toannexb        mp3_header_decompress   prores_metadata         vp9_metadata
Enabled indevs:
alsa                    fbdev                   lavfi                   oss                     v4l2                    xcbgrab
Enabled outdevs:
alsa                    fbdev                   oss                     v4l2                    xv
License: LGPL version 2.1 or later

编译,执行命令:make -j8,打印比较多,这里就不放了。

安装,执行命令:sudo make install,同样打印比较多,这里就不放了。

检查是否安装成功,vaapi加速是否支持,执行命令:ffmpeg -hwaccels

make -j8
sudo make install
sudo ldconfig
ffmpeg -hwaccels
  built with gcc 5.4.0 (Ubuntu/Linaro 5.4.0-6kord1~16.04.12) 20160609
  configuration: --enable-debug --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Hardware acceleration methods:
vaapi

4.3.1 ffvademo验证(过程记录)

编译时使用的是自编译的ffmpeglibva库,需要注意指定PKG_CONFIG的路径

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

编译过程不再赘述,直接来到验证过程

./ffvademo /home/kylin/videos/3840x2160_60fps_Main_h264.mp4
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/aarch64-linux-gnu/dri/XXX_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva info: va_openDriver() returns 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/kylin/videos/3840x2160_60fps_Main_h264.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.48.100
  Duration: 00:03:59.17, start: 0.000000, bitrate: 47385 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 47251 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[h264 @ 0x2567f4b0] Using deprecated struct vaapi_context in decode.
pci id for fd 8: 0731:9230, driver (null)
libEGL warning: DRI3: No driver found
pci id for fd 8: 0731:9230, driver (null)
libEGL warning: DRI2: failed to open XXX (search paths /usr/lib/aarch64-linux-gnu/dri:${ORIGIN}/dri:/usr/lib/dri)
 compile failed error info : ▒▒▒& .
./src/XXX_egl_opengl_display.c:1129:videoDraw() ERROR display video error !

观察这两行打印是没找到驱动?

0731:9230, driver (null) libEGL warning: DRI3: No driver found

看一下ffvademoEGL程序的动态库依赖

ldd ffvademo  | grep EGL
libEGL.so.1 => /usr/lib/aarch64-linux-gnu/mesa-egl/libEGL.so.1 (0x0000007f9efc5000)

链接到了mesa的库,正常应该链接到XXX的库,指定一下lib库有限查找的地址

export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/XXXX
ldd ffvademo  | grep EGL
libEGL.so.1 => /usr/lib/aarch64-linux-gnu/XXX/libEGL.so.1 (0x0000007fa4d91000)

再播放试试,已经能够正常播放了

export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/XXXX
./ffvademo /home/kylin/videos/3840x2160_60fps_Main_h264.mp4
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/aarch64-linux-gnu/dri/XXX_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva info: va_openDriver() returns 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/kylin/videos/3840x2160_60fps_Main_h264.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.48.100
  Duration: 00:03:59.17, start: 0.000000, bitrate: 47385 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 47251 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[h264 @ 0x1b903f0] Using deprecated struct vaapi_context in decode.

4.4 源码编译mpv(可选)

github仓库地址:github.com/mpv-player/…

将源码包mpv-0.32.0-Waf.tar.gz拷贝到系统中,解压并进入解压后的路径内。

mpv需要使用waf工具进行编译,默认版本需要联网下载waf

tar -xvf mpv-0.32.0-Waf.tar.gz
cd  mpv-0.32.0

需要提前安装的相关依赖库

sudo apt install liblua5.1-0-dev libass-dev libbluray-dev libuchardet-dev librubberband-dev liblcms2-dev libpulse-dev libalsa-ocaml-dev libgbm-dev libx11-dev libxinerama-dev libxv-dev x11proto-scrnsaver-dev libxss-dev libcaca-dev libxrandr-dev libxtst-dev libxi-dev
# 实际安装的库(80个包)
apt download libncurses5 libtinfo5 libncursesw5 liblua5.1-0 libtinfo-dev libreadline6-dev libreadline-dev liblua5.1-0-dev libtool-bin libexpat1 libexpat1-dev libpng12-0 libfreetype6 libpng12-dev libfreetype6-dev libfontconfig1-dev libfribidi-dev libharfbuzz-gobject0 libharfbuzz-dev libass-dev libbluray-dev libuchardet0 libuchardet-dev librubberband-dev liblcms2-dev libglib2.0-0 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpcre16-3 libpcre3 libglib2.0-bin libglib2.0-dev libpulsedsp pulseaudio-utils pulseaudio-module-bluetooth pulseaudio libpulse-mainloop-glib0 libpulse0 libpulse-dev ocaml-base-nox libncurses5-dev ocaml-compiler-libs ocaml-interp ocaml-nox libcamlp4-ocaml-dev camlp4 ledit libalsa-ocaml libasound2-dev libfindlib-ocaml ocaml-findlib libalsa-ocaml-dev libfindlib-ocaml-dev libegl1-mesa-dev libwayland-egl1-mesa libegl1-mesa libgbm1 libgl1-mesa-dri libgbm-dev libx11-6 libx11-dev x11proto-xinerama-dev libxinerama-dev libxv1 x11proto-video-dev libxv-dev x11proto-scrnsaver-dev libxss-dev libcaca0 libslang2-dev libcaca-dev libxrandr-dev libxrandr2 libxrender-dev x11proto-randr-dev x11proto-render-dev libxi-dev libxtst-dev x11proto-record-dev

编译时使用的是自编译的ffmpeglibva库,需要注意指定PKG_CONFIG的路径

利用waf进行依赖检测以及生成MakeFile文件,执行命令:./waf configure --enable-libmpv-shared

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/XXXX
export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
./waf configure --enable-libmpv-shared
Setting top to                           : /home/kylin/mpv/mpv-0.32.0
Setting out to                           : /home/kylin/mpv/mpv-0.32.0/build
Checking for waf version in 1.8.4-2.1.0  : ok
Checking for program 'cc'                : /usr/bin/cc
Checking for program 'pkg-config'        : /usr/bin/pkg-config
Checking for program 'ar'                : /usr/bin/ar
Checking for program 'rst2html'          : not found
Checking for program 'rst2man'           : not found
Checking for program 'rst2pdf'           : not found
Checking for program 'windres'           : not found
Checking for program 'perl'              : /usr/bin/perl
Checking for 'gcc' (C compiler)          : /usr/bin/cc
Detected target OS:                      : os-linux
Checking for compiler flags -std=c11     : yes
Checking for compiler flags -Werror -Werror=implicit-function-declaration : yes
Checking for compiler flags -Werror -Wno-error=deprecated-declarations    : yes
Checking for compiler flags -Werror -Wno-error=unused-function            : yes
Checking for compiler flags -Werror -Wempty-body                          : yes
Checking for compiler flags -Werror -Wdisabled-optimization               : yes
Checking for compiler flags -Werror -Wstrict-prototypes                   : yes
Checking for compiler flags -Werror -Wno-format-zero-length               : yes
Checking for compiler flags -Werror -Werror=format-security               : yes
Checking for compiler flags -Werror -Wno-redundant-decls                  : yes
Checking for compiler flags -Werror -Wvla                                 : yes
Checking for compiler flags -Werror -Wno-format-truncation                : yes
Checking for compiler flags -Werror -Wimplicit-fallthrough                : no
Checking for LGPL (version 2.1 or later) build                            : disabled
Checking for GPL (version 2 or later) build                               : yes
Checking for mpv CLI player                                               : yes
Checking for shared library                                               : yes
Checking for static library                                               : disabled
Checking for static build                                                 : disabled
Checking for whether to include binary compile time                       : yes
Checking for whether to optimize                                          : yes
Checking for whether to compile-in debugging information                  : yes
Checking for unit tests (development only)                                : disabled
Checking for enable ta leak report by default (development only)          : disabled
Checking for manpage generation                                           : no (missing RST2MAN)
Checking for html manual generation                                       : disabled
Checking for pdf manual generation                                        : disabled
Checking for dynamic loader                                               : yes
Checking for C plugins                                                    : yes
Checking for inline assembly (currently without effect)                   : yes
Checking for generate a clang compilation database                        : disabled
Checking for static Swift linking                                         : disabled
Checking for compiler support for noexecstack                             : yes
Checking for linker support for --nxcompat --no-seh --dynamicbase         : no
Checking for -lm                                                          : yes
Checking for MinGW                                                        : os-win32 not found
Checking for POSIX environment                                            : yes
Checking for Android environment                                          : no
Checking for tvOS environment                                             : no
Checking for Android EGL support                                          : android not found
Checking for development environment                                      : yes
Checking for macOS Swift build tools                                      : os-darwin not found
Checking for Universal Windows Platform                                   : disabled
Checking for win32 desktop APIs                                           : os-win32 not found
Checking for internal pthread wrapper for win32 (Vista+)                  : posix found
Checking for POSIX threads                                                : yes
Checking for GNU C extensions                                             : yes
Checking for stdatomic.h                                                  : yes
Checking for C11 aligned_alloc()                                          : yes
Checking for stdatomic.h support or slow emulation                        : yes
Checking for linking with -lrt                                            : yes
Checking for iconv                                                        : yes
Checking for w32/dos paths                                                : os-win32 not found
Checking for spawnp()/kill() POSIX support                                : yes
Checking for spawnp()/kill() Android replacement                          : posix-spawn-native found
Checking for any spawnp()/kill() support                                  : yes
Checking for Windows pipe support                                         : posix found
Checking for glob() POSIX support                                         : yes
Checking for glob() win32 replacement                                     : posix found
Checking for any glob() support                                           : yes
Checking for fchmod()                                                     : yes
Checking for vt.h                                                         : yes
Checking for gbm.h                                                        : yes
Checking for GLIBC API for setting thread name                            : yes
Checking for OSX API for setting thread name                              : glibc-thread-name found
Checking for BSD API for setting thread name                              : glibc-thread-name found
Checking for BSD's fstatfs()                                              : no
Checking for Linux's fstatfs()                                            : yes
Checking for Linux's memfd_create()                                       : no
Checking for Samba support (makes mpv GPLv3)                              : disabled
Checking for Lua                                                          : yes (version found: 51obsd)
Checking for Javascript (MuJS backend)                                    : no ('mujs >= 1.0.0' not found)
Checking for SSA/ASS support                                              : yes
Checking for libass OSD support                                           : yes
Checking for dummy OSD support                                            : libass-osd found
Checking for zlib                                                         : yes
Checking for Bluray support                                               : yes
Checking for dvdnav support                                               : disabled
Checking for cdda support (libcdio)                                       : disabled
Checking for uchardet support                                             : yes
Checking for librubberband support                                        : yes
Checking for libzimg support (high quality software scaler)               : no ('zimg >= 2.9' not found)
Checking for LCMS2 support                                                : yes
Checking for VapourSynth filter bridge                                    : no ('vapoursynth >= 24 vapoursynth-script >= 23' not found)
Checking for libarchive wrapper for reading zip files and more            : no ('libarchive >= 3.4.0' not found)
Checking for DVB input module                                             : disabled
Checking for SDL2                                                         : disabled
Checking for SDL2 gamepad input                                           : sdl2 not found
Checking for FFmpeg/Libav present                                         : yes
Checking for FFmpeg/Libav libavutil present                               : yes
Checking for libav* is FFmpeg                                             : yes
Checking for libav* is Libav                                              : no
Checking for Libav/FFmpeg library versions                                : yes
Checking for libavdevice                                                  : yes
Checking for Disable all known FFmpeg ABI violations                      : disabled
Checking for SDL2 audio output                                            : sdl2 not found
Checking for OSS                                                          : yes
Checking for RSound audio output                                          : no
Checking for sndio audio input/output                                     : disabled
Checking for PulseAudio audio output                                      : yes
Checking for JACK audio output                                            : no ('jack' not found)
Checking for OpenAL audio output                                          : disabled
Checking for OpenSL ES audio output                                       : no
Checking for ALSA audio output                                            : yes
Checking for CoreAudio audio output                                       : no
Checking for AudioUnit output for iOS                                     : no
Checking for WASAPI audio output                                          : os-win32 not found
Checking for SDL2 video output                                            : sdl2 not found
Checking for Cocoa                                                        : no
Checking for DRM                                                          : yes
Checking for DRM Prime ffmpeg support                                     : yes
Checking for GBM                                                          : yes
Checking for wayland-scanner                                              : yes
Checking for wayland-protocols                                            : no ('wayland-protocols >= 1.15' not found)
Checking for Wayland                                                      : wayland-protocols not found
Checking for X11                                                          : yes
Checking for Xv video output                                              : yes
Checking for OpenGL Cocoa Backend                                         : cocoa not found
Checking for OpenGL X11 Backend                                           : yes
Checking for EGL 1.4                                                      : yes
Checking for OpenGL X11 EGL Backend                                       : yes
Checking for OpenGL DRM EGL Backend                                       : yes
Checking for OpenGL Wayland Backend                                       : wayland not found
Checking for OpenGL Win32 Backend                                         : win32-desktop not found
Checking for OpenGL/DirectX Interop Backend                               : gl-win32 not found
Checking for OpenGL ANGLE headers                                         : os-win32 not found
Checking for OpenGL Win32 ANGLE Library                                   : egl-angle not found
Checking for OpenGL Win32 ANGLE Backend                                   : egl-angle not found
Checking for VDPAU acceleration                                           : no ('vdpau >= 0.2' not found)
Checking for VDPAU with OpenGL/X11                                        : vdpau not found
Checking for VAAPI acceleration                                           : yes
Checking for VAAPI (X11 support)                                          : yes
Checking for VAAPI (Wayland support)                                      : gl-wayland not found
Checking for VAAPI (DRM/EGL support)                                      : yes
Checking for VAAPI EGL on X11                                             : yes
Checking for VAAPI EGL                                                    : yes
Checking for CACA                                                         : yes
Checking for JPEG support                                                 : yes
Checking for Direct3D support                                             : win32-desktop not found
Checking for libshaderc SPIR-V compiler (shared library)                  : no
Checking for libshaderc SPIR-V compiler (static library)                  : no
Checking for libshaderc SPIR-V compiler                                   : shaderc-shared not found
Checking for SPIRV-Cross SPIR-V shader converter (shared library)         : no ('spirv-cross-c-shared' not found)
Checking for SPIRV-Cross SPIR-V shader converter (static library)         : no ('spirv-cross' not found)
Checking for SPIRV-Cross SPIR-V shader converter                          : spirv-cross-shared not found
Checking for Direct3D 11 video output                                     : win32-desktop not found
Checking for Raspberry Pi support                                         : no ('brcmegl' not found)
Checking for iOS OpenGL ES hardware decoding interop support              : no
Checking for OpenGL without platform-specific code (e.g. for libmpv)      : yes
Checking for OpenGL context support                                       : yes
Checking for libplacebo support                                           : no ('libplacebo >= 1.18.0' not found)
Checking for Vulkan context support                                       : libplacebo not found
Checking for VAAPI Vulkan                                                 : vulkan not found
Checking for EGL helper functions                                         : yes
Checking for libavcodec videotoolbox hwaccel                              : gl-cocoa not found
Checking for Videotoolbox with OpenGL                                     : gl-cocoa not found
Checking for D3D11VA hwaccel                                              : os-win32 not found
Checking for DXVA2 hwaccel                                                : d3d-hwaccel not found
Checking for OpenGL/DirectX Interop Backend DXVA2 interop                 : gl-dxinterop not found
Checking for CUDA Headers and dynamic loader                              : no ('ffnvcodec >= 8.2.15.7' not found)
Checking for CUDA acceleration                                            : ffnvcodec not found
Checking for CUDA with graphics interop                                   : cuda-hwaccel not found
Checking for Raspberry Pi MMAL hwaccel                                    : rpi not found
Checking for w32 executable                                               : os-win32 not found
Checking for macOS Touch Bar support                                      : cocoa not found
Checking for macOS 10.11 SDK Features                                     : cocoa not found
Checking for macOS 10.12.2 SDK Features                                   : cocoa not found
Checking for macOS 10.14 SDK Features                                     : cocoa not found
Checking for macOS Media Player support                                   : macos-10-12-2-features not found
Checking for macOS libmpv backend                                         : cocoa not found
Writing configuration header:                                             : config.h
'configure' finished successfully (3.129s)

编译,执行命令:./waf build,打印比较多,这里就不放了。

安装,执行命令:sudo ./waf install

sudo ./waf install
Waf: Entering directory `/home/kylin/mpv/mpv-0.32.0/build'
[1/1] Compiling version.sh
+ install /usr/local/bin/mpv (from build/mpv)
+ install /usr/local/share/doc/mpv/input.conf (from etc/input.conf)
+ install /usr/local/share/doc/mpv/mpv.conf (from etc/mpv.conf)
+ install /usr/local/share/doc/mpv/mplayer-input.conf (from etc/mplayer-input.conf)
+ install /usr/local/share/doc/mpv/restore-old-bindings.conf (from etc/restore-old-bindings.conf)
+ symlink /usr/local/lib/libmpv.so (to libmpv.so.1.107.0)
+ install /usr/local/lib/libmpv.so.1.107.0 (from build/libmpv.so)
+ symlink /usr/local/lib/libmpv.so.1 (to libmpv.so.1.107.0)
+ install /usr/local/include/mpv/client.h (from libmpv/client.h)
+ install /usr/local/include/mpv/qthelper.hpp (from libmpv/qthelper.hpp)
+ install /usr/local/include/mpv/opengl_cb.h (from libmpv/opengl_cb.h)
+ install /usr/local/include/mpv/render.h (from libmpv/render.h)
+ install /usr/local/include/mpv/render_gl.h (from libmpv/render_gl.h)
+ install /usr/local/include/mpv/stream_cb.h (from libmpv/stream_cb.h)
+ install /usr/local/lib/pkgconfig/mpv.pc (from build/libmpv/mpv.pc)
+ install /usr/local/share/zsh/site-functions/_mpv (from etc/_mpv.zsh)
+ install /usr/local/share/applications/mpv.desktop (from etc/mpv.desktop)
+ install /usr/local/share/bash-completion/completions/mpv (from etc/mpv.bash-completion)
+ install /usr/local/share/icons/hicolor/16x16/apps/mpv.png (from etc/mpv-icon-8bit-16x16.png)
+ install /usr/local/etc/mpv/encoding-profiles.conf (from etc/encoding-profiles.conf)
+ install /usr/local/share/icons/hicolor/32x32/apps/mpv.png (from etc/mpv-icon-8bit-32x32.png)
+ install /usr/local/share/icons/hicolor/64x64/apps/mpv.png (from etc/mpv-icon-8bit-64x64.png)
+ install /usr/local/share/icons/hicolor/scalable/apps/mpv.svg (from etc/mpv-gradient.svg)
+ install /usr/local/share/icons/hicolor/symbolic/apps/mpv-symbolic.svg (from etc/mpv-symbolic.svg)
Waf: Leaving directory `/home/kylin/mpv/mpv-0.32.0/build'
'install' finished successfully (0.975s)

试一下播放视频,能够正常播放且使用硬件解码。

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/XXX
export LIBVA_DRIVER_NAME=XXX
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri
mpv --vo=gpu --hwdec=vaapi /home/kylin/videos/3840x2160_60fps_Main_h264.mp4
 (+) Video --vid=1 (*) (h264 3840x2160 60.000fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
[     1] sorry, we do not support opengl version 4.4 ...
Using hardware decoding (vaapi).
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 3840x2160 vaapi[nv12]

4.5 影响分析

4.5.1 libva

安装路径为:/usr/local/lib

PKG_CONFIG文件路径为:/usr/local/lib/pkgconfig

和系统默认路径不一致,不会对系统环境造成影响

4.5.2 ffmpeg

安装路径为:/usr/local/lib

PKG_CONFIG文件路径为:/usr/local/lib/pkgconfig

和系统默认路径不一致,不会对系统环境造成影响

4.5.3 mpv

额外安装许多包,对系统部分包进行了升级。

sudo apt install liblua5.1-0-dev libass-dev libbluray-dev libuchardet-dev librubberband-dev liblcms2-dev libpulse-dev libalsa-ocaml-dev libgbm-dev libx11-dev libxinerama-dev libxv-dev x11proto-scrnsaver-dev libxss-dev libcaca-dev libxrandr-dev libxtst-dev libxi-dev
# 实际安装的库(80个包)
apt download libncurses5 libtinfo5 libncursesw5 liblua5.1-0 libtinfo-dev libreadline6-dev libreadline-dev liblua5.1-0-dev libtool-bin libexpat1 libexpat1-dev libpng12-0 libfreetype6 libpng12-dev libfreetype6-dev libfontconfig1-dev libfribidi-dev libharfbuzz-gobject0 libharfbuzz-dev libass-dev libbluray-dev libuchardet0 libuchardet-dev librubberband-dev liblcms2-dev libglib2.0-0 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpcre16-3 libpcre3 libglib2.0-bin libglib2.0-dev libpulsedsp pulseaudio-utils pulseaudio-module-bluetooth pulseaudio libpulse-mainloop-glib0 libpulse0 libpulse-dev ocaml-base-nox libncurses5-dev ocaml-compiler-libs ocaml-interp ocaml-nox libcamlp4-ocaml-dev camlp4 ledit libalsa-ocaml libasound2-dev libfindlib-ocaml ocaml-findlib libalsa-ocaml-dev libfindlib-ocaml-dev libegl1-mesa-dev libwayland-egl1-mesa libegl1-mesa libgbm1 libgl1-mesa-dri libgbm-dev libx11-6 libx11-dev x11proto-xinerama-dev libxinerama-dev libxv1 x11proto-video-dev libxv-dev x11proto-scrnsaver-dev libxss-dev libcaca0 libslang2-dev libcaca-dev libxrandr-dev libxrandr2 libxrender-dev x11proto-randr-dev x11proto-render-dev libxi-dev libxtst-dev x11proto-record-dev

解决了该系统声卡驱动导致系统设置界面闪退的问题

暂时无法评估

安装路径为:/usr/local/lib

可执行文件程序为:/usr/local/bin/mpv

PKG_CONFIG文件路径为:/usr/local/lib/pkgconfig

对系统默认的mpv链接项进行了更改,终端运行mpv为新安装的版本

对麒麟影音的影响:

软解暂未发现不良影响,硬解在麒麟影音依然不可用,但mpv可以正常硬解。

5 举一反三

查看其他内核版本为4.4.131-xxx开头的系统,发现普遍存在libva版本较低,XXX硬件解码不支持的问题。

类似的麒麟V4系统,均可以参照本篇文章搭建libvaffmpegmpv(可选)环境,支持XXX硬件解码。