Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
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 Respostas
Responde à pergunta

0

Blob instantiations allow for multiple ArrayBuffers to be concatenated:

new Blob([ ab1, ab2, ab3 ])
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda