The stream refuses to connect. You dig into the logs, and there it is—TLS handshake failed. With FFmpeg, secure transport depends on precise TLS configuration, and one wrong flag can break it.
What is FFmpeg TLS Configuration?
FFmpeg supports TLS (Transport Layer Security) to encrypt data over HTTP, RTSP, and other network protocols. TLS ensures the connection is secure between client and server. Proper setup means defining trusted certificates, cipher suites, and verification modes directly in the FFmpeg command-line or through its configuration files.
Enabling TLS in FFmpeg
FFmpeg uses the underlying OpenSSL or GnuTLS libraries for TLS. To enable it, you compile FFmpeg with the appropriate --enable-openssl or --enable-gnutls flag. Prebuilt binaries often include one or both options by default. Check with:
ffmpeg -buildconf | grep ssl
Basic TLS Command Example
To stream a file over HTTPS with certificate verification:
ffmpeg -i input.mp4 -c:v libx264 -f mpegts "https://example.com/stream?timeout=5000"\
-tls_verify 1 \
-tls_ca_file /path/to/ca.crt
Here:
- -tls_verify 1 enforces server certificate validation.
- -tls_ca_file points to the trusted CA bundle.