beek
beek

Reputation: 3750

Preload video segment size

I'm preloading webMs using the instructions in this article https://web.dev/fast-playback-with-preload/

Generally they work, but the amount of data loading at the start seems to make a difference (I assume it includes the meta data etc)

i.e. this number here 567139

// Fetch beginning of the video by setting the Range HTTP request header.
fetch('file.webm', { headers: { range: 'bytes=0-567139' } })
.then(response => response.arrayBuffer())
.then(data => {
  sourceBuffer.appendBuffer(data);
  sourceBuffer.addEventListener('updateend', updateEnd, { once: true });
});

My question is - how do I calculate the optimum amount of data to preload? I was thinking around 3 seconds but at this stage I don't exactly know the video duration, just the filesize.

For a 7mb webM file I seem to need to load the first 2mb to be able to get the duration data etc. Is this correct?

Upvotes: 1

Views: 310

Answers (0)

Related Questions