Projects, Information
and other Fun Stuff™

- by the OCD Robot

Video Downloading

Just a short post to share a good way to download videos embedded in webpages.

Some videos are easy to download, as they have an obvious mechanism to do so, e.g. a download button. Some are a bit more tricky, especially with CDN hosted videos that have validation tokens and so on attached. This technique I am about to share is not guaranteed to work 100% of the time, forever, but for now it seems to work pretty well even for some that are trickier than usual.

You DO need to be able to download the *.m3u8 file for this to work. That is usually found by opening your browser’s development tools, going to the “network” tab and looking through the list until you see a file ending in .m3u8 (there may be more than one, depending on resolutions).

Once you find the correct .m3u8 file, copy the full URL including any query string and paste it into your browser’s address bar. That should download the .m3u8 file. Rename that to “in.m3u8”.

You also need FFMPEG installed and available in your path, whatever OS you are using. Assuming you have all this done and available, open a command prompt, CD to the directory where your “in.m3u8” file is and run the following command:

ffmpeg -protocol_whitelist file,http,https,tcp,tls -allowed_extensions ALL -i input.m3u8 -bsf:a aac_adtstoasc -c copy out.mp4

Depending on how big the video file is and your connection speed, that could take a while but you should end up with a file called “out.mp4” that is the video you wanted to download.

An alternative if you have been able to download the audio and video separately and need to combine them, is to use the following command:

ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac out.mp4

That command is obviously expecting you are in the current directory where you have an audio file called “audio.wav” (this can be an mp4 file too) and a video file called “video.mp4”.

Have fun.

EOL