This page explains how to configure and build FFmpeg on Linux. This involves:
You can get the FFmpeg source code in these ways:
~/ffmpeg.
$ git clone --branch n7.1 https://git.ffmpeg.org/ffmpeg.git ffmpeg
It is recommended to use the same FFmpeg version as documented in the Qt Multimedia main page.
The following paragraphs assume that you store the FFmpeg source code under ~/ffmpeg.
To build FFmpeg, these tools and packages are required:
To install the required packages (including Yasm for FFmpeg), run:
$ apt-get install yasm
Additionally, if you're enabling a security backend, you need the corresponding developer package, for example:
$ apt-get install libssl-dev
For other backends, install the relevant packages:
libssl-dev.libgnutls-dev.libtls-dev.libmbedtls-dev.Create a build directory inside the ~/ffmpeg directory and navigate into it:
$ mkdir ~/ffmpeg/build $ cd ~/ffmpeg/build
To configure FFmpeg, run:
$ ../configure --prefix=/usr/local/ffmpeg --disable-doc --enable-network --enable-shared
The --prefix argument specifies a path where the FFmpeg development libraries are installed after building. The documentation is not needed, but network features should be enabled. To build FFmpeg
as static libraries, omit the --enable-shared option.
If you're building FFmpeg with a security backend, choose the appropriate option:
$ ../configure --enable-openssl # For OpenSSL $ ../configure --enable-gnutls # For GnuTLS $ ../configure --enable-libtls # For LibreSSL (libtls) $ ../configure --enable-mbedtls # For MbedTLS
Make sure you have the corresponding developer package installed as mentioned earlier.
By default, FFmpeg is built without hardware acceleration unless the appropriate packages are installed. For better performance, especially on systems with GPU support, it’s recommended to install VAAPI development packages:
$ apt-get install libva-dev
This will enable FFmpeg to detect VAAPI support during configuration.
If FFmpeg will be used with NVIDIA graphics cards, you should install the NVIDIA codec headers. These can be downloaded from the following repository: NVIDIA Codec Headers on GitHub.
To build and install the headers, run the following commands:
$ mkdir ~/nv-codec-headers $ cd ~/nv-codec-headers $ git clone https://github.com/FFmpeg/nv-codec-headers.git $ mkdir build $ cd build $ make -j install
Make sure to check the compatibility of the nv-codec-headers with your NVIDIA driver version, as newer nv-codec-headers may not be compatible with older driver
versions. Refer to the official documentation for more details.
By default, FFmpeg attempts to automatically detect available dependencies on the build system. This includes hardware acceleration and security backends. If you want to disable autodetection (for example, to avoid compiling unnecessary dependencies), you can use:
$ ../configure --disable-autodetect
If you are building FFmpeg with any additional dependencies (like a security backend or hardware acceleration), ensure that the required libraries are installed on the target system. There are several ways to handle this:
On Linux, FFmpeg uses both RPATH and RUNPATH metadata sections to manage library paths. We recommend using the patchelf utility to set the correct runpath:
$ patchelf --set-rpath "new/runpath" lib.so
By default, patchelf modifies the RUNPATH, as RPATH is considered obsolete on Linux. To set a relative runpath, you can use the $ORIGIN variable, which makes the path
relative to the location of the executable:
$ patchelf --set-rpath "$ORIGIN/../lib" lib.so
This approach ensures portability by linking libraries based on their relative locations.
Once you've configured FFmpeg with your desired options, you can build and install it:
$ make -j install
If the build completes without errors, FFmpeg development libraries will be installed in the /usr/local/ffmpeg directory. You can then reference this path when configuring Qt Multimedia by setting
the FFMPEG_DIR variable.