Download an HLS stream to MP4
streaming
// what it does
Pulls an HLS playlist and remuxes its segments into a single MP4. ffmpeg reads the .m3u8, downloads the referenced TS or fMP4 segments in order, and -c copy writes the existing H.264/AAC packets into MP4 without re-encoding, so it is fast and lossless. Reach for this to archive a VOD or capture a live HLS feed to a local file.
// shell
$ ffmpeg -i "https://example.com/stream.m3u8" -c copy output.mp4// gotcha
Against a master playlist, ffmpeg's automatic stream selection may not grab the rendition you want (and can even take video and audio from different variants); pin one explicitly with -map 0:p:<n> or point -i at a specific media (variant) playlist. ffmpeg transparently decrypts standard AES-128 HLS when the #EXT-X-KEY URI is reachable, but SAMPLE-AES / FairPlay / Widevine DRM cannot be decrypted.