Compile FFmpeg with libspeex Support

This guide provides a straightforward walkthrough for enabling the libspeex library when building FFmpeg from source. By linking FFmpeg with libspeex, you enable decoding and encoding support for the Speex voice codec. The process involves installing the prerequisite Speex development packages, configuring the FFmpeg build with the --enable-libspeex flag, and compiling the final binaries.

1. Install Prerequisites

Before configuring FFmpeg, you must install the libspeex development headers along with standard compilation tools.

On Debian/Ubuntu:

sudo apt update
sudo apt install build-essential yasm pkg-config libspeex-dev

On Fedora/RHEL/CentOS:

sudo dnf install gcc gcc-c++ make pkgconfig yasm speex-devel

On macOS (via Homebrew):

brew install yasm speex pkg-config

2. Download FFmpeg Source Code

Clone the official FFmpeg Git repository or download a release tarball, then navigate into the source directory:

git clone https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg

3. Run the Configure Script

Run the ./configure script and include the --enable-libspeex flag. Depending on your needs, you may also want to include --pkg-config-flags="--static" if compiling statically, or common flags like --enable-gpl.

./configure --enable-libspeex

If pkg-config cannot locate the Speex library files, verify that libspeex.pc is in your PKG_CONFIG_PATH.

4. Compile and Install

Once the configuration succeeds without errors, compile FFmpeg using make. You can utilize multiple CPU cores using the -j flag:

make -j$(nproc)
sudo make install

(Note: On macOS, replace $(nproc) with $(sysctl -n hw.ncpu)).

5. Verify libspeex Support

Check that FFmpeg successfully registered the Speex encoder and decoder:

ffmpeg -encoders | grep speex
ffmpeg -decoders | grep speex

If the compilation was successful, libspeex will be listed as an available codec in both outputs.