Stream Video Over HTTPS with FFmpeg

This article provides a quick guide on how to securely stream video over HTTP (HTTPS) using FFmpeg. You will learn how to configure FFmpeg to package your video into the HTTP Live Streaming (HLS) format and securely upload or stream it to an HTTPS-enabled web server or ingestion endpoint.


To stream video over HTTPS using FFmpeg, the most common and reliable method is using the HTTP Live Streaming (HLS) protocol. FFmpeg encodes the video, cuts it into small segments, creates a playlist file (.m3u8), and sends these files to a secure web server (like Nginx or Apache configured with SSL/TLS) via HTTPS.

Step 1: Prepare Your HTTPS Destination

Before running FFmpeg, you need a web server or a streaming destination configured to accept HTTPS uploads (usually via HTTP PUT or POST methods, such as WebDAV). Ensure your server has a valid SSL certificate installed.

Step 2: Use the FFmpeg HLS Command

To encode a video input and push it to your secure server over HTTPS, use the following FFmpeg command:

ffmpeg -re -i input.mp4 \
  -c:v libx264 -preset veryfast -b:v 3000k \
  -c:a aac -b:a 128k \
  -f hls \
  -hls_time 4 \
  -hls_list_size 5 \
  -hls_flags delete_segments \
  -method PUT \
  https://yoursecure-server.com/live/stream.m3u8

Command Breakdown:

Step 3: Handling SSL Certificate Issues

If you are using a self-signed SSL certificate for testing purposes, FFmpeg might reject the connection due to verification errors. You can bypass certificate verification by adding the -tls_verify 0 flag to your command:

ffmpeg -tls_verify 0 -re -i input.mp4 -c:v libx264 -c:a aac -f hls -method PUT https://yoursecure-server.com/live/stream.m3u8

Note: Only use -tls_verify 0 for development and testing. Always use valid certificates in production.

Step 4: Playing Back the Secure Stream

Once FFmpeg starts uploading the segments to your HTTPS server, users can watch the stream securely. Any modern HLS-compatible web player (such as Video.js, hls.js, or Plyr) can play the stream by pointing to the secure URL:

https://yoursecure-server.com/live/stream.m3u8