First of all, to see a complete list of configure options refer to ./configure --help.

According to the FFmpeg documentation...

This isn't actually the documentation but is a wiki that is editable by anyone, so like any wiki you may want to independently verify any claims.

This made me wonder what other such options FFmpeg can be compiled with in order to give me the best build for creating the most efficient (i.e. the highest quality at the lowest bitrate) audio.

This is currently Opus audio. Enable it with --enable-libopus, and use the latest version of libopus if you want to take advantage of recent development activity.

There are claims that the Sox audio resampler is better than the built-in resampler in FFmpeg. I haven't tried it much myself. Enable it with --enable-libsoxr.

What advantages does compiling with --enable-nonfree offer?

This option alone gives no advantages. It is required for some external libraries that are considered to be non-free. You can view which libraries require this in the source code of the configure file: refer to EXTERNAL_LIBRARY_NONFREE_LIST (and HWACCEL_LIBRARY_NONFREE_LIST). As of this answer these include: decklink, libndi_newtek, libfdk_aac, openssl, libtls (and cuda_nvcc, cuda_sdk, libnpp).

A disadvantage of using --enable-nonfree is that the resulting build will be non-free and therefore non-redistributable.

What advantages does not compiling with --enable-gpl offer?

Slightly faster to compile. Somewhat smaller resulting executable file size. LGPL 2.1 license instead of GPL 2. However, these may not be of any concern to you.

See LICENSE.md included in the source code for a complete list of what requires --enable-gpl.

Answer from llogan on Stack Exchange
Top answer
1 of 2
3

First of all, to see a complete list of configure options refer to ./configure --help.

According to the FFmpeg documentation...

This isn't actually the documentation but is a wiki that is editable by anyone, so like any wiki you may want to independently verify any claims.

This made me wonder what other such options FFmpeg can be compiled with in order to give me the best build for creating the most efficient (i.e. the highest quality at the lowest bitrate) audio.

This is currently Opus audio. Enable it with --enable-libopus, and use the latest version of libopus if you want to take advantage of recent development activity.

There are claims that the Sox audio resampler is better than the built-in resampler in FFmpeg. I haven't tried it much myself. Enable it with --enable-libsoxr.

What advantages does compiling with --enable-nonfree offer?

This option alone gives no advantages. It is required for some external libraries that are considered to be non-free. You can view which libraries require this in the source code of the configure file: refer to EXTERNAL_LIBRARY_NONFREE_LIST (and HWACCEL_LIBRARY_NONFREE_LIST). As of this answer these include: decklink, libndi_newtek, libfdk_aac, openssl, libtls (and cuda_nvcc, cuda_sdk, libnpp).

A disadvantage of using --enable-nonfree is that the resulting build will be non-free and therefore non-redistributable.

What advantages does not compiling with --enable-gpl offer?

Slightly faster to compile. Somewhat smaller resulting executable file size. LGPL 2.1 license instead of GPL 2. However, these may not be of any concern to you.

See LICENSE.md included in the source code for a complete list of what requires --enable-gpl.

2 of 2
2

Thanks to llogan for pointing out that the full list of configuration options can be found by doing ./configure --help in the directory containing the FFmpeg sources. Unfortunately this information isn't documented anywhere else, so to make it available without requiring that FFmpeg's sources are downloaded, I've reproduced them below.

Note that I've only reproduced the configuration options that enable/disable support for a particular external library or hardware acceleration feature - general program configuration or debugging options have been omitted. Each option is followed by a description in square brackets of whether the option is enabled by default in FFmpeg or whether support for it is autodetected:

Licensing options:

  --enable-gpl             allow use of GPL code, the resulting libs and binaries will be under GPL [no]
  --enable-version3        upgrade (L)GPL to version 3 [no]
  --enable-nonfree         allow use of nonfree code, the resulting libs and binaries will be unredistributable [no]

External library support:

  Using any of the following switches will allow FFmpeg to link to the
  corresponding external library. All the components depending on that library
  will become enabled, if all their other dependencies are met and they are not
  explicitly disabled. E.g. --enable-libwavpack will enable linking to
  libwavpack and allow the libwavpack encoder to be built, unless it is
  specifically disabled with --disable-encoder=libwavpack.

  Note that only the system libraries are auto-detected. All the other external
  libraries must be explicitly enabled.

  Also note that the following help text describes the purpose of the libraries
  themselves, not all their features will necessarily be usable by FFmpeg.

  --disable-alsa           disable ALSA support [autodetect]
  --disable-appkit         disable Apple AppKit framework [autodetect]
  --disable-avfoundation   disable Apple AVFoundation framework [autodetect]
  --enable-avisynth        enable reading of AviSynth script files [no]
  --disable-bzlib          disable bzlib [autodetect]
  --disable-coreimage      disable Apple CoreImage framework [autodetect]
  --enable-chromaprint     enable audio fingerprinting with chromaprint [no]
  --enable-frei0r          enable frei0r video filtering [no]
  --enable-gcrypt          enable gcrypt, needed for rtmp(t)e support if openssl, librtmp or gmp is not used [no]
  --enable-gmp             enable gmp, needed for rtmp(t)e support if openssl or librtmp is not used [no]
  --enable-gnutls          enable gnutls, needed for https support if openssl, libtls or mbedtls is not used [no]
  --disable-iconv          disable iconv [autodetect]    
  --enable-jni             enable JNI support [no]
  --enable-ladspa          enable LADSPA audio filtering [no]
  --enable-libaom          enable AV1 video encoding/decoding via libaom [no]
  --enable-libaribb24      enable ARIB text and caption decoding via libaribb24 [no]
  --enable-libass          enable libass subtitles rendering, needed for subtitles and ass filter [no]
  --enable-libbluray       enable BluRay reading using libbluray [no]
  --enable-libbs2b         enable bs2b DSP library [no]
  --enable-libcaca         enable textual display using libcaca [no]
  --enable-libcelt         enable CELT decoding via libcelt [no]
  --enable-libcdio         enable audio CD grabbing with libcdio [no]
  --enable-libcodec2       enable codec2 en/decoding using libcodec2 [no]
  --enable-libdav1d        enable AV1 decoding via libdav1d [no]
  --enable-libdavs2        enable AVS2 decoding via libdavs2 [no]
  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394 and libraw1394 [no]
  --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
  --enable-libflite        enable flite (voice synthesis) support via libflite [no]
  --enable-libfontconfig   enable libfontconfig, useful for drawtext filter [no]
  --enable-libfreetype     enable libfreetype, needed for drawtext filter [no]
  --enable-libfribidi      enable libfribidi, improves drawtext filter [no]
  --enable-libgme          enable Game Music Emu via libgme [no]
  --enable-libgsm          enable GSM de/encoding via libgsm [no]
  --enable-libiec61883     enable iec61883 via libiec61883 [no]
  --enable-libilbc         enable iLBC de/encoding via libilbc [no]
  --enable-libjack         enable JACK audio sound server [no]
  --enable-libklvanc       enable Kernel Labs VANC processing [no]
  --enable-libkvazaar      enable HEVC encoding via libkvazaar [no]
  --enable-liblensfun      enable lensfun lens correction [no]
  --enable-libmodplug      enable ModPlug via libmodplug [no]
  --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
  --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  --enable-libopencv       enable video filtering via libopencv [no]
  --enable-libopenh264     enable H.264 encoding via OpenH264 [no]
  --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
  --enable-libopenmpt      enable decoding tracked files via libopenmpt [no]
  --enable-libopus         enable Opus de/encoding via libopus [no]
  --enable-libpulse        enable Pulseaudio input via libpulse [no]
  --enable-librsvg         enable SVG rasterization via librsvg [no]
  --enable-librubberband   enable rubberband needed for rubberband filter [no]
  --enable-librtmp         enable RTMP[E] support via librtmp [no]
  --enable-libshine        enable fixed-point MP3 encoding via libshine [no]
  --enable-libsmbclient    enable Samba protocol via libsmbclient [no]
  --enable-libsnappy       enable Snappy compression, needed for hap encoding [no]
  --enable-libsoxr         enable Include libsoxr resampling [no]
  --enable-libspeex        enable Speex de/encoding via libspeex [no]
  --enable-libsrt          enable Haivision SRT protocol via libsrt [no]
  --enable-libssh          enable SFTP protocol via libssh [no]
  --enable-libtensorflow   enable TensorFlow as a DNN module backend for DNN based filters like sr [no]
  --enable-libtesseract    enable Tesseract, needed for ocr filter [no]
  --enable-libtheora       enable Theora encoding via libtheora [no]
  --enable-libtls          enable LibreSSL (via libtls), needed for https support if openssl, gnutls or mbedtls is not used [no]
  --enable-libtwolame      enable MP2 encoding via libtwolame [no]
  --enable-libv4l2         enable libv4l2/v4l-utils [no]
  --enable-libvidstab      enable video stabilization using vid.stab [no]
  --enable-libvmaf         enable vmaf filter via libvmaf [no]
  --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
  --enable-libvorbis       enable Vorbis en/decoding via libvorbis, native implementation exists [no]
  --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
  --enable-libwavpack      enable wavpack encoding via libwavpack [no]
  --enable-libwebp         enable WebP encoding via libwebp [no]
  --enable-libx264         enable H.264 encoding via x264 [no]
  --enable-libx265         enable HEVC encoding via x265 [no]
  --enable-libxavs         enable AVS encoding via xavs [no]
  --enable-libxavs2        enable AVS2 encoding via xavs2 [no]
  --enable-libxcb          enable X11 grabbing using XCB [autodetect]
  --enable-libxcb-shm      enable X11 grabbing shm communication [autodetect]
  --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
  --enable-libxcb-shape    enable X11 grabbing shape rendering [autodetect]
  --enable-libxvid         enable Xvid encoding via xvidcore, native MPEG-4/Xvid encoder exists [no]
  --enable-libxml2         enable XML parsing using the C library libxml2, needed for dash demuxing support [no]
  --enable-libzimg         enable z.lib, needed for zscale filter [no]
  --enable-libzmq          enable message passing via libzmq [no]
  --enable-libzvbi         enable teletext support via libzvbi [no]
  --enable-lv2             enable LV2 audio filtering [no]
  --disable-lzma           disable lzma [autodetect]
  --enable-decklink        enable Blackmagic DeckLink I/O support [no]
  --enable-mbedtls         enable mbedTLS, needed for https support if openssl, gnutls or libtls is not used [no]
  --enable-mediacodec      enable Android MediaCodec support [no]
  --enable-libmysofa       enable libmysofa, needed for sofalizer filter [no]
  --enable-openal          enable OpenAL 1.1 capture support [no]
  --enable-opencl          enable OpenCL processing [no]
  --enable-opengl          enable OpenGL rendering [no]
  --enable-openssl         enable openssl, needed for https support if gnutls, libtls or mbedtls is not used [no]
  --disable-sndio          disable sndio support [autodetect]
  --disable-schannel       disable SChannel SSP, needed for TLS support on Windows if openssl and gnutls are not used [autodetect]
  --disable-sdl2           disable sdl2 [autodetect]
  --disable-securetransport disable Secure Transport, needed for TLS support on OSX if openssl and gnutls are not used [autodetect]
  --enable-vapoursynth     enable VapourSynth demuxer [no]
  --disable-xlib           disable xlib [autodetect]
  --disable-zlib           disable zlib [autodetect]

  The following libraries provide various hardware acceleration features:

  --disable-amf            disable AMF video encoding code [autodetect]
  --disable-audiotoolbox   disable Apple AudioToolbox code [autodetect]
  --enable-cuda-nvcc       enable Nvidia CUDA compiler [no]
  --disable-cuvid          disable Nvidia CUVID support [autodetect]
  --disable-d3d11va        disable Microsoft Direct3D 11 video acceleration code [autodetect]
  --disable-dxva2          disable Microsoft DirectX 9 video acceleration code [autodetect]
  --disable-ffnvcodec      disable dynamically linked Nvidia code [autodetect]
  --enable-libdrm          enable DRM code (Linux) [no]
  --enable-libmfx          enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no]
  --enable-libnpp          enable Nvidia Performance Primitives-based code [no]
  --enable-mmal            enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no]
  --disable-nvdec          disable Nvidia video decoding acceleration (via hwaccel) [autodetect]
  --disable-nvenc          disable Nvidia video encoding code [autodetect]
  --enable-omx             enable OpenMAX IL code [no]
  --enable-omx-rpi         enable OpenMAX IL code for Raspberry Pi [no]
  --enable-rkmpp           enable Rockchip Media Process Platform code [no]
  --disable-v4l2-m2m       disable V4L2 mem2mem code [autodetect]
  --disable-vaapi          disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
  --disable-vdpau          disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
  --disable-videotoolbox   disable VideoToolbox code [autodetect]

Also note that some codecs above, such as Xvid and Vorbis, already have encoders native to FFmpeg and don't require that any additional encoders be enabled.

Additional information on licensing options can be found from this screenshot of the Media Auto Build Suite, which I found to contain the best explanation I've come across so far of what the licensing options mean and what their implications are:

🌐
Reddit
reddit.com › r/ffmpeg › can anyone tell me how you compile ffmpeg from a github version, preferably into a static build?
r/ffmpeg on Reddit: Can anyone tell me how you compile ffmpeg from a GitHub version, preferably into a static build?
September 26, 2022 - Any kind of custom patch and you are into having to build it yourself, and that can be a really difficult task when you are talking about something as complex as ffmpeg. ... Unknown option "PATH=/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin". See ./configure --help for available options. ... This came up in a search, but regardless that doesn't look like an option you want to pass in when compiling.
Discussions

audio - Compile FFMpeg without most codecs - Stack Overflow
Can it be done with compilation flags, or do I need to edit the code? ... You can use configure with --disable-everything and then enable only what you need, then build this configuration. More on this: Building FFmpeg. This way you don't need to touch source code (manual edits). Specifically what is affected and other switches (excerpt from configure script): Individual component options... More on stackoverflow.com
🌐 stackoverflow.com
android - Compiling FFmpeg without ALMOST everything - Stack Overflow
In my case I wanted to compile ffmpeg for android using the ffmpeg-android git repo. To understand my problem you should know the basics of building ffmpeg. I only work with audio files but this qu... More on stackoverflow.com
🌐 stackoverflow.com
compilation - FFMPEG API (compiling with specific formats) - Stack Overflow
I am trying to compile FFMPEG to support a single video type (*.mp4). I have everything working when I compile for all, but I do not want the extra over-head when I will only use a single format. ... More on stackoverflow.com
🌐 stackoverflow.com
How to Configure FFmpeg Build for Optimal Performance and Hardware Acceleration
If you are compiling it yourself, then you can add -O2 -march=native to your CFLAGS which will make a difference. Maybe even -O3 -march=native but I'm not sure how compatible ffmpeg is with that. Other than that, the really performance-critical code uses hand-optimized assembly anyway. More on reddit.com
🌐 r/ffmpeg
4
4
July 26, 2024
🌐
GitHub
gist.github.com › omegdadi › 6904512c0a948225c81114b1c5acb875
A list of all the configuration options available when compiling FFMpeg v4.1.5 · GitHub
A list of all the configuration options available when compiling FFMpeg v4.1.5 - ffmpeg-4.1.5_configure_options.txt
🌐
GitHub
github.com › FFmpeg › FFmpeg › blob › master › configure
FFmpeg/configure at master · FFmpeg/FFmpeg
Developer options (useful when working on FFmpeg itself): --disable-debug disable debugging symbols · --enable-debug=LEVEL set the debug level [$debuglevel] --disable-optimizations disable compiler optimizations · --enable-extra-warnings enable more compiler warnings ·
Author   FFmpeg
🌐
Ampere
amperecomputing.com › tuning-guides › FFmpeg-Tuning-Guide
FFmpeg Build and Tuning Guide
When running gcc on Arm architectures, it is recommended to use the -mcpu=native option. Refer to the blog on the Arm website “Compiler flags across architectures: -march, -mtune, and -mcpu” for details. 3. This guide shows how to build with a subset of the packages described in the FFmpeg Compilation Guide.
🌐
FFmpeg
ffmpeg.org › platform.html
Platform Specific Information
If you wish to compile shared libraries, add --enable-shared to your configure options.
Top answer
1 of 1
25

You can use configure with --disable-everything and then enable only what you need, then build this configuration. More on this: Building FFmpeg. This way you don't need to touch source code (manual edits).

Specifically what is affected and other switches (excerpt from configure script):

Individual component options:
  --disable-everything     disable all components listed below
  --disable-encoder=NAME   disable encoder NAME
  --enable-encoder=NAME    enable encoder NAME
  --disable-encoders       disable all encoders
  --disable-decoder=NAME   disable decoder NAME
  --enable-decoder=NAME    enable decoder NAME
  --disable-decoders       disable all decoders
  --disable-hwaccel=NAME   disable hwaccel NAME
  --enable-hwaccel=NAME    enable hwaccel NAME
  --disable-hwaccels       disable all hwaccels
  --disable-muxer=NAME     disable muxer NAME
  --enable-muxer=NAME      enable muxer NAME
  --disable-muxers         disable all muxers
  --disable-demuxer=NAME   disable demuxer NAME
  --enable-demuxer=NAME    enable demuxer NAME
  --disable-demuxers       disable all demuxers
  --enable-parser=NAME     enable parser NAME
  --disable-parser=NAME    disable parser NAME
  --disable-parsers        disable all parsers
  --enable-bsf=NAME        enable bitstream filter NAME
  --disable-bsf=NAME       disable bitstream filter NAME
  --disable-bsfs           disable all bitstream filters
  --enable-protocol=NAME   enable protocol NAME
  --disable-protocol=NAME  disable protocol NAME
  --disable-protocols      disable all protocols
  --enable-indev=NAME      enable input device NAME
  --disable-indev=NAME     disable input device NAME
  --disable-indevs         disable input devices
  --enable-outdev=NAME     enable output device NAME
  --disable-outdev=NAME    disable output device NAME
  --disable-outdevs        disable output devices
  --disable-devices        disable all devices
  --enable-filter=NAME     enable filter NAME
  --disable-filter=NAME    disable filter NAME
  --disable-filters        disable all filters
Top answer
1 of 1
1

I added to ./configure:

--enable-filter=amix, aresample .

Rule 1

You should inform yourself about the most neccessary filters. In my case I needed aresample as well for writing the output file.

Rule2

Be sure what formats you want to use. In my case I wanted to process and/or output mp3 and aac files. Inform yourself by searching the internet for your wishes. Good search terms: ffmpeg {aac, mp3, etc.} encoder .||. decoder .||. muxer .||. demuxer

For aac I needed --enable-muxer=adts and --enable-dexmuxer=adts,aac and --enable-bsf=adtstoasc

Rule3

Enable the protocols (uri schemes) of your given input files. If you want to use inputs from /media/audios/myAudio.mp3 you have to add the file protocol: --enable-protocol=file

Rule 4

Addititional libraries: For mp3 files use --enable-libmp3lame Search the internet for more information.

Rule 5

If you want to combine a low quality audio file with a good quality audio file the output may become as bad as the low quality audio file. You should specify the bitrate when using ffmpeg. Search the internet for more information.

Rule 6

Search the internet. You may not fint the solution within seconds but if you do not stop you may find the solution. Inspect the compilation console output as well and check if every decoder and encoder you wanted is really there. FFmpeg gives this information. Maybe you used a wrong name for a file format which has a different name than the encoder. Or the encoder has another name than the decoder.

Rule 7 You can get a list of all supported encoders and decoders and muxers and so on by calling

./configure --list-{what you want to list in plural}

Example: ./confige --list-demuxers

Find elsewhere
🌐
HackerNoon
hackernoon.com › installing-ffmpeg-compiling-and-customizing-for-multimedia-control
Installing FFmpeg: How to Compile and Fine-Tune for Optimal Performance | HackerNoon
October 17, 2023 - Maximize FFmpeg's Power: Optimize Compilation and Installation for Video Encoding, Transcoding, and Streaming. Boost Multimedia Performance with Vital Codecs!
🌐
GitHub
github.com › FFmpeg › FFmpeg › blob › master › INSTALL.md
FFmpeg/INSTALL.md at master · FFmpeg/FFmpeg
It is recommended to build FFmpeg twice, first with minimal external dependencies so that 3rd party packages, which depend on FFmpegs libavutil/libavfilter/libavcodec/libavformat can then be built.
Author   FFmpeg
🌐
GitHub
gist.github.com › 2bits › 2574547
ffmpeg-0.10.2 configure options · GitHub
September 22, 2019 - ffmpeg-0.10.2 configure options · Raw · ff.stable.txt · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
Reddit
reddit.com › r/ffmpeg › how to configure ffmpeg build for optimal performance and hardware acceleration
r/ffmpeg on Reddit: How to Configure FFmpeg Build for Optimal Performance and Hardware Acceleration
July 26, 2024 -

Hello, I am relatively new to FFmpeg.

I have been working on a customized version of FFmpeg in order to resolve the issue where the HEVC_CUVID decoder fails to retrieve HDR10+ side data after decoding.

To achieve this, I had to modify certain C files and compile them accordingly.

However, I encountered performance concerns with my current build; while Gyan's library achieves approximately 34 FPS, my custom build falls short at less than 9 FPS.

Moreover, it seems that Nvidia hardware acceleration features such as CUVID, FFNVCODEC, and NVDEC are not available or enabled in my build.

My configuration options include:

./configure --toolchain=msvc --arch=x86_64 --enable-yasm --disable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/c/ffmpeg3.3/DLLS

I would greatly appreciate any guidance on resolving these two issues simultaneously.

Thank you for your time and assistance.

install prefix            /c/ffmpeg3.3/DLLS
source path               .
C compiler                cl.exe
C library                 msvcrt
ARCH                      x86 (generic)
big-endian                no
runtime cpu detection     yes
standalone assembly       no
x86 assembler             nasm
MMX enabled               yes
MMXEXT enabled            yes
3DNow! enabled            yes
3DNow! extended enabled   yes
SSE enabled               yes
SSSE3 enabled             yes
AESNI enabled             yes
AVX enabled               yes
AVX2 enabled              yes
AVX-512 enabled           yes
AVX-512ICL enabled        yes
XOP enabled               yes
FMA3 enabled              yes
FMA4 enabled              yes
i686 features enabled     yes
CMOV is fast              yes
EBX available             no
EBP available             no
debug symbols             yes
strip symbols             no
optimize for size         no
optimizations             yes
static                    no
shared                    yes
postprocessing support    no
network support           yes
threading support         w32threads
safe bitstream reader     yes
texi2html enabled         no
perl enabled              yes
pod2man enabled           yes
makeinfo enabled          no
makeinfo supports HTML    no
xmllint enabled           no

External libraries:
mediafoundation         schannel

External libraries providing hardware acceleration:
d3d11va                 d3d12va                 dxva2
🌐
GitHub
gist.github.com › lulalala › 7028049
compile options for minial ffmpeg which can encode/decode from images to h264 · GitHub
compile options for minial ffmpeg which can encode/decode from images to h264 - ffmpeg_compile.sh
🌐
FFmpeg
ffmpeg.org › ffmpeg.html
ffmpeg Documentation
2 days ago - While every effort is made to accurately reflect the behavior of the program, FFmpeg is under continuous development and the code may have changed since the time of this writing. In the absence of any map options for a particular output file, ffmpeg inspects the output format to check which type of streams can be included in it, viz.
Top answer
1 of 2
16

This is easier said than done, and has taken me over a month to figure out how to do without any issues, but I've spent enough time on it that I decided I'd document the process well enough to be completed virtually seamlessly by anyone following me.

Unfortunately, Cygwin's default toolchain (i.e. the gcc-core package included with the Cygwin installer) is inherently broken for cross-compiling purposes, and there doesn't seem to be any intent from the Cygwin maintainers to fix this, so currently, the only way to compile software for Windows with Cygwin is to set up a MinGW-w64 toolchain under it. Thankfully, this is as easy as installing a few packages. After this, we'll be compiling the remaining packages, before using a combination of both to compile FFmpeg itself.


Using this Guide

Following this guide in its entirety will build a static FFmpeg installation with external libraries such as fdk-aac, libopus, x265 and the SOX resampler. I may consider adding instructions for compiling specific external libraries to the guide if I get enough requests to do so for a particular library.

The dependencies used by this guide - made up of the MinGW-w64 cross-compile toolchain itself, all packages installed by apt-cyg and all packages compiled from source - will consume up to 2.8GB of disk space, although the guide also includes commands to clean up everything but the FFmpeg installation once done. The installation itself, made up of the binaries and documentation, occupies just over 200MB of disk space.

This guide will create a folder in your Home directory called ffmpeg_sources, where it will download and compile all of the packages being built from source. FFmpeg will be installed to /usr/local, where the FHS standard recommends that software compiled by the user is installed to. This location also has the secondary advantage of being on the system PATH by default in Cygwin, and so doesn't require the $PATH environment variable to be updated.


Install package manager dependencies

To begin with, download the latest version of the Cygwin installer to install the wget, tar, gawk and git packages. The good news is that these packages are dependencies for a tool that can prevent you from ever needing to use the Cygwin installer again.


Install the apt-cyg package manager

Next, install kou1okada's fork of the apt-cyg package manager. If you don't currently use a package manager for Cygwin, this step will not only make the rest of the guide a breeze, but will also make your Cygwin experience rival that of any Linux distribution.

Even if you already use a package manager for Cygwin, such as a different fork of the original apt-cyg, I highly recommend you replace it with this one, which is a much more fully-fledged piece of software compared to the original, as well as the only package manager for Cygwin that is currently in active development.

To install kou1okada's apt-cyg:

mkdir -p /usr/local/src &&
cd /usr/local/src &&
git clone https://github.com/kou1okada/apt-cyg.git &&
ln -s "$(realpath apt-cyg/apt-cyg)" /usr/local/bin/

Install build tools and set up the MinGW-w64 cross-compiler

apt-cyg install \
autoconf \
automake \
binutils \
cmake \
doxygen \
git \
libtool \
make \
mercurial \
mingw64-x86_64-SDL2 \
mingw64-x86_64-binutils \
mingw64-x86_64-fribidi \
mingw64-x86_64-gcc-core \
mingw64-x86_64-gcc-g++ \
mingw64-x86_64-headers \
mingw64-x86_64-libtheora \
mingw64-x86_64-libvpx \
mingw64-x86_64-runtime \
mingw64-x86_64-win-iconv \
mingw64-x86_64-windows-default-manifest \
mingw64-x86_64-zlib \
nasm \
pkg-config \
subversion \
texinfo \
yasm

Compile the dependencies

Each section below compiles an external library that will allow you to compile FFmpeg with support for that library enabled. Copy and paste the whole of each command into your shell.

If you decide you don't require your build of FFmpeg to support a given library, skip its section and remove the corresponding --enable-package line when compiling FFmpeg in the final stage of this guide.

Create a directory at the root of your Cygwin installation with the following:

rm -rf /ffmpeg_sources &&
mkdir -p /ffmpeg_sources

This is the directory we'll be downloading our source code to, and compiling it from.

libmp3lame

To compile the LAME audio codec for MP3:

cd /ffmpeg_sources && rm -rf lame-svn &&
svn checkout https://svn.code.sf.net/p/lame/svn/trunk/lame lame-svn &&
cd lame-svn &&
./configure --host=x86_64-w64-mingw32 --prefix="/usr/x86_64-w64-mingw32/sys-root/mingw" \
--enable-static --disable-shared &&
make -j$(nproc) &&
make install 

libx264

To compile the x264 video codec:

cd /ffmpeg_sources && rm -rf x264 && 
git clone --depth 1 https://code.videolan.org/videolan/x264.git && 
cd x264 &&
./configure --cross-prefix=x86_64-w64-mingw32- --host=x86_64-w64-mingw32 \
--prefix="/usr/x86_64-w64-mingw32/sys-root/mingw" --enable-static &&
make -j$(nproc) &&
make install 

libx265

To compile the x265 video codec:

cd /ffmpeg_sources && rm -rf x265 && 
hg clone https://bitbucket.org/multicoreware/x265 &&
cd x265/build/linux &&
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/x86_64-w64-mingw32/sys-root/mingw" \
-DENABLE_SHARED=OFF -DCMAKE_EXE_LINKER_FLAGS="-static" ../../source \
-DCMAKE_TOOLCHAIN_FILE="/ffmpeg_sources/x265/build/msys/toolchain-x86_64-w64-mingw32.cmake" &&
make -j$(nproc) &&
make install

libogg/libvorbis

The Ogg format is a dependency for the Vorbis audio codec, so will need to be compiled before it:

cd /ffmpeg_sources && rm -rf ogg &&
git clone --depth 1 https://gitlab.xiph.org/xiph/ogg.git &&
cd ogg && ./autogen.sh &&
./configure --host=x86_64-w64-mingw32 --prefix="/usr/x86_64-w64-mingw32/sys-root/mingw" \
--enable-static --disable-shared &&
make -j$(nproc) &&
make install

Then compile Vorbis as normal:

cd /ffmpeg_sources && rm -rf vorbis && 
git clone --depth 1 https://gitlab.xiph.org/xiph/vorbis.git &&
cd vorbis && ./autogen.sh &&
./configure --host=x86_64-w64-mingw32 --prefix="/usr/x86_64-w64-mingw32/sys-root/mingw" \
--enable-static --disable-shared &&
make -j$(nproc) &&
make install

libaom

To compile the AV1 video encoder:

cd /ffmpeg_sources && rm -rf aom && 
git clone --depth 1 https://aomedia.googlesource.com/aom && 
mkdir -p /ffmpeg_sources/aom/build && cd /ffmpeg_sources/aom/build && 
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/x86_64-w64-mingw32/sys-root/mingw" \
-DCMAKE_EXE_LINKER_FLAGS="-static" .. \
-DCMAKE_TOOLCHAIN_FILE="/ffmpeg_sources/aom/build/cmake/toolchains/x86_64-mingw-gcc.cmake" && 
make -j$(nproc) && 
make install

libopus

To compile the Opus audio encoder:

cd /ffmpeg_sources && rm -rf opus && 
git clone --depth 1 https://github.com/xiph/opus.git &&
cd opus && ./autogen.sh &&
./configure CFLAGS="-I/usr/local/llsp" --host=x86_64-w64-mingw32 --prefix="/usr/x86_64-w64-mingw32/sys-root/mingw" \
--enable-static --disable-shared &&
make -j$(nproc) &&
make install

libfdk-aac

To compile the Fraunhofer FDK encoder for AAC:

cd /ffmpeg_sources && rm -rf fdk-aac && 
git clone --depth 1 https://github.com/mstorsjo/fdk-aac &&
cd fdk-aac && autoreconf -fiv &&
./configure --host=x86_64-w64-mingw32 --prefix="/usr/x86_64-w64-mingw32/sys-root/mingw" \
--enable-static --disable-shared &&
make -j$(nproc) &&
make install 

libsoxr

To compile the SOX resampler library, you'll first need to create a CMAKE toolchain file for the MinGW-w64 toolchain as the project doesn't include one by default.

Create a new file in the Cygwin root directory, and call it toolchain-x86_64-mingw32.cmake (make sure Windows is showing extensions, and that the extension is .cmake).

Copy and paste the following into the file:

SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER /usr/bin/x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER /usr/bin/x86_64-w64-mingw32-windres)
SET(CMAKE_Fortran_COMPILER /usr/bin/x86_64-w64-mingw32-gfortran)
SET(CMAKE_AR:FILEPATH /usr/bin/x86_64-w64-mingw32-ar)
SET(CMAKE_RANLIB:FILEPATH /usr/bin/x86_64-w64-mingw32-ranlib)
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(QT_BINARY_DIR /usr/x86_64-w64-mingw32/bin /usr/bin)
SET(Boost_COMPILER -gcc47)

Now you can compile the SOX resampler as normal:

cd /ffmpeg_sources && rm -rf soxr &&  
git clone --depth 1 https://git.code.sf.net/p/soxr/code soxr &&
mkdir -p soxr/build && cd soxr/build &&
cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="/usr/x86_64-w64-mingw32/sys-root/mingw" \
-DBUILD_SHARED_LIBS=OFF .. -DCMAKE_TOOLCHAIN_FILE="/toolchain-x86_64-mingw32.cmake" &&
make -j$(nproc) &&
make install

Compile the FFmpeg binary

The only thing that's left to is compile FFmpeg itself, using the libraries downloaded or compiled above:

cd /ffmpeg_sources && rm -rf ffmpeg &&
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 &&
tar xvf ffmpeg-snapshot.tar.bz2 && rm -f ffmpeg-snapshot.tar.bz2 && cd ffmpeg &&
CFLAGS=-I/usr/x86_64-w64-mingw32/sys-root/mingw/include &&
LDFLAGS=-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib &&
export PKG_CONFIG_PATH= &&
export PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig &&
./configure \
--arch=x86_64 \
--target-os=mingw32 \
--cross-prefix=x86_64-w64-mingw32- \
--prefix=/usr/local \
--pkg-config=pkg-config \
--pkg-config-flags=--static \
--extra-cflags=-static \
--extra-ldflags=-static \
--extra-libs="-lm -lz -fopenmp" \
--enable-static \
--disable-shared \
--enable-nonfree \
--enable-gpl \
--enable-avisynth \
--enable-libaom \
--enable-libfdk-aac \
--enable-libfribidi \
--enable-libmp3lame \
--enable-libopus \
--enable-libsoxr \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 &&
make -j$(nproc) &&
make install

Remember to remove --enable-\*package\* lines for each package in the list above that you didn't download or compile a library for.

Compiling FFmpeg will take much longer than compilation of the external libraries, but once it's done, you should have a fully working binary enabled with all of the libraries you compiled it with. To run it, simply run ffmpeg in the Cygwin terminal.


Clean up/uninstall

By this point in the guide, you will have taken up around 2.8 GB of disk space with downloading, installing and compiling. The majority of this is now redundant, and should be cleaned up. More than 2.6 GB of it can be safely purged, which brings the total footprint of our FFmpeg installation down to as little as 200MB.

Post-install clean up

Running the following will free up more than 2.3GB of disk space:

apt-cyg remove \
cmake \
doxygen \
git \
mercurial \
subversion \
texinfo \
yasm &&
rm -rf /ffmpeg_sources &&
rm -rf /usr/local/lib/{libav*,libpost*,libsw*} &&
rm -rf /usr/local/lib/pkgconfig/{libav*,libpost*,libsw*} &&
rm -rf /usr/local/include/{libav*,libpost*,libsw*} &&
rm -rf /toolchain-x86_64-mingw32.cmake

As well as removing the ffmpeg_sources directory and unneeded static libraries, this will also remove any packages installed earlier that are no longer needed, except for those that are commonly needed for building tools on Cygwin/Linux.

Remove the cross-compiler

If you no longer intend to compile any other programs using the MinGW-w64 cross-compiling toolchain built earlier in this guide, you can safely uninstall it, as well as all the remaining packages installed earlier:

apt-cyg remove \
autotools \
autoconf \
automake \
gcc-core \
gcc-g++ \
pkg-config \
libtool \
make \
nasm \
mingw64-x86_64-SDL2 \
mingw64-x86_64-binutils \
mingw64-x86_64-fribidi \
mingw64-x86_64-gcc-core \
mingw64-x86_64-gcc-g++ \
mingw64-x86_64-headers \
mingw64-x86_64-libtheora \
mingw64-x86_64-libvpx \
mingw64-x86_64-runtime \
mingw64-x86_64-win-iconv \
mingw64-x86_64-windows-default-manifest \
mingw64-x86_64-zlib &&
rm -rf /usr/x86_64-w64-mingw32

This will free up an additional ~450 MB of space.

Uninstalling FFmpeg

If you ever need to reverse all of the steps in this guide and purge the FFmpeg binaries from your system, simply run the following:

apt-cyg remove \
autotools \ 
autoconf \
automake \
binutils \
cmake \
doxygen \
gcc-core \
gcc-g++ \
git \
libtool \
make \
mercurial \
mingw64-x86_64-SDL2 \
mingw64-x86_64-binutils \
mingw64-x86_64-fribidi \
mingw64-x86_64-gcc-core \
mingw64-x86_64-gcc-g++ \
mingw64-x86_64-headers \
mingw64-x86_64-libtheora \
mingw64-x86_64-libvpx \
mingw64-x86_64-runtime \
mingw64-x86_64-win-iconv \
mingw64-x86_64-windows-default-manifest \
mingw64-x86_64-zlib \
nasm \
pkg-config \
subversion \
texinfo \
yasm &&
rm -rf /ffmpeg_sources &&
rm -rf /usr/local/bin{ffmpeg,ffprobe,ffplay} &&
rm -rf /usr/local/lib/{libav*,libpost*,libsw*} &&
rm -rf /usr/local/lib/pkgconfig/{libav*,libpost*,libsw*} &&
rm -rf /usr/local/include/{libav*,libpost*,libsw*} &&
rm -rf /usr/local/share/doc/ffmpeg &&
rm -rf /usr/local/share/ffmpeg &&
rm -rf /usr/local/share/man/man1/ff* &&
rm -rf /usr/local/share/man/man3/{libav*,libpost*,libsw*} &&
rm -rf /usr/x86_64-w64-mingw32/ &&
rm -rf /toolchain-x86_64-mingw32.cmake 

This will remove everything installed during the process of this guide, and revert your system to exactly how it was before starting it.

2 of 2
3

Instead of doing everything manually, you can use the media-autobuild_suite for Windows, which builds FFmpeg with almost all of its dependencies:

This Windows Batchscript setups a MinGW/GCC compiler environment for building ffmpeg and other media tools under Windows. After building the environment it retrieves and compiles all tools. All tools get static compiled, no external .dlls needed (with some optional exceptions)

The script gets continuously updated, and for most users, it will be the preferred way to get FFmpeg compiled under Windows.

🌐
Scribd
scribd.com › document › 159927616 › FFmpeg-Configure-Options-pdf
FFmpeg Configuration Options Guide | PDF
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
FFmpeg
ffmpeg.org › developer.html
Developer Documentation
The FFmpeg build system allows visualizing the test coverage in an easy manner with the coverage tools gcov/lcov. This involves the following steps: Configure to compile with instrumentation enabled: configure --toolchain=gcov.
🌐
FFmpeg
ffmpeg.org
FFmpeg
This release is not backwards ... allowing such features as custom channel ordering, or Ambisonics. Certain deprecated ffmpeg CLI options were also removed, and a C11-compliant compiler is now required to build the code....
🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › tutorials
FFmpeg 7.x compilation - Linux Mint Forums
March 5, 2023 - The main difference between ~/new_multilib.sh and (the original)~/ffmpeg_sources/x265_git/build/linux/multilib.sh is: 1./ On the "cmake .." line #16, I added the -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off switches, (so later, when building ffmpeg it'll find what it needs for libx265 in ~/ffmpeg_build/...). 2./ (optionally) I removed the "# Mac/BSD libtool" stuff from the "if then else" loop, although you could just leave that in.