2026-07-035 min readffmpeg m3u8 command, ffmpeg hls commands, ffmpeg commands for m3u8

FFmpeg M3U8 Commands You Need to Know

Essential FFmpeg commands for working with M3U8/HLS streams. Quick reference for downloading, converting, and analyzing streams.

Quick Command Reference

Basic conversion:

ffmpeg -i "stream.m3u8" -c copy output.mp4

With audio bitstream filter:

ffmpeg -i "stream.m3u8" -c copy -bsf:a aac_adtstoasc output.mp4

Re-encode to H.264:

ffmpeg -i "stream.m3u8" -c:v libx264 -crf 23 -c:a aac output.mp4

Select specific quality:

ffmpeg -i "master.m3u8" -map 0:v:0 -map 0:a:0 -c copy output.mp4

Extract audio only:

ffmpeg -i "stream.m3u8" -vn -c:a mp3 audio.mp3

Analyzing Stream Information

Before downloading, inspect the stream:

# Show all stream info
ffmpeg -i "https://example.com/master.m3u8"

# Check if encryption is used
curl -s "https://example.com/stream.m3u8" | grep "#EXT-X-KEY"

Live Stream Recording

Record for a specific duration:

ffmpeg -i "live.m3u8" -t 1800 -c copy recording.mp4

Record until manually stopped:

ffmpeg -i "live.m3u8" -c copy recording.mp4

Press Ctrl+C to stop recording. The file will contain everything up to that point.

Segment-Specific Operations

Merge local TS segments into MP4:

ffmpeg -i "concat:seg1.ts|seg2.ts|seg3.ts" -c copy merged.mp4

Download a specific segment range:

ffmpeg -i "stream.m3u8" -ss 120 -t 60 -c copy clip.mp4

Related Articles