HLS.js Guide and Best Practices
The ultimate guide to HLS.js — in-depth explanation of its working principles, use cases, advantages and disadvantages, with code examples and solutions to common issues.
Read More →From beginner to advanced — master all methods of M3U8 to MP4 conversion
M3U8 is the core file format of the HLS (HTTP Live Streaming) streaming media protocol. It is essentially a UTF-8 encoded playlist file used to describe video segmentation information. A complete HLS video typically consists of one M3U8 playlist file and multiple TS segment files.
In practice, we often need to convert M3U8 videos to the more universal MP4 format for playback, storage, or editing on various devices. This article will detail several common methods for M3U8 to MP4 conversion to help you choose the approach that best suits your needs.
If you only need occasional conversions and don't want to download or install any software, using an online conversion tool is the best choice.
FFmpeg is a powerful open-source audio and video processing tool that supports nearly all audio and video format conversions, and is also a great tool for handling M3U8. If you are familiar with command-line operations, this is the most flexible and efficient method.
The simplest M3U8 to MP4 command:
ffmpeg -i "https://example.com/stream.m3u8" -c copy output.mp4
This command uses the -c copy parameter for lossless remuxing — it directly copies the audio and video data from the TS segments into the MP4 container, making it very fast with no quality loss.
If both the M3U8 file and TS segments are stored locally, you can process them like this:
ffmpeg -i "local/playlist.m3u8" -c copy output.mp4
If the M3U8 uses AES-128 encryption, you need to provide the decryption key:
ffmpeg -i "https://example.com/encrypted.m3u8" \
-decryption_key "your_key_here" \
-c copy output.mp4
-c copy: Lossless remuxing, no re-encoding-c:v libx264: Re-encode video using H.264-c:a aac: Re-encode audio using AAC-b:v 2M: Set video bitrate to 2Mbps-s 1280x720: Set output resolution to 720pIf you have already downloaded all TS segment files to your local machine, you can merge these files directly.
Our TS File Batch Merger Tool can help you quickly merge local TS files:
On Windows, you can use the copy command:
copy /b *.ts output.ts
On Mac/Linux, you can use the cat command:
cat *.ts > output.ts
After merging, use FFmpeg to remux to MP4:
ffmpeg -i output.ts -c copy output.mp4
Some video players themselves support recording and saving streaming media being played as local files.
VLC is a powerful open-source player that also supports M3U8 playback and recording:
Cause: The video codec format may be incompatible, or segment files may be corrupted.
Solutions:
ffmpeg -i input.m3u8 -c:v libx264 -c:a aac output.mp4Cause: If using re-encoding, speed will inevitably be slower; poor network conditions can also affect download speed.
Solutions:
Cause: The video codec format is not supported by the MP4 container, or the player doesn't support that codec.
Solutions:
ffmpeg -i input.m3u8 -c:v libx264 -c:a copy output.mp4Cause: The link may have expired, requires login authentication, or has CORS restrictions.
Solutions:
No matter which method you use, as long as you employ lossless remuxing (no re-encoding), there will be no loss of video quality. If re-encoding is necessary, we recommend setting an appropriate bitrate to maintain video quality.
When converting M3U8 to MP4, please note the following:
M3U8 to MP4 conversion is a common requirement that can be achieved through various methods. For most users, using an online conversion tool is the most convenient and quick choice; for developers or users with batch processing needs, FFmpeg is a more flexible and powerful tool.
If you want to quickly try M3U8 to MP4 conversion, try our free online M3U8 to MP4 tool — browser-local processing, safe and fast!
More great articles and useful tools
The ultimate guide to HLS.js — in-depth explanation of its working principles, use cases, advantages and disadvantages, with code examples and solutions to common issues.
Read More →Systematic solutions to common M3U8 to MP4 issues, including black screens, encryption, slow downloads, and 403 errors, providing multiple efficient and practical solutions.
Read More →Comprehensive coverage of PC, mobile, and web platforms — recommending solutions like VLC, PotPlayer, and web-based online players, with troubleshooting methods for common issues.
Read More →Free online M3U8 to MP4 tool — browser-local processing, safe and fast, no registration required
Convert Now ➡