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
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.
Download M3U8 Streams Using FFmpeg
Learn how to download M3U8/HLS streams with FFmpeg. Commands for saving streams, selecting quality, and handling live streams.
Merging M3U8 TS Segments with FFmpeg
Learn how to merge TS segments from M3U8 playlists into a single MP4 file using FFmpeg. Both online stream and local file methods.