M3U8 to MP4 Merging Tutorial
Introduces common approaches for converting M3U8 segmented videos into MP4 files, including online tools, player verification methods, and common developer solutions.
Read More →All common issues covered — easily handle M3U8 to MP4 conversion
M3U8 to MP4 conversion is a very common requirement, but in practice you often encounter various issues: black screen after conversion, video encryption, slow download speed, 403 errors… These problems can be extremely frustrating.
This article compiles the most common failure causes during the M3U8 to MP4 conversion process, and provides detailed solutions for each issue. No matter what problem you encounter, you can find the answer in this article.
After conversion is complete, when playing the MP4 file there's only audio with no video, or the picture is black, garbled, or green.
This is the most reliable solution. Although slower, it has the highest success rate. Use the FFmpeg command:
ffmpeg -i "input.m3u8" -c:v libx264 -c:a aac output.mp4
This command will re-encode the video to H.264 and audio to AAC, which is the most compatible codec combination for MP4.
If you download segments first and then merge, check:
If one tool fails to convert, try other tools:
An encryption error is reported during conversion, or the converted video cannot be played. When opening the M3U8 file with a text editor, you can see fields like #EXT-X-KEY.
AES-128 is a commonly used encryption method for HLS videos. Each TS segment is encrypted using the AES algorithm, and the corresponding key is required for decryption and playback.
Example of encryption identifier in an M3U8 file:
#EXT-X-KEY:METHOD=AES-128,URI="key.key",IV=0x1234567890abcdef
If you have the decryption key, you can use FFmpeg for decryption and conversion:
ffmpeg -i "input.m3u8" -decryption_key "your_key_here" -c copy output.mp4
Note: The key is 32 hexadecimal characters (16 bytes).
If the M3U8 contains the key address, FFmpeg can automatically obtain the key (provided you have access permission):
ffmpeg -i "https://example.com/encrypted.m3u8" -c copy output.mp4
If the key requires specific request headers (such as Cookie, Referer), additional configuration is needed:
ffmpeg -headers "Referer: https://example.com" \
-i "https://example.com/encrypted.m3u8" -c copy output.mp4
Some tools support automatic handling of encrypted videos — you can try several tools.
The conversion progress bar moves very slowly, or downloading segments is very slow, taking hours to complete.
If the M3U8 is a master playlist (containing multiple qualities), choosing lower quality can significantly increase speed. You can use the M3U8 Analyzer to view all available qualities.
Tools that support multi-threaded downloading can download multiple segments simultaneously, significantly increasing speed. Some professional download tools (such as N_m3u8DL-CLI) support multi-threading.
If the network speed is really too slow, you can:
A 403 error is reported when downloading segments, or the M3U8 file itself is inaccessible, showing 403 Forbidden.
If it's an anti-hotlinking restriction, you can add the correct Referer. Use the FFmpeg command:
ffmpeg -headers "Referer: https://www.example.com" \
-i "https://cdn.example.com/video.m3u8" -c copy output.mp4
If login is required to watch, you can copy the Cookie from the browser:
ffmpeg -headers "Cookie: session=xxx; uid=123" \
-i "https://example.com/video.m3u8" -c copy output.mp4
How to get the Cookie:
Some servers check the User-Agent — set it to a browser UA:
ffmpeg -user_agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
-i "https://example.com/video.m3u8" -c copy output.mp4
If none of the above methods work, you can try:
The M3U8 file itself cannot be opened, reporting 404 error, connection timeout, network error, etc.
The video plays normally, but the audio and video don't match — either the audio is faster, or the video is faster.
Re-encoding regenerates timestamps, which usually solves audio-video sync issues:
ffmpeg -i "input.m3u8" -c:v libx264 -c:a aac -async 1 output.mp4
If you know the exact delay, you can manually adjust it:
-itsoffset 0.5 (delay audio by 0.5 seconds)Some players support real-time audio-video sync adjustment — try using a player first.
The download is interrupted during the process, or some segments fail to download, resulting in incomplete video.
Choose download tools that support resumable downloads — they can continue downloading after network recovery.
FFmpeg can set the retry count:
ffmpeg -reconnect 1 -reconnect_streamed 1 \
-reconnect_delay_max 10 -i "input.m3u8" -c copy output.mp4
If the network is unstable, you can:
When encountering problems, you can troubleshoot in the following order:
Finally, and most importantly:
Encountering failures in M3U8 to MP4 conversion is quite normal — the key is to learn to analyze the cause of the problem and then apply the right remedy. This article summarizes the ten most common types of problems and their solutions, hoping to help you complete the conversion smoothly.
If you want to quickly experience M3U8 to MP4 conversion, why not try our free online M3U8 to MP4 tool — browser local processing, safe and fast!
More great articles and useful tools
Introduces common approaches for converting M3U8 segmented videos into MP4 files, including online tools, player verification methods, and common developer 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 →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 →Free online M3U8 to MP4 tool — browser local processing, safe and fast, no registration required
Convert Now ➡