Open liuty10 opened 4 years ago
So, the configuration should be like this.
PATH="$HOME/FFMPEG/bin:$PATH" PKG_CONFIG_PATH="$HOME/FFMPEG/ffmpeg_build/lib/pkgconfig:/opt/intel/mediasdk/lib/pkgconfig" ./configure \
--pkg-config-flags="--static" \
--enable-static --disable-shared \
--prefix="$HOME/FFMPEG/ffmpeg_build" \
--bindir="$HOME/FFMPEG/bin" \
--extra-cflags="-I$HOME/FFMPEG/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/FFMPEG/ffmpeg_build/lib" \
--extra-cflags="-I/opt/intel/mediasdk/include" \
--extra-ldflags="-L/opt/intel/mediasdk/lib" \
--extra-ldflags="-L/opt/intel/mediasdk/plugins" \
--extra-cflags="-I/usr/local/cuda/include" \
--extra-ldflags="-L/usr/local/cuda/lib64" \
--enable-libmfx \
--enable-vaapi \
--enable-opencl \
--disable-debug \
--enable-libvorbis \
--enable-libvpx \
--enable-libdrm \
--enable-gpl \
--enable-runtime-cpudetect \
--enable-libfdk-aac \
--enable-libx264 \
--enable-libx265 \
--enable-openssl \
--enable-pic \
--extra-libs="-lpthread -lm -lz -ldl" \
--enable-cuda \
--enable-cuvid \
--enable-nvenc \
--enable-libnpp \
--enable-nonfree
PATH="$HOME/FFMPEG/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
hash -r
install nvidia-driver: https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu
How to test:
ffmpeg -i USVA6833.MP4 -c:v libx264 -global_quality 25 libx264.mp4
ffmpeg -i USVA6833.MP4 -c:v libx265 -global_quality 25 libx265.mp4
ffmpeg -i USVA6833.MP4 -c:v h264_qsv -global_quality 25 h264_qsv.mp4
ffmpeg -i USVA6833.MP4 -c:v hevc_qsv -global_quality 25 hevc_qsv.mp4
ffmpeg -i USVA6833.MP4 -c:v h264_nvenc -global_quality 25 h264_nvenc.mp4
ffmpeg -i USVA6833.MP4 -c:v hevc_nvenc -global_quality 25 hevc_nvenc.mp4
Server:
cd ./ffmpeg-3.4.6
export PATH="$HOME/FFMPEG/bin:$PATH"
export PKG_CONFIG_PATH="$HOME/FFMPEG/ffmpeg_build/lib/pkgconfig:/opt/intel/mediasdk/lib/pkgconfig"
./configure --prefix="$HOME/FFMPEG/ffmpeg_build" \
--bindir="$HOME/FFMPEG/bin" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/FFMPEG/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/FFMPEG/ffmpeg_build/lib" \
--extra-cflags="-I/opt/intel/mediasdk/include" \
--extra-ldflags="-L/opt/intel/mediasdk/lib" \
--extra-ldflags="-L/opt/intel/mediasdk/plugins" \
--extra-libs="-lpthread -lm -lz -ldl" \
--enable-libmfx \
--enable-vaapi \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-runtime-cpudetect \
--enable-libdrm \
--enable-pic \
--enable-shared \
--enable-nonfree
make
make install
hash -r
Client:
PATH="$HOME/FFMPEG/bin:$PATH" PKG_CONFIG_PATH="$HOME/FFMPEG/ffmpeg_build/lib/pkgconfig" ./configure \
--pkg-config-flags="--static" \
--prefix="$HOME/FFMPEG/ffmpeg_build" \
--bindir="$HOME/FFMPEG/bin" \
--extra-cflags="-I$HOME/FFMPEG/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/FFMPEG/ffmpeg_build/lib" \
--enable-libdrm \
--enable-gpl \
--enable-runtime-cpudetect \
--enable-libx264 \
--enable-libx265 \
--enable-pic \
--extra-libs="-lpthread -lm -lz -ldl" \
--enable-shared \
--enable-nonfree
PATH="$HOME/FFMPEG/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
hash -r
Server:
export PATH="$HOME/FFMPEG/bin:$PATH:/usr/local/cuda/bin"
export PKG_CONFIG_PATH="$HOME/FFMPEG/ffmpeg_build/lib/pkgconfig:/opt/intel/mediasdk/lib/pkgconfig"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:$HOME/FFMPEG/ffmpeg_build/lib:/opt/VES/lib64"
Client
export PATH="$HOME/FFMPEG/bin:$PATH"
export PKG_CONFIG_PATH="$HOME/FFMPEG/ffmpeg_build/lib/pkgconfig"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/FFMPEG/ffmpeg_build/lib:/opt/VES/lib64"
Thanks to this link: https://gist.github.com/Brainiarc7/4f831867f8e55d35cbcb527e15f9f116 https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
Build FFmpeg with QSV support: Build platform: Ubuntu 18.04LTS. Ubuntu 16.04LTS is not recommended for some third-party tools' version mismatch. But it's not a big problem.
Ensure the platform is up to date:
sudo apt update && sudo apt -y upgrade && sudo apt -y dist-upgrade
Install baseline dependencies first (inclusive of OpenCL headers+)
sudo apt-get -y install autoconf automake build-essential libass-dev libtool pkg-config texinfo zlib1g-dev libva-dev cmake mercurial libdrm-dev libvorbis-dev libogg-dev git libx11-dev libperl-dev libpciaccess-dev libpciaccess0 xorg-dev intel-gpu-tools opencl-headers libwayland-dev xutils-dev ocl-icd-* libssl-dev libnuma-dev
Then add the Oibaf PPA, needed to install the latest development headers for libva:
Build the latest libva and all drivers from source: Setup build environment:
Build the dependency chain as shown, starting with installing the latest build of libdrm. This is needed to enable the cl_intel_va_api_media_sharing extension, needed when deriving OpenCL device initialization interop in FFmpeg, as illustrated later on in the documentation:
if if doesn't work, you can also use
sudo apt install libdrm
. (1)Libva Libva is an implementation for VA-API (Video Acceleration API)VA-API is an open-source library and API specification, which provides access to graphics hardware acceleration capabilities for video processing. It consists of a main library and driver-specific acceleration backends for each supported hardware vendor. It is a prerequisite for building the VAAPI driver components below.
(2) Gmmlib: The Intel(R) Graphics Memory Management Library provides device specific and buffer management for the Intel(R) Graphics Compute Runtime for OpenCL(TM) and the Intel(R) Media Driver for VAAPI.
The component is a prerequisite to the Intel Media driver build step below.
To build this, create a workspace directory within the vaapi sub directory and run the build:
(3) Intel Media driver: The Intel(R) Media Driver for VAAPI is a new VA-API (Video Acceleration API) user mode driver supporting hardware accelerated decoding, encoding, and video post processing for GEN based graphics hardware, released under the MIT license.
Configure the project with cmake:
Then build the media driver:
time make -j$(nproc) VERBOSE=1
Then install the project:sudo make -j$(nproc) install VERBOSE=1
Add yourself to the video group:sudo usermod -a -G video $USER
Now, export environment variables as shown below:Put that in /etc/environment.
(4) Before you proceed with the iMSDK: It is recommended that you install the Intel Neo OpenCL runtime: Justification: This will allow for Intel's MediaSDK OpenCL inter-op back-end to be built. Note: There's also a Personal Package Archive (PPA) for this that you can add, allowing you to skip the manual build step, as shown:
Then install the packages:
sudo apt install intel-*
Here, you will find some packages can't be installed:
The main reason is that Neo packages and dependencies on launchpad were renamed, so please use:
sudo apt-get install intel-opencl-icd
Install the dependencies for the OpenCL back-end:
Build dependencies:
sudo apt-get install ccache flex bison cmake g++ git patch zlib1g-dev autoconf xutils-dev libtool pkg-config libpciaccess-dev libz-dev clinfo
Testing: Use
clinfo
and confirm that the ICD is detected.Optionally, run Luxmark and confirm that Intel Neo's OpenCL platform is detected and usable.
Be aware that Luxmark, among others, require freeglut, which you can install by running:
sudo apt install freeglut3*
CMake will automatically detect the platform you're on and enable the platform-specific hooks needed for a working build.
Create a library config file for the iMSDK:
sudo nano /etc/ld.so.conf.d/imsdk.conf
Content:
Then run:
--enable-gpl --enable-libx264
.(2) Build and configure libx265: This library provides a H.265/HEVC video encoder. See the H.265 Encoding Guide for more information and usage examples.
(3)Build and deploy the libfdk-aac library: This provides an AAC audio encoder. See the AAC Audio Encoding Guide for more information and usage examples. This requires ffmpeg to be configured with --enable-libfdk-aac (and --enable-nonfree if you also included --enable-gpl).
(4) Build and configure libvpx:
(5) Build LibVorbis:
(6)
sudo apt-get -y install libnuma-dev libmp3lame-dev libopus-dev
Then, build:
testing QSV: https://trac.ffmpeg.org/wiki/Hardware/QuickSync
Now, QSV should work. Next, we will try to set the building environment for NVENC. Follow the steps here: https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/
Download and install a compatible driver from the NVIDIA web site Download and install the CUDA toolkit Clone the
nv-codec-headers
repository and install using this repository as header-only:make install
Configure FFmpeg using the following command (use correct CUDA library path):./configure --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64