Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Range header, video

First of all, don't ask me why I'm duing this thing, but I'm just curious if I can attain it.

I request a video from a server using the Range-header. The server sends me a buffer data of the video. In general I have about 3 request and then I have the full array of all three array buffers. Can I somehow concat them and then, converting the concatenation to a blob, create a url using URL.createObjectUrl to watch the video?

(In the following code, let's just assume we don't get fetch errors)

const getVideoBuffers = async (ranges, currentBuffers = [], i = 0) => {
  const res = await fetch("video", { headers: { Range: ranges[i] } });
  const buffer = await res.arrayBuffer();
  currentBuffers.push(buffer);
  i += 1;
  if (res.ok && res.status !== 206) return currentBuffers;
  return getVideoBuffers(ranges, currentBuffers, i);
}

const videoRanges = [...];
const buffers = await getVideoBuffers(videoRanges);
// Need this function
const concatedBuffers = concatBuffers(buffers);
const blob = new Blob([concatedBuffers], { type: "video/mp4" });
const url = URL.createObjectUrl(blob);
const video = document.createElement("video");
video.src = url;

Or am I thinking completely wrong? Then, how can I achieve the desired thing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Blob instantiations allow for multiple ArrayBuffers to be concatenated:

new Blob([ ab1, ab2, ab3 ])
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!