How to Download Videos with .m3u8 Format Using FFMPEG - Nayaka Yoga Pradipta
ID | EN

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

  1. Open the website that has the video
  2. Open Developer Tools (F12 or Cmd+Option+I)
  3. Go to the Network tab
  4. Filter with keyword m3u8
  5. Play the video and watch for requests that appear
  6. 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 processed
  • time : duration already downloaded
  • speed : 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!