FFmpeg M3U8をMP4に変換【2025年完全ガイド】
2025年版:FFmpegでストリーミングプレイリストをMP4ダウンロードに変換する実践ガイド。
Table of Contents
- FFmpeg introduction and installation
- Basic conversion commands
- Advanced options (quality, speed, audio)
- Common issues and solutions
- Batch conversion scripts
- Online tool alternatives
Introduction
Learn how to convert M3U8 or HTTP Live Streaming (HLS) playlists into MP4 files using the FFmpeg command-line utility. This guide breaks down installation, essential commands, performance tuning, and troubleshooting so you can confidently archive live or on-demand streams.
Prerequisites
- FFmpeg installed on your system
- Accessible M3U8 playlist URL or local file
- Basic command-line usage knowledge
Install FFmpeg
Windows
- Download the latest release from ffmpeg.org.
- Extract the archive to
C:\\ffmpeg. - Add
C:\\ffmpeg\\binto your system PATH.
macOS
brew install ffmpegLinux (Ubuntu/Debian)
sudo apt install ffmpegBasic Conversion Commands
Simple Copy (Fastest)
ffmpeg -i "https://example.com/playlist.m3u8" -c copy output.mp4The -c copy flag preserves the original audio and video codecs, delivering the quickest results when the MP4 container supports the source streams.
Re-encode for Compatibility
ffmpeg -i input.m3u8 -c:v libx264 -c:a aac output.mp4Re-encoding with H.264 video and AAC audio maximizes playback compatibility across browsers, smart TVs, and mobile devices. Expect longer processing times compared to remuxing.
Advanced Options
High Quality Output
ffmpeg -i input.m3u8 -c:v libx264 -crf 18 -preset slow output.mp4Adjust the -crf value to control quality (lower means higher quality). Combine with a slower preset for improved compression efficiency when file size matters.
Fast Conversion with Bitstream Filters
ffmpeg -i input.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4Adding the aac_adtstoasc bitstream filter ensures AAC audio stored in ADTS format is compatible with MP4 containers without full re-encoding.
Custom Resolution
ffmpeg -i input.m3u8 -s 1920x1080 -c:v libx264 -c:a copy output.mp4Use the -s flag to scale the video to a specific resolution, maintaining the original audio stream when re-encoding is unnecessary.
Common Issues and Fixes
CORS Errors
Append the necessary headers when fetching protected playlists:
ffmpeg -headers "Referer: https://example.com" -i playlist.m3u8 -c copy output.mp4Protocol Not Supported
ffmpeg -protocol_whitelist file,http,https,tcp,tls -i playlist.m3u8 -c copy output.mp4Network Timeouts
ffmpeg -timeout 10000000 -i playlist.m3u8 -c copy output.mp4Batch Conversion Scripts
Bash Script
#!/bin/bash
for file in *.m3u8; do
ffmpeg -i "$file" -c copy "${file%.m3u8}.mp4"
doneWindows Batch
for %%f in (*.m3u8) do ffmpeg -i "%%f" -c copy "%%~nf.mp4"Online Alternative
Prefer a browser-based workflow? Try our Online M3U8 to MP4 Converter, featuring progress tracking, batch queueing, and no local installation requirements.
FAQ
Why does conversion fail? Verify network access, apply the protocol whitelist, or confirm the stream is not DRM protected.
How can I maintain quality? Use -c copy to avoid re-encoding whenever the target device supports the original codecs.
Can I capture live streams? Yes—combine the command with -t 3600 to limit recording to one hour.
Conclusion
FFmpeg delivers fine-grained control over M3U8 to MP4 conversions. When you need a faster option, launch our online converter to process playlists directly in your browser.