Common SVT-AV1 Compilation Flags for Building From Source
Building the Scalable Video Technology AV1 (SVT-AV1) encoder from source code allows developers and video engineers to optimize the binary for specific hardware and use cases. This article covers the most common CMake compilation flags used during the SVT-AV1 build process, explaining how to control build types, target specific CPU architectures, toggle component builds, and configure library types for optimal performance.
Standard CMake Build Flags
SVT-AV1 uses the CMake build system. The following standard CMake flags are crucial for defining the overall build environment:
-DCMAKE_BUILD_TYPE=Release: This is the most important flag for production builds. It enables high-level compiler optimizations (-O3) and disables debug symbols, ensuring the encoder runs at maximum speed. Other options includeDebugandRelWithDebInfo.-DBUILD_SHARED_LIBS=OFF: Controls whether to build SVT-AV1 as a shared library (.soor.dll) or a static library (.aor.lib). Setting this toOFFbuilds static libraries, which is preferred for creating portable, self-contained executables (like a static FFmpeg build). Set toONif you want shared libraries.
Component Selection Flags
SVT-AV1 consists of an encoder, a decoder, and sample applications. You can use flags to exclude components you do not need, reducing compilation time and binary size:
-DBUILD_ENC=ON: Enables building the encoder library (libSvtAv1Enc). This is enabled by default, but can be set toOFFif you only require the decoder.-DBUILD_DEC=ON: Enables building the decoder library (libSvtAv1Dec). If you only plan to encode video and use external decoders (like Dav1d), you can set this toOFF.-DBUILD_APPS=ON: Dictates whether to build the standalone command-line executable applications (SvtAv1EncAppandSvtAv1DecApp). Setting this toOFFis useful if you only need the libraries for integration into other software like FFmpeg or HandBrake.
Hardware and Optimization Flags
SVT-AV1 relies heavily on assembly optimizations (AVX2, AVX-512, NEON) to achieve high-speed encoding.
-DENABLE_AVX512=ON: Enables or disables AVX-512 instruction set support. If you are compiling on or targeting modern server CPUs (like Intel Xeon or AMD EPYC) that support AVX-512, keeping thisON(default) provides significant speedups.-DCOMPILE_C_ONLY=OFF: When set toON, this disables all assembly optimizations (x86 NASM or ARM NEON) and compiles only the pure C implementation. This is highly useful for debugging, cross-compiling to unsupported architectures, or testing compiler behavior, but results in much slower encoding speeds.
CPU-Specific Tuning Flags
To squeeze the absolute maximum performance out of SVT-AV1 on a specific machine, you can pass custom flags directly to the compiler via CMake:
-DCMAKE_C_FLAGS="-march=native": Tells the compiler to optimize the code for the host CPU architecture currently performing the build. Do not use this if you plan to distribute the compiled binary to other machines with different CPU architectures.