Convert HLS to MP4 Using FFmpeg
Convert HLS streaming video to MP4 with FFmpeg. Fast lossless conversion and re-encoding options for maximum compatibility.
The Standard Command
To convert an HLS stream to MP4 with FFmpeg:
ffmpeg -i "https://example.com/stream.m3u8" -c copy -bsf:a aac_adtstoasc output.mp4
This is the most common command for HLS to MP4 conversion. It preserves original quality by using stream copy mode.
When Stream Copy Fails
If you get errors with -c copy, the stream may use a codec incompatible with MP4. Try re-encoding:
ffmpeg -i "https://example.com/stream.m3u8" -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k -pix_fmt yuv420p output.mp4
Hardware Acceleration
For faster conversion on modern hardware:
# NVIDIA NVENC
ffmpeg -i "stream.m3u8" -c:v h264_nvenc -preset p7 -cq 23 -c:a aac output.mp4
# Intel QuickSync
ffmpeg -i "stream.m3u8" -c:v h264_qsv -global_quality 23 -c:a aac output.mp4
# Apple VideoToolbox
ffmpeg -i "stream.m3u8" -c:v h264_videotoolbox -q:v 60 -c:a aac output.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.
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.