Step 1: (getting some data)
I opened chrome dev tools with network tab open so i can see what was going on, full reload the page, had a hard time with those stupid pop ups and finally got to the video again. Looking at network tab i see something that was strange so i take a closer look (Image 1).
Image 1
A file named init-a1-x3.mp4 was requested along with
init-v1-x3.mp4
fragment-1-a1-x3.m4s
fragment-1-v1-x3.m4s
fragment-2-v1-x3.m4s
Step 2: (making a guess with the data)
Making a guess v1 means video file and a1 means audio track,
and init should be mp4 headers and fragments are the video/audio pieces we need to collect in order to make our video file.
Step 3: (Proving our theory)
To prove our theory is easy just make an http request in chrome to
init-v1.mp4 and init-a1.mp4 and save to a file
Image 2
We get what it looks like a video with no content but it has its length so our guess was right its only a header file.
Now we need to check if it is a valid header, we can do this combining our header file (init) with fragment-1 and check if it has any content.
So lets do it, first we download fragment-1 with chrome, then we open an hex editor (i use HXD works great) to copy the contents of fragment-1 to init.
Image 3 and 4
Text in red is the contents of fragment-1 pasted in init. Of course they go in the end of the file if not we will corrupt first one and we don't want that.
Note that we paste fragment-1-v1 into init-v1 (because they are same format)
When we run our mp4 with VLC (video viewer), we got video yay!, but it is just a fragment of course, so we need to get the others...
Step 4: (the strategy)
-We know that init files are the headers of video and audio file
-We also know that fragments contains video if its a v1 fragment and audio if is a1 fragment.
-We even known that fragments are encoded like this:
fragment-{number}-{type}-x3.m4s
We have to automate the task to download our video and audio fragments and save them to our init file sequantially (if not we have a bunch of pieces in wrong order, we can't understand the movie this way).
Step 5: (the scripting)
I choose node for this project (easy https request with axios) you can choose whatever language best suits for you
The code
Final result:
If you get this far, thank you for taking your time reading this guide, i enjoy doing it and also enjoy working in this mini project.
Please leave your questions and feedback if needed







