How to Build FFmpeg with OpenSSL or GnuTLS
This guide provides a straightforward walk-through for compiling FFmpeg from source with secure network capabilities. By enabling either OpenSSL or GnuTLS during the build process, you allow FFmpeg to handle encrypted network streams, such as HTTPS, RTMPS, and RTSPS. You will learn the system prerequisites, the specific configuration flags required for both libraries, and how to verify that your custom build supports secure protocols.
Why Compile FFmpeg with SSL?
By default, standard FFmpeg builds may not include TLS/SSL support due to licensing and dependency restrictions. If you attempt to stream over HTTPS or RTMPS without TLS support, you will encounter protocol errors. Compiling FFmpeg with OpenSSL or GnuTLS bridges this gap, allowing secure, encrypted media transmission.
Note that you must choose either OpenSSL or GnuTLS; enabling both simultaneously will cause configuration conflicts.
Step 1: Install Build Tools and Dependencies
Before compiling, install the essential development tools and build dependencies for your operating system.
On Debian/Ubuntu-based systems, run:
sudo apt update
sudo apt install -y build-essential yasm pkg-config gitOn Fedora/RHEL-based systems, run:
sudo dnf groupinstall "Development Tools"
sudo dnf install -y yasm pkgconfig gitStep 2: Download the FFmpeg Source Code
Clone the official FFmpeg git repository and navigate into the directory:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpegOption A: Build FFmpeg with OpenSSL
OpenSSL is widely used and offers excellent performance, but its license requires special configuration flags when paired with FFmpeg.
1. Install the OpenSSL Development Libraries
- Debian/Ubuntu:
sudo apt install libssl-dev - Fedora/RHEL:
sudo dnf install openssl-devel
2. Configure the Build
To build with OpenSSL, you must include the
--enable-openssl flag. Because of licensing compatibility,
you must also include the --enable-nonfree flag if you are
distributing the binary.
./configure --enable-openssl --enable-nonfree3. Compile and Install
Compile the binaries using your available CPU cores (e.g.,
-j$(nproc)) and install them:
make -j$(nproc)
sudo make installOption B: Build FFmpeg with GnuTLS
GnuTLS is a GPL-compatible alternative to OpenSSL, making it ideal if you want to distribute your compiled FFmpeg binary under standard GPL terms.
1. Install the GnuTLS Development Libraries
- Debian/Ubuntu:
sudo apt install libgnutls28-dev - Fedora/RHEL:
sudo dnf install gnutls-devel
2. Configure the Build
Configure the build using the --enable-gnutls and
--enable-gpl flags:
./configure --enable-gnutls --enable-gpl3. Compile and Install
Compile the binaries and install them to your system:
make -j$(nproc)
sudo make installStep 3: Verify Secure Protocol Support
Once the compilation and installation processes are complete, verify that your new FFmpeg binary has secure network protocols enabled.
Run the following command to list the supported protocols:
ffmpeg -protocolsLook at the Input and Output columns in the output. If the build was successful, you should see the following protocols listed:
httpsrtmpstls
You can also test the build by fetching information from a secure HTTPS stream:
ffmpeg -i https://secure.streaming.provider/live/playlist.m3u8If FFmpeg initiates the connection without a “Protocol not found” error, your secure network communication is fully functional.