Article directory
-
- Ubuntu 20.04 manually compiles ffmpeg integrating qsv
-
- 1. Prospects
- 2. Manually compile and install ffmpeg related dependencies
-
- 1. Compilation required dependencies
- 2. Compile and install libva
- 3. Compile and install libva-utils
- 4. Compile and install gmmlib
- 5. Compile and install intel-media-driver
- 6. Verify intel-media-driver installation
- 7. Compile and install intel-media-sdk
- 8. Javacv's ffmpeg and the corresponding platform's dependent file package
- 3. Article description
Ubuntu 20.04 manually compiles ffmpeg integrating qsv
1. Prospects
The author's previous operations related to enabling ffmpeg hardware acceleration are all based on ubuntu 22.04
the docker image used in the actual project based on ubuntu20.04
using the same command
apt-get install -y libmfx1 libmfx-tools \
libva-dev libmfx-dev intel-media-va-driver-non-free vainfo
Also set related environment variables. The vainfo command always shows that the driver initialization failed. Using the strace vainfo
command, it is found that the file is missing cplib.so
, and the dependent file is searched intel media driver 安装自带
. So far, it has reached a deadlock
. At this time, there is not much time to spend on finding the reason, so the author chooses manual installation
2. Manually compile and install ffmpeg related dependencies
Need to install:
- be ripe
- libva-utils
- gmmlib
- intel-media-driver
- intel-media-sdk
From top to bottom, it can be said that the lower layer depends on the installation of the upper layer
. Based on the installation experience of intel media sdk, all other dependent installation paths are set to /opt/intel/mediasdk/
The release version of the intel media sdk will explain the version corresponding to the above content to be installed.
Take the latest version as an example:
the next steps are also compiled and installed based on the latest released version
1. Compilation required dependencies
apt-get install -y git make cmake autoconf meson libtool pkg-config build-essential gcc g++
2. Compile and install libva
LIBVA_VERSION=2.16.0
git clone https://github.com/intel/libva.git
cd libva/
git checkout $LIBVA_VERSION
./autogen.sh --prefix=/opt/intel/mediasdk/
make -j8
sudo make install
3. Compile and install libva-utils
LIBVAUTILS_VERSION=2.16.0
git clone https://github.com/intel/libva-utils.git
cd libva-utils/
git checkout $LIBVAUTILS_VERSION
./autogen.sh --prefix=/opt/intel/mediasdk
make -j8
sudo make install
4. Compile and install gmmlib
GMMLIB_VERSION=intel-gmmlib-22.2.0
git clone https://github.com/intel/gmmlib.git
cd gmmlib
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/intel/mediasdk ..
make -j8
sudo make install
5. Compile and install intel-media-driver
MEDIA_DRIVER_VERSION=intel-media-22.5.4
git clone https://github.com/intel/media-driver.git
cd media-driver/
git checkout $MEDIA_DRIVER_VERSION
cd ../
mkdir build_media && cd build_media
cmake -DCMAKE_INSTALL_PREFIX=/opt/intel/mediasdk/ ../media-driver
make -j8
sudo make install
The installation process shows that some dependencies are missing, simply solve it with the following command
apt-get install -y libx11-dev libva-dev
set environment variables
LIBVA_DRIVER_NAME=iHD
LIBVA_DRIVERS_PATH=/opt/intel/mediasdk/lib/dri
PKG_CONFIG_PATH=/opt/intel/mediasdk/lib/pkgconfig
6. Verify intel-media-driver installation
Use the vainfo tool that comes with libva-utils to check whether the media driver is set successfully
/opt/intel/mediasdk/bin/vainfo
. If you find something wrong, share a small tip learned from the github Issue, and use strace /opt/intel/mediasdk/bin/vainfo to see Specifically which link has the problem, the environment variable is not set or a certain dependency is missing
7. Compile and install intel-media-sdk
During the compilation process, there was an error of missing related dependencies. By finding out how to download the dependencies, first perform the following steps
ONEVPL_VERSION=intel-onevpl-22.5.4
git clone https://github.com/oneapi-src/oneVPL-intel-gpu onevpl-gpu
cd onevpl-gpu
git checkout $ONEVPL_VERSION
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/intel/mediasdk ..
make -j8
sudo make install
MEDIA_SDK_VERSION=intel-mediasdk-22.5.4
git clone https://github.com/Intel-Media-SDK/MediaSDK.git msdk
cd msdk
git checkout $MEDIA_SDK_VERSION
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/intel/mediasdk ..
make -j8
sudo make install
8. Javacv's ffmpeg and the corresponding platform's dependent file package
Refer to this blog , after performing the above manual compilation and installation, refer to javacpp-preset下重新编译ffmpeg
the steps in the blog
If there is a lack of dependencies during the installation of ffmpeg, you need to modify the ffmpeg compilation configuration in the cppbuild.sh file, and add /opt/intel/mediasdk/lib and /opt/intel/mediasdk/include to the lib file and header file paths respectively
3. Article description
The above author has not really found out the underlying reason why the media driver initialization failure problem occurs when using the libva and intel media driver versions that come with the system on ubuntu20.04. Please correct me if I am wrong