Using youtube-dl and FFmpeg to download .m3u8 blob video streams

Introduction

What is youtube-dl? It is an open-source command-line tool for downloading online video streams, particularly from YouTube. It has many options for downloading different types of files and can automate the process. It can hook into FFmpeg to encode downloaded streams to a specific file type and with specific file options.

What is FFmpeg? It is also an open-source command-line tool for converting media files to different types. It can do a lot of things but we’re not actually going to work with it in this article.

What is The Chosen? It is the first major TV show about the life of Jesus Christ, and one of the biggest crowd-funded TV shows at that. All episodes are available for free through their web player or mobile app, and today we are going to use a simple process to download an episode as an MP4 video file.

Step 1: Find the stream URL

First, you need to actually find the webpage that has the video stream. You’ll probably want to start playing the video too. This might not work for every video stream but it works for The Chosen so we’re going to use that as an example.

Next, bring up your browser “inspect” feature. In Google Chrome, you can press F12 or right-click the page and click “inspect”. This will bring up a page on the right that contains all the technical details of the page you’re looking at.

Click on the “Network” tab at the top and reload the webpage. You’ll see a list generate of all the requests being made on the page. On The Chosen’s player page, you’ll see three entries on that list. Click on one, and another smaller window inside the list will appear to the right, showing you data about that particular entry. Under Headers > General > Request URL you will find what we need. As of writing this article, the three requests that generate on refreshing The Chosen’s player page are three video stream requests, with one being marked as 480p quality, one being marked as 1080p quality, and another that is not marked. (Although, when I downloaded the unmarked version, it matched the 1080p version)

Step 2: Create the youtube-dl command

To grab subtitles from the stream, we can use the option –all-subs

To make our output as an MP4, we use the options -f mp4 and -o “filename.mp4”

And finally, we can simply put in the request URL as our last parameter to the command.

It should look something like this:

youtube-dl –all-subs -f mp4 -o “[S2E8] Beyond Mountains [1080p].mp4” “https://video.thechosen.tv/The_Chosen_S02E08_muxed-07092021_y5yx123m-thechosen_1080p_high.m3u8

Step 3: Enjoy!

Or, optionally, create a script to download multiple episodes at once! The default video bandwidth settings are modest, but you can decrease them for a smaller file size if you wish. Take a look at the documentation for youtube-dl and ffmpeg.

Examples

Here are some scripts I created, using The Chosen as an example:

Download all Season 1 episodes (480p)

Download all Season 1 episodes (1080p)

Download all Season 2 episodes (480p)

Download all Season 2 episodes (1080p)

Leave a comment

Your email address will not be published. Required fields are marked *