← Blog.backToBlog

Download M3U8 Streams Using FFmpeg

7 min read

Basic Download Command

Save an M3U8 stream as MP4:

ffmpeg -i "https://example.com/stream.m3u8" -c copy downloaded.mp4

FFmpeg fetches segments, concatenates them, and writes one file. -c copy avoids re-encoding. Prefer a GUI? Try our free online M3U8 downloader.

Downloading Live Streams

Live streams have no natural end — set a duration:

ffmpeg -i "https://example.com/live.m3u8" -t 3600 -c copy live-recording.mp4

-t 3600 records one hour. Press Ctrl+C to stop early; the file keeps what was captured. Stay near the live edge; old segments expire.

Quality Selection

# Inspect variants
ffmpeg -i "https://example.com/master.m3u8"
# Highest video + audio
ffmpeg -i "https://example.com/master.m3u8" -map 0:v:0 -map 0:a:0 -c copy best.mp4

Increase the last index in -map 0:v:N for lower qualities.

Resuming Interrupted Downloads

FFmpeg does not truly resume mid-playlist. If interrupted, restart or capture shorter clips and merge later. For large jobs, use a stable connection, or a downloader with retries like our downloader. See also M3U8 download failed.

Headers for Protected CDNs

ffmpeg -headers "Referer: https://example.com" -user_agent "Mozilla/5.0" -i "URL" -c copy out.mp4

Use when the CDN returns 403 without browser-like headers.

Frequently Asked Questions

How do I download M3U8 with FFmpeg?
ffmpeg -i "url" -c copy out.mp4

How long can I record live?
As long as you set with -t, or until you stop with Ctrl+C.

Can FFmpeg resume?
Not natively for HLS — restart or use shorter segments.

Is this legal?
Only download streams you have the right to save.