Location>code7788 >text

Windows 10 using MSYS2 and VS2019 compilation FFmpeg details

Popularity:642 ℃/2024-08-30 19:50:42

1 Environmental preparation

1.1 Installing Visual Studio 2019

This step is relatively simple and will not be explained in detail.

1.2 Installing msys2

First you need to install the msys2 environment and related compilation dependencies, the official URL is:

https:///

After downloading the installation program from the official website, follow the instructions directly to install it.

After installation, you need to replace the address of the download library with a domestic source, otherwise the download speed may be extremely slow or even fail. Configuration file is located in: C:\msys64\etc\, respectively, mirrorlist.mingw32, mirrorlist.mingw64, three configuration files of the preferred Server address, replace the Tsinghua University and the Chinese University of Science and Technology mirror!

# See https:///dev/mirrors

## Primary
## Tsinghua University
Server= https:///msys2/mingw/i686/
## CSU
Server= https:///msys2/mingw/i686/

Server = https://mirror./mingw/i686/
Server = https://repo./mingw/i686/

## Tier 1
Server = https:///msys2/mingw/i686/
Server = https:///mirrors/msys2/mingw/i686/
Server = https:///mirror/msys2/mingw/i686/
Server = https:///mirror//mingw/i686/
Server = https:///pub/os/windows/msys2/builds/mingw/i686/
Server = https:///pub/msys2/mingw/i686/
Server = https:///pub/msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///mirrors/pub/msys2/mingw/i686/
Server = https:///MSYS2/mingw/i686/
Server = https:///msys2/mingw/i686/

## Tier 2
Server = https:///mirrors/msys2/mingw/i686/
Server = https:///pub/msys2/mingw/i686/
Server = https:///msys2-mirror/mingw/i686/
Server = https:///~nickoe/msys2-mirror/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
Server = https:///msys2/mingw/i686/
mirrorlist.mingw32
# See https:///dev/mirrors

## Primary
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https://mirror./mingw/x86_64/
Server = https://repo./mingw/x86_64/

## Tier 1
Server = https:///msys2/mingw/x86_64/
Server = https:///mirrors/msys2/mingw/x86_64/
Server = https:///mirror/msys2/mingw/x86_64/
Server = https:///mirror//mingw/x86_64/
Server = https:///pub/os/windows/msys2/builds/mingw/x86_64/
Server = https:///pub/msys2/mingw/x86_64/
Server = https:///pub/msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///mirrors/pub/msys2/mingw/x86_64/
Server = https:///MSYS2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/

## Tier 2
Server = https:///mirrors/msys2/mingw/x86_64/
Server = https:///pub/msys2/mingw/x86_64/
Server = https:///msys2-mirror/mingw/x86_64/
Server = https:///~nickoe/msys2-mirror/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
Server = https:///msys2/mingw/x86_64/
mirrorlist.mingw64
# See https:///dev/mirrors

## Primary
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https://mirror./msys/$arch/
Server = https://repo./msys/$arch/

## Tier 1
Server = https:///msys2/msys/$arch/
Server = https:///mirrors/msys2/msys/$arch/
Server = https:///mirror/msys2/msys/$arch/
Server = https:///mirror//msys/$arch/
Server = https:///pub/os/windows/msys2/builds/msys/$arch/
Server = https:///pub/msys2/msys/$arch/
Server = https:///pub/msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///mirrors/pub/msys2/msys/$arch/
Server = https:///MSYS2/msys/$arch/
Server = https:///msys2/msys/$arch/

## Tier 2
Server = https:///mirrors/msys2/msys/$arch/
Server = https:///pub/msys2/msys/$arch/
Server = https:///msys2-mirror/msys/$arch/
Server = https:///~nickoe/msys2-mirror/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/
Server = https:///msys2/msys/$arch/

Run C:\msys64\ and install and upgrade all libraries with one click via pacman -Syu at the command line.

During the compilation process, you may encounter some other libraries are missing, just follow the instructions to install them. For example, you may need to install the following libraries:

pacman -S make cmake#Regular compilation tools
pacman-S yasm #assembly tools
pacman-S nasm #assembly tools
pacman-S pkg-config#Library configuration tool, compiled to support x264 and x265 will use the
pacman-S mingw-w64-x86_64-gcc#Compilation Tools
pacman -S diffutils #Comparison tools,ffmpeg configure generatingmakefilewhen using
pacman -S git  #Source code download tool

1.3 Configuring the VC environment

First of all, in order to make msys2 access the windows PATH environment variable, you need to find the script file msys2_shell.cmd in the msys2 installation directory, use any editor to open it, and change rem set MSYS2_PATH_TYPE=inherit to set MSYS2_PATH_TYPE= inherit, i.e. remove the rem comment inherit system environment variables.

Next, find Visual Studio 2019 in the windows start menu, right-click on "x64_x86 Cross Tools Command Prompt For VS 2019" and choose to run as administrator (it's better to run with administrator privileges, or else subsequent problems may occur when the (It is better to run with administrator privileges, otherwise the make install command may not have enough privileges, remember).

Regarding the selection of several options

If you have 32-bit Windows and want to compile 32-bit FFmpeg, it is recommended to choose:x86 Native Tools Command Prompt;

If you have 64-bit Windows and want to compile 64-bit FFmpeg, it is recommended to choose:x64 Native Tools Command Prompt

If you are on 32-bit Windows and want to compile 64-bit FFmpeg, it is recommended to choose:x86_x64 Cross Tools Command Prompt

Recommended if you have 64-bit Windows and want to compile 32-bit FFmpeg:x64_x86 Cross Tools Command Prompt

See the Microsoft website for details:Use the Microsoft C++ toolset from the command line

My OS is Win10 64-bit and it's 32-bit FFmpeg that needs to be compiled, so that's the choice:x64_x86 Cross Tools Command Prompt For VS 2019

Then, cd to C:\msys64 and run msys2_shell.cmd in 32-bit mode (msys2_shell.cmd -mingw64 will run msys2 in 64-bit mode) to enable the MinGW runtime environment. At this time, type cl in the popped-up msys2 command window, and the output of the MSVC message, then it means that the compiler configuration is successful. The compiler has been successfully configured.

Type which cl and which link in the msys window to see the current compiler and linker locations, respectively:

You can see that the location of the cl compiler is correct, the link linker is incorrect, this is because the linker found for the default MSYS linker, MSYS default also carries a linker named (in the :msys installation directory /usr/bin/), which conflicts with Visual Studio's own, which affects the build system after the construction of the build (in my compilation process is because I ignored this problem, resulting in an unusually slow compilation process and the generation of dll files can not be used). This will affect the build of the build system (I ignored this problem during my build, resulting in an unusually slow build and unusable dll files), so we must make sure that Visual Studio comes with it. Find the one that comes with MSYS, rename it to something else, for example I renamed it link.exe_back. type which link again:

You can see that it has been for the Visual Studio directory.

2 FFMPEG compilation

2.1 Source Code Download

The source code can be used by the/FFmpeg/FFmpeg/tagsmaybeFFmpeg official websiteDownload, e.g. I downloaded the latest version 4.3.

2.2 Compiling dependent libraries

2.2.1 Compiling SDL

First get the SDL source code from github with the following command:

git clone https:///libsdl-org/
cd SDL
git checkout release-2.30.0

Note that SDL has now released version 3.0, and ffmpeg is currently only available in SDL2, so after pulling the code, you need to switch to version 2.30.0.

After downloading the SDL2 source code, we need to generate a VS project for it using CMake, so let's first go hereDownload CMakeAfter that, open CMake-GUI, and execute Configure, and then configure the following. After that, open CMake-GUI, specify the path where the SDL2 source code is located and the output path after compilation in CMake-GUI, and then execute Configure, and then configure as follows

Then keep the default configuration and Generate VS2019 project.

With VS project, you can compile SDL by VS2019. The compiled SDL will be saved to the Release or Debug directory of the specified output directory, while the path we want to output is /usr/local/sdl2/lib, we need to create the lib directory under the specified output directory, and copy and files to the lib directory. Also create a pkgconfig directory in the lib directory and copy the files to it. In addition, we also need to modify the contents of the lib directory to change the library path to the specified output path, so that the complete directory structure is as follows:

2.2.2 Compiling x264

Like SDL we have to get its source code first, you can get the x264 source code by the following command:

git clone https:///videolan/

Once the source code is obtained, you can compile the dynamic libraries available under Windows directly in the MSYS2 environment as follows:

cd x264                             # existMSYS2hit the targetx264source code directory
pacman -S automake autoconf libtool # Install tools for generating Makefiles CC=cl ./configure --prefix=/usr/local/x264 --enable-shared make -j 4 && make install

With the above command, you can compile x264. x264 compiled, its output directory structure is the same as SDL2, in /usr/local/x264 includes include, lib, bin and other directories. One point to emphasize is that we need to change the filenames in the lib directory, otherwise ffmpeg will report "Cannot find the library" error when compiling.

2.2.3 Compiling fdk-aac

The compilation of fdk-aac is similar to that of SDL, it also uses CMake to generate VS project file, and then compiles the library through VS. First, pass the following command to get the fdk-aac source code:

git clone https:///mstorsjo/

After that, generate the VS project file through CMake, please refer to the steps of SDL to generate VS project for the specific execution steps, which will not be repeated here.
Next, use VS2019 to compile fdk-aac, the compiled library will be put into the Release or Debug directory, so we have to manually organize the output directory tree of fdk-aac as we did with the SDL library. At this point, fdk-aac is compiled.

There is a special case when compiling fdk-aac, that is, I can't generate include header file by using CMake (it is also possible that I didn't execute any piece correctly). In order to solve this problem, I used MSYS2+mingw to recompile fdk-aac, which can generate include header files, and then manually copy the generated header files to the /usr/local/fdk-aac directory.

./
./configure --prefix=/c/work/Opensource/ffmpegbuild/fdk-aac/migwbuild
make
make install

2.2.4 Compiling x265

First download the x265 source code

git clone https:///videolan/

Query VS2019 cmake path Query VS2019 cmake path, execute whereis cmake

Edit the file /c/work/Opensource/ffmpegbuild/x265/build/msys-cl/, change the path in it to the absolute path of the VC version, otherwise it will use the cmake in the default msys2, which is about to:

cmake -G "NMake Makefiles" -DCMAKE_CXX_FLAGS="-DWIN32 -D_WINDOWS -W4 -GR -EHsc" -DCMAKE_C_FLAGS="-DWIN32 -D_WINDOWS -W4"  ../../source

Modified to:

/c/"Program Files (x86)/Microsoft Visual Studio/2019"/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake -G "NMake Makefiles" -DCMAKE_CXX_FLAGS="-DWIN32 -D_WINDOWS -W4 -GR -EHsc" -DCMAKE_C_FLAGS="-DWIN32 -D_WINDOWS -W4"  ../../source

Go to the source directory and execute the following 3 commands to complete the compilation

cd /home/source/x265/build/msys-cl/
./make-
nmake install

After executing nmake install, we can see that x265 is compiled to C:/Program Files (x86)/x265/ directory, we need to copy it to /usr/local/ directory of msys2, and change the paths in the corresponding files.

2.2.5 ffmpeg using compiled libraries

First of all, we have to set the environment variable PKG_CONFIG_PATH, through which we tell FFmpeg where the above libraries can be found, the specific settings are as follows:

Run the command pacman -S vim in the msys2 window to install vim, vim ~/.bashrc to edit the file, and set environment variables in ~/.bashrc

export PKG_CONFIG_PATH=/usr/local/sdl2/lib/pkgconfig:/usr/local/x264/lib/pkgconfig:/usr/local/fdk-aac/lib/pkgconfig:/usr/local/x265/lib/pkgconfig:$PKG_CONFIG_PATH

Then execute the command source ~/.bashrc to let the environment variables take effect. The contents of the four library pkgconfig configuration files are as follows:

# sdl pkg-config source file

prefix=/usr/local/sdl2
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: sdl2
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
Version: 2.30.0
Requires.private: 
Conflicts:
Libs: -L${libdir}   -lSDL2 
Libs.private:  -lSDL2-static  -lkernel32 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid -ladvapi32 -lsetupapi -lshell32 -ldinput8
Cflags: -I${includedir} -I${includedir}/SDL2 
prefix=/usr/local/x264
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: x264
Description: H.264 (MPEG4 AVC) encoder library
Version: 0.164.3191
Libs: -L${exec_prefix}/lib -llibx264 
Libs.private: 
Cflags: -I${prefix}/include -DX264_API_IMPORTS
prefix=/usr/local/fdk-aac
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Fraunhofer FDK AAC Codec Library
Description: AAC codec library
Version: 2.0.3
Libs: -L${libdir} -lfdk-aac 
Libs.private: -lm 
Cflags: -I${includedir}
prefix=/usr/local/x265
exec_prefix=${prefix}/bin
libdir=${prefix}/lib
includedir=${prefix}/include

Name: x265
Description: H.265/HEVC video encoder
Version: 3.4
Libs: -L${libdir} -llibx265
Libs.private: 
Cflags: -I${includedir}

2.3 Compiling ffmpeg

Go to the ffmpeg source decompression directory and execute . /configure --help to see all supported compilation parameters:

As you can see, there are many compilation parameters supported natively, we only focus on the following parts here, and the cropping function can be completed by configuring the following parameters.

Individual component options:
--disable-everything Disable all components below
--disable-encoder=NAME Disable the specified encoder
--enable-encoder=NAME Enable the specified encoder
--disable-encoders Disable all encoders
--disable-decoder=NAME Disable the specified decoder
--enable-decoder=NAME Enable the specified decoder
--disable-decoders Disable all decoders
--disable-hwaccel=NAME Disable hardware acceleration (hardware decoding)
--enable-hwaccel=NAME Enable Hardware Acceleration
--disable-hwaccels Disable all hardware acceleration
--disable-muxer=NAME Disable the specified wrapper
--enable-muxer=NAME Enable the specified wrapper
--disable-muxers Disable all wrappers
--disable-demuxer=NAME Disable the specified unwrapper
--enable-demuxer=NAME Enable the specified wrapper
--disable-demuxers Disable all demuxers
--enable-parser=NAME Enable the specified parser
--disable-parser=NAME Disable the specified parser
--disable-parsers Disable all parsers
--enable-bsf=NAME Enables the specified bitstream filter.
--disable-bsf=NAME Disable the specified bitstream filters
--disable-bsfs disable all bitstream filters
--enable-protocol=NAME   Enable the specified protocol(The protocol here isTCP/UDP/FILE)
--disable-protocol=NAME Disable the specified protocol
--disable-protocols Disable all protocols
--enable-indev=NAME Enable the specified input device
--disable-indev=NAME Disable the specified input device
--disable-indevs Disable all input devices
--enable-outdev=NAME Enable the specified output device
--disable-outdev=NAME Disable the specified output device
--disable-outdevs Disable all output devices
--disable-devices Disable all devices
--enable-filter=NAME Enable the specified filter
--disable-filter=NAME Disable the specified filter
--disable-filters        Disable all filters

A brief description of a few of the options above:

  • encoder: Corresponding to the encoder, such as the need to convert mp3 format to aac format, after the conversion will inevitably use the aac format encoder;
  • decoder: The counterpart is the decoder, same as above, if you want to convert to aac format, you have to decode the mp3 format first, which will use the mp3 format decoder.
  • muxer: The counterpart is the wrapper, which is mainly used to generate the final wrapper format. Different audio and video formats have their own fixed file content format, which is convenient for the player to recognize and parse them.
  • demuxer: The counterpart is the unwrapper, for example, an MP4 wrapper format can hold both H264 encoded video and AAC encoded audio, if you want to take out the audio in it, you need to find the stream where the audio is located according to certain rules.
  • protocol: file protocol, FFmpeg not only supports reading and writing of local audio and video files, but also supports reading and writing of network streaming media, for example, if you want to watch a network TV locally, then you can pass the http/rtsp/rtmp address of this network TV in FFmpeg, so that you can realize local playback.
  • parser: Parses and populates internal data structures, e.g. AVCodecParser, which is usually used in conjunction with a decoder.

Here is a list of some common compilation options, for a complete list of compilation options, please refer to: Appendix I: "Summary of FFmpeg Compilation Parameters".

I use the following compilation options when compiling:

./configure --prefix=./buildout --toolchain=msvc --disable-doc --enable-shared --enable-libx264 --enable-gpl --enable-libfdk-aac --enable-nonfree --enable-libx265 --enable-ffplay  --disable-debug

The last option --disable-debug -- was added because without it, the compiler would get stuck generating libraries with the message "Creating library libavcodec/ and object libavcodec/".writingsAlso encountered this problem, but Microsoft official also did not give a solution, it is not clear whether it is only in a specific version of VS2019 (I am the community version) to reproduce the problem, so temporarily add --disable-debug cancel debugging information generation.

After that, execute the make command to compile. During compilation, if the following error occurs [error C2065: "slib": undeclared identifier]:

Then you need to modify the fftools/source file by commenting out line 1153, which is caused by the undefined CC_IDENT logo, as shown below:

If you encounter similar compilation errors during the subsequent compilation process, please handle them in the same way. After the compilation is complete, execute make install, which will install the executable program, libraries, header files, etc. to the specified directory.

So far the compilation is complete, followed by the direct installation of ffmpeg through the vcpkg method and a simple ffmpeg-based player example.

Appendix I: Summary of FFmpeg Compilation Parameters

1.1 Help options

parameters parameter effects
–help Print Display Help
–quiet Disable display message output
–list-decoders Show all available decoders
–list-encoders Show all available encoders
–list-hwaccels Show all available hardware gas pedals
–list-demuxers Show all available demultiplexers
–list-muxers Show all available multiplexers
–list-parsers Show all available parsers
–list-protocols Show all available protocols
–list-bsfs Show all available bitstream filters
–list-indevs Show all available input devices
–list-outdevs Show all available output devices
–list-filters Show all available filters

1.2 Standard options

parameters parameter effects
–logfile=FILE Records tests and outputs them to the specified file FILE, which defaults to ffbuild/.
–disable-logging Configuration debugging information is not logged
–fatal-warnings Fails if any configuration warnings are generated
–prefix=PREFIX Installed in the specified path PREFIX, default is /usr/local
–bindir=DIR Install the binary in the specified path DIR, default is PREFIX/bin.
–datadir=DIR Install the data files in the specified path DIR, default is PREFIX/share/ffmpeg
–docdir=DIR Install the documentation in the specified path DIR, default is PREFIX/share/doc/ffmpeg.
–libdir=DIR Install the library at the specified path, default is PREFIX/lib.
–shlibdir=DIR Install the shared libraries in the specified path, the default is LIBDIR, i.e. PREFIX/lib.
–incdir=DIR Install the include file in the specified path, the default is PREFIX/include.
–mandir=DIR Install the manual page in the specified path, the default is PREFIX/share/man.
–pkgconfigdir=DIR Install the pkg-config file in the specified path, the default is LIBDIR/pkgconfig.
–enable-rpath Using rpath allows rpath to be used when installing library linkers in paths that are not part of the dynamic linker's search path (use with care)
–install-name-dir=DIR Directory name of the target where Darwin is installed

1.3 Licensing options

parameters parameter effects
–enable-gpl GPL code is allowed, compiled libraries and binaries are under GPL license, default is no
–enable-version3 Upgrade (L) GPL to version 3, default is no
–enable-nonfree Non-free code is allowed and binaries will not be redistributed, default is no

1.4 Configuration options Configuration options

parameters parameter effects
–disable-static Do not build static libraries, default is no
–enable-shared Build shared dynamic libraries, default is no
–enable-small Optimize for size, not speed
–disable-runtime-cpudetect Disable CPU detection at runtime (smaller binaries)
–enable-gray Enable full grayscale support (slower colors)
–disable-swscale-alpha Disable alpha channel support in swscale
–disable-all Disabling build components, libraries and programs
–disable-autodetect Disable automatically detected external libraries, default is no

1.5 Program options

parameters parameter role
–disable-programs Not building command-line programs
–disable-ffmpeg Disable ffmpeg build
–disable-ffplay Disable ffplay build
–disable-ffprobe Disable ffprobe build

1.6 Documentation options

parameters parameter effects
–disable-doc Not building documentation
–disable-htmlpages Do not build HTML document pages
–disable-manpages Do not build manual documentation pages
–disable-podpages Not building POD documentation pages
–disable-txtpages Not building text document pages

1.7 Component options Component options

parameters parameter effects
–disable-avdevice Disable libavdevice builds
–disable-avcodec Disable libavcodec build
–disable-avformat Disable libavformat build
–disable-swresample Disabling the libswresample build
–disable-swscale Disable libswscale builds
–disable-postproc Disable libpostproc builds
–disable-avfilter Disable libavfilter build
–enable-avresample Enable libavresample builds (deprecated), default is no
–disable-pthreads Disable pthreads [auto-detect].
–disable-w32threads Disable Win32 Threads [Auto Detect]
–disable-os2threads Disable OS/2 threads [auto-detection]
–disable-network Disable network support , default is no
–disable-dct Disabling DCT Codes
–disable-dwt Disabling DWT Codes
–disable-error-resilience Disable error recovery code
–disable-lsp Disabling LSP Codes
–disable-lzo Disabling LZO Decoder Codes
–disable-mdct Disabling MDCT Codes
–disable-rdft Disabling RDFT Code
–disable-fft Disabling FFT Codes
–disable-faan Disable Floating Point AAN (I)DCT Code
–disable-pixelutils Disabling pixel tools in libavutil

1.8 Individual component options Standalone Component Options

parameters parameter effects
–disable-everything Disable all components listed below
–disable-encoder=NAME Disable the encoder for the specified NAME
–enable-encoder=NAME Enable the encoder for the specified NAME
–disable-encoders Disable all encoders
–disable-decoder=NAME Disable the decoder for the specified NAME
–enable-decoder=NAME Enable the decoder for the specified NAME
–disable-decoders Disable all decoders
–disable-hwaccel=NAME Disable hardware with the specified NAME
–enable-hwaccel=NAME Enable the hardware for the specified NAME
–disable-hwaccels Disable all hwaccels
–disable-muxer=NAME Disable the multiplexer for the specified NAME
–enable-muxer=NAME Enable the multiplexer for the specified NAME
–disable-muxers Disable all multiplexers
–disable-demuxer=NAME Disables the demultiplexer for the specified NAME
–enable-demuxer=NAME Enable demultiplexer for the specified NAME
–disable-demuxers Disable all demultiplexers
–enable-parser=NAME Enable parser for specified NAME
–disable-parser=NAME Disable the parser for a given NAME
–disable-parsers Disable all parsers
–enable-bsf=NAME Enable the bitstream filter for the specified NAME
–disable-bsf=NAME Disable the bitstream filter for the specified NAME
–disable-bsfs Disable all bitstream filters
–enable-protocol=NAME Enable Specified NAME Protocol
–disable-protocol=NAME Disable the specified NAME protocol
–disable-protocols Disable all protocols
–enable-indev=NAME Enable the input device with the specified NAME
–disable-indev=NAME Disable the input device with the specified NAME
–disable-indevs Disable input devices
–enable-outdev=NAME Enable the output device with the specified NAME
–disable-outdev=NAME Disable the output device with the specified NAME
–disable-outdevs Disable output devices
–disable-devices Disable all devices
–enable-filter=NAME Enable the filter name for the specified NAME
–disable-filter=NAME Disable the filter name for the specified NAME
–disable-filters Disable all filters

1.9 External library support Extended Library Support

Using any of the following options will allow FFmpeg to link to the corresponding external library. If all other dependencies are met and they are not explicitly disabled, all components that depend on the library will be enabled. For example. --enable-libopus will enable linking to libopus and allow the libopus encoder to be built, unless it is explicitly disabled with --disable-encoder=libopus.

Please note that only system libraries are automatically detected. All other external libraries must be explicitly enabled.

Also note that the following help text describes the use of the libraries themselves, not all of their features must be used by FFmpeg.

parameters parameter effects
–disable-alsa Disable ALSA Support [Auto Detect]
–disable-appkit Disable Apple AppKit framework [auto-detection]
–disable-avfoundation Disable Apple AVFoundation framework [auto-detection]
–enable-avisynth Enable reading AviSynth script files [No]
–disable-bzlib Disable bzlib [auto-detect].
–disable-coreimage Disable Apple CoreImage framework [auto-detection]
–enable-chromaprint Enable audio fingerprinting with chromaprint, default is no
–enable-frei0r Enable frei0r video filtering , default is no
–enable-gcrypt Enable gcrypt, requires rtmp(t)e support, defaults to no if not using openssl, librtmp or gmp
–enable-gmp Enable gmp, requires rtmp(t)e support, defaults to no if not using openssl or librtmp
–enable-gnutls Enable gnutls, requires https support, defaults to no if openssl, libtls or mbedtls is not used
–disable-iconv Disable iconv [auto-detect].
–enable-jni Enable JNI support, default is no
–enable-ladspa Enable LADSPA audio filtering, default is no
–enable-libaom Enable AV1 video encoding/decoding via libaom, default is no
–enable-libaribb24 Enable ARIB text and subtitle decoding via libaribb24, default is no
–enable-libass Enable libass subtitle rendering, need subtitles, default is no
–enable-libbluray Enable Blu-ray reading with libbluray, default is no
–enable-libbs2b Enable bs2b DSP library, default is no
–enable-libcaca Enable text display with libcaca, default is no
–enable-libcelt Enable CELT decoding via libcelt, default is no
–enable-libcdio Enables the use of libcdio to rip audio CDs.
–enable-libcodec2 Enable codec2 encoding/decoding with libcodec2, default is no
–enable-libdav1d Enable AV1 decoding via libdav1d, default is no
–enable-libdavs2 Enable AVS2 decoding via libdavs2, default is no
–enable-libdc1394 Enabling IIDC-1394 Grabbing with libdc1394 and libraw1394
–enable-libfdk-aac Enable AAC decoding/encoding via libfdk-aac, default is no
–enable-libflite Enable flite (speech synthesis) support via libflite, default is no
–enable-libfontconfig Enable libfontconfig, useful for drawtext filters, default is no
–enable-libfreetype Enable libfreetype, required for drawtext filters, default is no
–enable-libfribidi Enable libfribidi to improve drawtext filters, default is no
–enable-libglslang Enable GLSL->SPIRV compilation via libglslang, default is no
–enable-libgme Enable game music Emu via libgme, default is no
–enable-libgsm Enable GSM decoding/encoding via libgsm, default is no
–enable-libiec61883 Enable iec61883 via libiec61883, default is no
–enable-libilbc Enable iLBC decoding/encoding via libilbc, default is no
–enable-libjack Enable JACK Audio Sound Server, default is no
–enable-libklvanc Enable kernel lab VANC processing, default is no
–enable-libkvazaar Enable HEVC encoding via libkvazaar, default is no
–enable-liblensfun Enable lensfun lens correction, default is no
–enable-libmodplug Enable ModPlug via libmodplug, default is no
–enable-libmp3lame Enable MP3 encoding via libmp3lame, default is no
–enable-libopencore-amrnb Enable AMR-NB decoding/encoding via libopencore-amrnb, default is no
–enable-libopencore-amrwb Enable AMR-WB decoding via libopencore-amrwb, default is no
–enable-libopencv Enable video filtering via libopencv, default is no
–enable-libopenh264 Enable H.264 encoding via OpenH264, default is no
–enable-libopenjpeg Enable JPEG 2000 decoding/encoding via OpenJPEG, default is no
–enable-libopenmpt Enable decoding of tracked files via libopenmpt, default is no
–enable-libopenvino Enable OpenVINO as DNN module backend, default is no
–enable-libopus Enable Opus decoding/encoding via libopus, default is no
–enable-libpulse Enable Pulseaudio input via libpulse, default is no
–enable-librabbitmq Enable the RabbitMQ library, default is no
–enable-librav1e Enable AV1 encoding via rav1e, default is no
–enable-librist Enable RIST via librist, default is no
–enable-librsvg Enable SVG rasterization via librsvg, default is no
–enable-librubberband Enable the rubber band required for the rubber band filter, default is no
–enable-librtmp Enable RTMP[E] support via librtmp, default is no
–enable-libshine Enable fixed-point MP3 encoding via libshine, default is no
–enable-libsmbclient Enable Samba protocol via libsmbclient, default is no
–enable-libsnappy Enable Snappy compression, requires hap encoding, default is no
–enable-libsoxr Enable libsoxr resampling, default is no
–enable-libspeex Enable Speex decoding/encoding via libspeex, default is no
–enable-libsrt Enable Haivision SRT protocol via libsrt, default is no
–enable-libssh Enable SFTP protocol via libssh, default is no
–enable-libsvtav1 Enable AV1 encoding via SVT, default is no
–enable-libtensorflow Enable TensorFlow as DNN module backend for DNN-based filters, default is no
–enable-libtesseract Enable Tesseract, required for ocr filters, default is no
–enable-libtheora Enable Theora encoding via libtheora, default is no
–enable-libtls LibreSSL required to enable https support if openssl, gnutls or mbedtls are not used, default is no
–enable-libtwolame Enable MP2 encoding via libttwolame, default is no
–enable-libuavs3d Enable AVS3 decoding via libuavs3d, default is no
–enable-libv4l2 Enable libv4l2/v4l-utils, default is no
–enable-libvidstab Use Enable video stabilization, default is no
–enable-libvmaf Enable vmaf filter via libvmaf, default is no
–enable-libvo-amrwbenc Enable AMR-WB encoding via libvo-amrwbenc, default is no
–enable-libvorbis Enable Vorbis encoding/decoding via libvorbis, default is no
–enable-libvpx Enable VP8 and VP9 decoding/encoding via libvpx, default is no
–enable-libwebp Enable WebP encoding via libwebp, default is no
–enable-libx264 Enable H.264 encoding via x264, default is no
–enable-libx265 Enable HEVC encoding via x265, default is no
–enable-libxavs Enable AVS encoding via xavs, default is no
–enable-libxavs2 Enable AVS2 encoding via xavs2, default is no
–enable-libxcb Enabling X11 Grabbing with XCB [Auto Detection]
–enable-libxcb-shm Enable X11 to capture shm communication [auto-detect].
–enable-libxcb-xfixes Enable X11 Grab Mouse Rendering [Auto Detection]
–enable-libxcb-shape Enable X11 Grab Shape Rendering [Auto Detect]
–enable-libxvid Xvid encoding enabled via xvidcore, native MPEG-4/Xvid encoder present, default no
–enable-libxml2 Enable XML parsing with the C library libxml2, default is no
–enable-libzimg Enable , required for zscale filters, default is no
–enable-libzmq Enable passing messages through libzmq, default is no
–enable-libzvbi Enable Graphic TV support via libzvbi, default is no
–enable-lv2 Enable LV2 audio filtering, default is no
–disable-lzma Disable lzma [auto-detect].
–enable-decklink Enable Blackmagic DeckLink I/O support, default is no
–enable-mbedtls mbedTLS required to enable https support if openssl, gnutls, or libtls is not used, default is no
–enable-mediacodec Enable Android MediaCodec support, default is no
–enable-mediafoundation Enable encoding via MediaFoundation
–enable-libmysofa Enable libmysofa, soflizer filter required, default is no
–enable-openal Enable OpenAL 1.1 capture support, default is no
–enable-opencl Enable OpenCL processing, default is no
–enable-opengl Enable OpenGL rendering, default is no
–enable-openssl If gnutls, libtls, or mbedtls are not used, enable openssl as required for https support, default is no
–enable-pocketsphinx Enable PocketSphinx, required for asr filters, default is no
–disable-sndio Disable sndio support [auto-detect].
–disable-schannel Disable SChannel SSP, requires TLS support [auto-detect]
–disable-sdl2 Disable sdl2 [auto-detect].
–disable-securetransport Disable secure transport, requires TLS support
–enable-vapoursynth Enable VapourSynth demultiplexer, default is no
–enable-vulkan Enable Vulkan code, default is no
–disable-xlib Disable xlib [auto-detect].
–disable-zlib Disable zlib [auto-detect].

The following libraries provide various hardware acceleration features:

parameters parameter effects
–disable-amf Disable AMF video encoding code [auto-detect]
–disable-audiotoolbox Disable Apple AudioToolbox Code [Auto Detect]
–enable-cuda-nvcc Enable Nvidia CUDA compiler, default is no
–disable-cuda-llvm Use clang, disable CUDA compilation [auto-detect].
–disable-cuvid Disable Nvidia CUVID support [auto-detection]
–disable-d3d11va Disable Microsoft Direct3D 11 video acceleration code [auto-detect]
–disable-dxva2 Disable Microsoft DirectX 9 Video Acceleration Code [Auto-detect]
–disable-ffnvcodec Disabling dynamically linked Nvidia code [auto-detect]
–enable-libdrm Enable DRM code (Linux), default is no
–enable-libmfx Enable Intel MediaSDK (AKA Fast Sync Video) code via libmfx, default is no
–enable-libnpp Enable Nvidia Performance Primitives-based code, default is no
–enable-mmal Enable Broadcom Multimedia Abstraction Layer (Raspberry Pi) via MMAL, default is no
–disable-nvdec Disable Nvidia video decode acceleration (via hwaccel) [auto-detect]
–disable-nvenc Disable Nvidia video encoding code [auto-detect].
–enable-omx Enable OpenMAX IL code, default is no
–enable-omx-rpi Enable OpenMAX IL code for Raspberry Pi, default is no
–enable-rkmpp Enable Rexchip Media Processing Platform code , default is no
–disable-v4l2-m2m Disable V4L2 mem2mem code [auto-detect].
–disable-vaapi Disable video acceleration API (mostly Unix/Intel) code [auto-detection]
–disable-vdpau Disable Nvidia Video Decode and Presentation API for Unix code [auto-detection]
–disable-videotoolbox Disable VideoToolbox Code [Auto Detect]

1.10 Toolchain options Toolchain options

parameters parameter effects
–arch=ARCH Select Architecture
–cpu=CPU Select the minimum CPU required (affects instruction selection, may crash on older CPUs)
–cross-prefix=PREFIX Compilation tools use PREFIX
–progs-suffix=SUFFIX program name suffix
–enable-cross-compile Assuming a cross-compiler is used
–sysroot=PATH The root of the cross-built tree
–sysinclude=PATH Location of cross-build system header files
–target-os=OS Compiler Target OS
–target-exec=CMD Commands to run executables on the target
–target-path=DIR View the path to the build directory on the target
–target-samples=DIR Path to the target sample directory
–tempprefix=PATH Force fixed directory/prefix instead of mktemp for checking
–toolchain=NAME Setting tool defaults based on NAME
–nm=NM Using the nm utility NM [nm -g]
–ar=AR Use of archiving tools AR [ar]
–as=AS Using the Assembler AS
–ln_s=LN_S Using the Symbolic Linking Tool LN_S [ln -s -f]
–strip=STRIP Use of the stripping tool STRIP [strip]
–windres=WINDRES Using windows resource compiler WINDRES [windres]
–x86asmexe=EXE Use nasm-compatible assembler EXE [nasm].
–cc=CC Using the C compiler CC [gcc]
–cxx=CXX Using the C compiler CXX [g++].
–objcc=OCC Using the ObjC compiler OCC [gcc].
–dep-cc=DEPCC Using the Dependency Generator DEPCC [gcc]
–nvcc=NVCC Using the Nvidia CUDA compiler NVCC or clang
–ld=LD Using the Linker LD
–pkg-config=PKGCONFIG Using the pkg-config utility PKGCONFIG [pkg-config]
–pkg-config-flags=FLAGS Pass additional flags to pkgconf
–ranlib=RANLIB Using ranlib RANLIB
–doxygen=DOXYGEN Generating API docs with DOXYGEN [doxygen]
–host-cc=HOSTCC Using the Host C Compiler HOSTCC
–host-cflags=HCFLAGS Using HCFLAGS when compiling for hosts
–host-cppflags=HCPPFLAGS Using HCPPFLAGS when compiling for hosts
–host-ld=HOSTLD Using the Host Linker HOSTLD
–host-ldflags=HLDFLAGS Use HLDFLAGS when linking to a host.
–host-extralibs=HLIBS Use the library HLIBS when linking hosts
–host-os=OS Compiler Host Operating System
–extra-cflags=ECFLAGS Adding ECFLAGS to CFLAGS
–extra-cxxflags=ECFLAGS Adding ECFLAGS to CXXFLAGS
–extra-objcflags=FLAGS Adding FLAGS to OBJCFLAGS
–extra-ldflags=ELDFLAGS Add ELDFLAGS to LDFLAGS
–extra-ldexeflags=ELDFLAGS Adding ELDFLAGS to LDEXEFLAGS
–extra-ldsoflags=ELDFLAGS Add ELDFLAGS to LDSOFLAGS
–extra-libs=ELIBS Add ELIBS
–extra-version=STRING Version String Suffix
–optflags=OPTFLAGS Override optimization-related compiler flags
–nvccflags=NVCCFLAGS Override nvcc flags
–build-suffix=SUFFIX library name suffix
–enable-pic Building location-independent code
–enable-thumb Compiling the Thumb Instruction Set
–enable-l Optimization when using links
–env=“ENV=override” Override environment variables

1.11 Advanced options

parameters parameter effects
–malloc-prefix=PREFIX Prefix malloc and related names with PREFIX
–custom-allocator=NAME Using supported custom dispensers
–disable-symver Disable symbolic version control
–enable-hardcoded-tables Use hard-coded tables instead of runtime generation
–disable-safe-bitstream-reader Disable buffer boundary checking in bit reader (faster, but may crash)
–sws-max-filter-size=N swscale Maximum filter size to use , default 256

1.12 Optimization options Optimization Options

parameters parameter effects
–disable-asm Disable all assembly optimization
–disable-altivec Disable AltiVec Optimization
–disable-vsx Disable VSX Optimization
–disable-power8 Disable POWER8 Optimization
–disable-amd3dnow Disable 3DNow!
–disable-amd3dnowext Disable 3DNow!
–disable-mmx Disable MMX Optimization
–disable-mmxext Disable MMXEXT Optimization
–disable-sse Disabling SSE Optimization
–disable-sse2 Disable SSE2 optimization
–disable-sse3 Disable SSE3 Optimization
–disable-ssse3 Disable SSSE3 optimization
–disable-sse4 Disable SSE4 optimization
–disable-sse42 Disable SSE4.2 optimization
–disable-avx Disable AVX Optimization
–disable-xop Disable XOP Optimization
–disable-fma3 Disable FMA3 optimization
–disable-fma4 Disable FMA4 optimization
–disable-avx2 Disable AVX2 optimization
–disable-avx512 Disable AVX-512 optimization
–disable-aesni Disable AESNI optimization
–disable-armv5te Disable armv5te optimization
–disable-armv6 Disable armv6 optimization
–disable-armv6t2 Disable armv6t2 optimization
–disable-vfp Disable VFP Optimization
–disable-neon Disable NEON optimization
–disable-inline-asm Disable inline assembly
–disable-x86asm Disable standalone x86 assemblies
–disable-mipsdsp Disable MIPS DSP ASE R1 Optimization
–disable-mipsdspr2 Disable MIPS DSP ASE R2 Optimization
–disable-msa Disable MSA Optimization
–disable-msa2 Disable MSA2 optimization
–disable-mipsfpu Disable Floating Point MIPS Optimization
–disable-mmi Disable Longxin SIMD Optimization
–disable-fast-unaligned Consider unaligned access slow

1.13 Developer Options

parameters parameter role
–disable-debug Disable debugging symbols
–enable-debug=LEVEL Setting the debug level
–disable-optimizations Disable compiler optimization
–enable-extra-warnings Enable more compiler warnings
–disable-stripping Disable stripping executables and shared libraries
–assert-level=level 0 (default), 1 or 2, number of assertion tests, 2 causes the runtime to slow down
–enable-memory-poisoning Fill uninitialized allocation space of the heap with arbitrary data
–valgrind=VALGRIND Run "make fate" tests via valgrind to detect memory leaks and errors, using the specified valgrind binaries. Cannot be used in conjunction with --target-exec.
–enable-ftrapv trapdoor arithmetic overflow
–samples=FATE Path location of the test sample
–enable-neon-clobber-test Check for NEON register corruption (should be for debugging purposes only)
–enable-xmm-clobber-test Check for XMM register corruption (Win64 only; should be used for debugging purposes only)
–enable-random Randomly enable/disable components
–enable-random=LIST Randomly enable/disable specific components, LIST is a comma-separated list of NAME[:PROB] entries, where NAME is the probability name of a component (group) associated with a PROB (default 0.5).
–random-seed=VALUE Seed value for -enable/disable-random
–disable-valgrind-backtrace Backtracking is not printed under Valgrind (only for --disable-optimizations builds)
–enable-ossfuzz Enabling the build fuzzer tool
–libfuzzer=PATH Path to libfuzzer
–ignore-tests=TESTS Neglected Tests
–enable-linux-perf Enabling the Linux Performance Monitor API
–disable-large-tests Disable tests that use a lot of memory

Parts of this blog post are referenced in the following article, with thanks:

/yongdaimi/p/

/post/7076719206573539336