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
- Install FFmpeg — Download from ffmpeg.org or use your package manager
- Get the M3U8 URL — Find the HLS stream URL (ends in .m3u8)
- Open a terminal — Command Prompt (Windows), Terminal (Mac), or shell (Linux)
- Run the command:
ffmpeg -i "https://example.com/stream.m3u8" -c copy output.mp4
- 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
Download M3U8 Streams Using FFmpeg
Learn how to download M3U8/HLS streams with FFmpeg. Commands for saving streams, selecting quality, and handling live streams.
Convert M3U8 to MP4 with FFmpeg: Complete Guide
Step-by-step guide to converting M3U8 streams to MP4 using FFmpeg. Fast, lossless, and fully customizable conversion commands.
FFmpeg M3U8 Commands You Need to Know
Essential FFmpeg commands for working with M3U8/HLS streams. Quick reference for downloading, converting, and analyzing streams.