How Do I Download a Video From an M3U8 File?

A M3U8 file is not and should not be considered a video file format, but they are only text-based playlist files. It stores playlists (consisting of a URL) with information about all the items in the playlist. It can be opened using the VLC media player or streamed online as popular platforms like YouTube, Vimeo, and Dailymotion use it. Some users prefer to watch it offline, which requires downloading, which raises the question of how to download a video from an M3U8 file on Linux.

This guide elaborates on the possible methods using which the videos from an M3U8 file can be downloaded.

  • Download a Video From an M3U8 File on Linux
  • Using FFmpeg
  • Get the m3u8 File From a URL
  • View Video From a M3U8 Using Media Player
  • View the Text Inside an M3U8 File

How to Download a Video From an M3U8 File on Linux?

To download a video from an M3U8 file on Linux, you must have a valid URL of the video, such as from YouTube, Dailymotion, or Vimeo. Once you have the URL, use FFmpeg to download the video from it.

Using FFmpeg

FFmpeg is one powerful tool used to do several operations on multimedia files, including downloading a video from an M3U8 file. It is done using this command:

$ ffmpeg -i "URL" outputFile.mp4

Here is a breakdown of the above command:

  • The “ffmpeg invokes the command.
  • The “-i specifies the input which can either be a file or an URL
  • -outputfile.ts is the output file with all segments combined.

Note: The URL should be replaced with the link to the file you are trying to download but beware of copyright issues.

Here is an example of downloading a video from an M3U8 file using FFmpeg on Linux:

$ ffmpeg -i "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8" file.mp4

After a few minutes, the downloading will complete, and the video can be played offline. 

How to Get the m3u8 File From a URL?

To find the m3u8 file from a URL, first, start the video, press the “CTRL+SHIFT+i” and it will take you directly to the tab from where the m3u8 file can be downloaded:

In the above image, the Network tab is selected and from the sub-tabs, select XHR and view the network traffic. In there, look for a .m3u8 file with status 200, right click and select “Open in new tab.” It will now download the file.

Note: If you cannot find the m3u8 file, refresh the video, and if the video has it, you will see it there.

How to View Video From a M3U8 Using Media Player?

If you have a file with a “.m3u8” extension, you can view the video directly on the system without downloading it. Just use the VLC media player.

To install VLC on the system, use these commands:

$ sudo snap install vlc             #Ubuntu/Debian
$ sudo dnf install vlc              #Fedora
$ sudo pacman -S vlc              #Arch Linux
$ sudo zypper install vlc              #openSUSE

After the installation is done, just open the file with “.m3u8” to view the contents of the file without downloading it on the system. To do that, follow these steps.

Step 1: Right-Click and Open With Other Application

First, select “Open With Other Application” by right-clicking on the file.

Step 2: Select Application

From the next screen, select VLC media player, and if it is not there, click on “View All Applications,” and you will find it there.

It will now start playing the file.

The above image confirms playing the file “1.m3u8.

How to View the Text Inside an M3U8 File?

To view the contents of an M3U8 file, first download the file using the browser. We have downloaded the m3U8 file from the following link:  

http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8

When the above URL is pasted in the Browser, it will start downloading.

Once downloaded, head to the Downloads folder (default folder for downloads) using the cd Command:

$ cd Downloads

Now, use any text editor (nano editor recommended) to view the text file:

$ nano sl.m3u8

The above image shows the contents (primarily Links and other metadata) of an M3U8 file.

Conclusion

The M3U8 files provide an efficient and effective way to download the entire playlist. These files provide the list of URLs for the audio or video files to be played seamlessly. The FFmpeg tool is used to download a video from an M3U8 file. However, these files can be played directly without downloading the playlist using the VLC media player.

This guide explained how to download a video from an M3U8 file on Linux.