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

139
Visualizações
Only one blob is playable using media recorder to write on disk with electron

I am using React And Electron to write a recorded video using MediaRecorder to disk.

The video file is being generated successfully, however only the first blob of the video is playable. The video file size seems to be increasing if I leave it recording for more time so I think the blobs are being written to the file but in a corrupted way. By the way I'm following this approach unsuccessfully tho.

Front-end code:

const blob_reader_cam = new FileReader();

const handleDataAvailable = (e) => {
  if (!e.data || !e.data.size > 0) return;
  if (blob_reader_cam.readyState !== 1)
    blob_reader_cam.readAsArrayBuffer(e.data);
  else recordedCameraChunks.push(e.data);
};

blob_reader_cam.addEventListener("load", (ev) => {
  window.electron.api.writeCameraFile(ev.currentTarget.result);
  if (recordedCameraChunks.length) {
    ev.currentTarget.readAsArrayBuffer(recordedCameraChunks.shift());
  }
});

const startCameraRecording = () => {
  if (!cameraStream) return;
  const options = {
    mimeType: "video/webm; codecs=vp9",
    videoBitsPerSecond: 2500000,
  };
  mediaRecorder = new MediaRecorder(cameraStream, options);

  mediaRecorder.ondataavailable = handleDataAvailable;
  mediaRecorder.onstop = handleStop;
  mediaRecorder.start(1000);
};

Electron js code:


const storage_stream_cam = require("fs").createWriteStream(PATH_CAM);

writeCameraFile(data) {
      storage_stream_cam.write(Buffer.from(data));
}

about 4 years ago · Juan Pablo Isaza
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