How to Download Videos with .m3u8 Format Using FFMPEG
Saturday, Jul 16, 2022
Ever found an online video you want to download but the format is .m3u8? This format is a playlist file for HTTP Live Streaming (HLS). In this tutorial, I’ll show you how to download videos with m3u8 format using FFMPEG.
What is FFMPEG?
FFMPEG is a multimedia framework that can:
- Decode, encode, transcode
- Mux, demux
- Stream, filter
- Play
Simply put, FFMPEG is a tool for manipulating video and audio files.
Installing FFMPEG
macOS
brew install ffmpeg
Ubuntu/Debian
sudo apt update
sudo apt install ffmpeg
Windows
Download from ffmpeg.org and add to PATH.
How to Get the m3u8 URL
- Open the website that has the video
- Open Developer Tools (F12 or Cmd+Option+I)
- Go to the Network tab
- Filter with keyword
m3u8 - Play the video and watch for requests that appear
- Copy the URL ending in
.m3u8
Download Video with FFMPEG
After getting the m3u8 URL, run the following command:
ffmpeg -i "YOUR_M3U8_URL" -c copy output.mp4
Example:
ffmpeg -i "https://example.com/video/playlist.m3u8" -c copy movie.mp4
Parameter Explanation
-i: Input file/URL-c copy: Copy codec without re-encoding (faster)output.mp4: Output file name
Additional Tips
If there’s an SSL error
ffmpeg -i "M3U8_URL" -c copy -bsf:a aac_adtstoasc output.mp4
For videos with subtitles
ffmpeg -i "M3U8_URL" -c copy -c:s mov_text output.mp4
Monitor progress
FFMPEG will display progress in the terminal:
frame: number of frames processedtime: duration already downloadedspeed: download speed
Conclusion
FFMPEG is a very powerful tool for video manipulation. With a simple command, you can download videos from various sources.
Disclaimer: Use this tutorial wisely and only for videos you have the right to download.
Have questions? Reach out to me on Twitter @nayakayp!