2

I want to download a streaming video. When I go to Chrome DevTools -> Network instead of a link to the mp4 video I find many links like ...hd4b.mp4/fragment-1-v1.m4s and other like ...a1.m4s for audio. There are also an initial ...hd4b.mp4/init-v1.mp4 and ...init-a1.mp4. There are too many fragments to copy them manually.

So I need to know how to filter all the .m4s fragment links for the .mp4 file I want. There is an answer here that gives me all the links in Networks and after executing it I can paste the links to a file but it gets links that are not part of the .mp4 I want too. It doesn't really matter but it would be nice to get only the links for the ...hd4b.mp4.

How do I get the video links in one file and the audio ones in another?

What should I do with the init links? Add them to the list?

Now that I think, the way to get the links would be going to the end of the video and getting the last number and generating the links modifying the number from one to last. How would I generate the links? Answer.

And then when I have the links here's the way to download them but how do I merge the video parts?

And when I have the audio and video how do I combine them in the final mp4?

2
  • Use youtube-dl when possible.
    – Daniel B
    May 29, 2019 at 10:14
  • I've tried it, but it doesn't seem to work.
    – user428047
    May 29, 2019 at 10:15

1 Answer 1

4

youtube-dl

Try using the latest version to download the video. If you can't follow the steps.

First get the links

In Chrome go to DevTools -> Networks and find the first and last fragment links. If the links are sequential generate the links like:

seq -f "...hd4b.mp4/fragment-%g-v1.m4s" 10 > video-links.txt

Where %g will go from 1 to 10. If there is an init link it has to be included at the beginning of the video-links.txt file.

If the links are not sequential copy them like this:

  1. Switch devtools to detached window (click devtools settings icon, click "dock side" undock icon). Next time you can simply press Ctrl-Shift-D.
  2. Invoke devtools-for-devtools by pressing Ctrl-Shift-i
  3. Run this code to copy the URLs of all/filtered requests to clipboard: copy(UI.panels.network._networkLogView._dataGrid._rootNode._flatNodes.map(n => n._request._url).join('\n'))

You can save the code as a Snippet in Sources panel and run it via right-click or Ctrl-Enter:

var URLs = UI.panels.network._networkLogView._dataGrid._rootNode._flatNodes.map(n => n._request._url);
copy(URLs.join('\n'));
URLs; // displays it in the console as an expandable array

After executing the script the links are in the clipboard so paste them to a file.

Download video and audio

wget -i "video-links.txt" -O "video.mp4" -B "...hd4b.mp4/"

Use the -B option with the base of the URL.

Download the audio following the same steps as for the video.

Merge video and audio

ffmpeg -i video.mp4 -i audio.wav \
-c:v copy -c:a aac -strict experimental output.mp4

You must log in to answer this question.