Nexxus
Nexxus

Reputation: 151

Chrome HTML5 video range request headers in Nodejs

I am doing some experimenting with very basic MP4 video streaming using the HTML5 video tag.

Upon looking at the headers that are sent from the client (Chrome browser) when I go to the page with the video tag on it, I see three different range headers sent to the server:

range: 'bytes=0-'
range: 'bytes=4489216-'
range: 'bytes=1180401664-'

I am wondering why Chrome is not specifying an end range header to accompany the start range, it looks like Chrome is attempting to load the entire file, then asking for data somewhere a bit further in the file, and then asking for data very close to the end of the file.

When looking at the Chrome developer tools in the network tab, I see that it immediately download about 3 MB once I get to the page with the video tag on it, then about 20 kB, and then about 3 MB again near the very end of the file.

Streaming does seem to work like this as well as scanning through the video but I'm mainly wondering about why there are no end ranges specified by Chrome and also why it is downloading seemingly random points and sizes in the video while visiting the page.

Thanks!

Upvotes: 0

Views: 1002

Answers (1)

szatmary
szatmary

Reputation: 31160

There is no end because it doesn't not know the end. Mp4 files are split into "boxes". The first 4 bytes of each box is the box size. So the player knows where the next box starts But it doest know the next box size until it starts to download it. So it leapfrogs through the file until it finds what it needs. The browser can always just close the socket if it decides it doesn't want the rest of the range.

Upvotes: 2

Related Questions