Download M3U8 Streams Using FFmpeg
Learn how to download M3U8/HLS streams with FFmpeg. Commands for saving streams, selecting quality, and handling live streams.
Basic Download Command
To download an M3U8 stream as an MP4 file:
ffmpeg -i "https://example.com/stream.m3u8" -c copy downloaded.mp4
FFmpeg fetches all segments, concatenates them, and saves the result as a single file. The -c copy flag ensures no re-encoding — just a direct copy of the streams.
Downloading Live Streams
For live streams, you need to specify a duration because they don't have an end:
ffmpeg -i "https://example.com/live-stream.m3u8" -t 3600 -c copy live-recording.mp4
The -t 3600 flag tells FFmpeg to record for 3600 seconds (1 hour). Adjust the number to your needs. Press Ctrl+C to stop recording early.
Downloading with Quality Selection
For adaptive streams with multiple quality levels:
# List available variants first
ffmpeg -i "https://example.com/master.m3u8"
# Download the highest quality variant
ffmpeg -i "https://example.com/master.m3u8" -map 0:v:0 -map 0:a:0 -c copy best-quality.mp4
Increase the last number in -map 0:v:0 to select lower quality variants (0=highest, 1=second highest, etc.).
Resuming Interrupted Downloads
FFmpeg doesn't natively support resume. If your download is interrupted, you'll need to start over. For large files, consider:
- Using a download manager that supports HLS (like our online downloader)
- Recording shorter segments and concatenating them
- Ensuring a stable connection before starting
Related Articles
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.
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.