2026-07-035 min readdownload hls with ffmpeg, ffmpeg hls download, save hls stream ffmpeg

Download HLS Streams with FFmpeg: Step-by-Step

Complete guide to downloading HLS streams using FFmpeg. Covers VOD, live, encrypted streams, and automation with scripts.

Step-by-Step HLS Download with FFmpeg

  1. Install FFmpeg — Download from ffmpeg.org or use your package manager
  2. Get the M3U8 URL — Find the HLS stream URL (ends in .m3u8)
  3. Open a terminal — Command Prompt (Windows), Terminal (Mac), or shell (Linux)
  4. Run the command:
    ffmpeg -i "https://example.com/stream.m3u8" -c copy output.mp4
  5. Wait for completion — FFmpeg will show progress: time, speed, and file size

Downloading Encrypted Streams

Some HLS streams use AES-128 encryption. FFmpeg can decrypt them automatically if the key is accessible:

ffmpeg -i "https://example.com/encrypted.m3u8" -c copy -decryption_key 0123456789abcdef0123456789abcdef output.mp4

If FFmpeg can't find the key, you may need to download the key file separately and reference it locally.

Automating Downloads with Scripts

For batch downloading multiple streams, create a simple script:

#!/bin/bash
# download_all.sh
urls=(
"https://example.com/stream1.m3u8"
"https://example.com/stream2.m3u8"
)
for url in "${urls[@]}"; do
filename=$(echo $url | grep -oP '[^/]+(?=.m3u8)')
ffmpeg -i "$url" -c copy "${filename}.mp4"
done

Related Articles