Build FFmpeg with OpenSSL or GnuTLS

This guide explains how to compile FFmpeg from source with TLS support using either OpenSSL or GnuTLS to enable secure protocols such as HTTPS, FTPS, and RTMPS. By default, FFmpeg does not bundle TLS support unless explicitly configured with an external cryptography library. Because OpenSSL has licensing considerations that require enabling non-free flags, many users opt for GnuTLS for LGPL/GPL compliance; both methods are detailed step-by-step below.

1. Install Build Dependencies

Before compiling, update your package manager and install the necessary build tools and development headers.

On Debian or Ubuntu-based distributions:

sudo apt update
sudo apt install -y build-essential yasm nasm pkg-config git

Install your preferred TLS development library:

  • For GnuTLS:

    sudo apt install -y libgnutls28-dev
  • For OpenSSL:

    sudo apt install -y libssl-dev

2. Download FFmpeg Source Code

Clone the official FFmpeg Git repository to your local machine and navigate into the directory:

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

3. Configure the Build

Choose either OpenSSL or GnuTLS based on your licensing and technical requirements. Note that OpenSSL is considered incompatible with the GPL license under FFmpeg's terms, requiring the --enable-nonfree flag.

Run the ./configure script with --enable-gnutls:

./configure --prefix=/usr/local --enable-gnutls --enable-gpl

Option B: Building with OpenSSL

Run the ./configure script with --enable-openssl and --enable-nonfree:

./configure --prefix=/usr/local --enable-openssl --enable-nonfree

4. Compile and Install

Once configuration finishes without errors, compile the binary using multiple CPU cores to speed up the process, then install the generated binaries:

make -j$(nproc)
sudo make install

5. Verify TLS Support

Verify that FFmpeg was built correctly and supports secure network transport by checking the available protocols:

ffmpeg -protocols | grep -E "https|tls"

If the output lists https and tls, the build was successful, and FFmpeg is ready to handle encrypted network streams.