Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting 0xc00d3e8c Error and duration is not shown #16

Open
glitch-txs opened this issue Oct 7, 2022 · 0 comments
Open

getting 0xc00d3e8c Error and duration is not shown #16

glitch-txs opened this issue Oct 7, 2022 · 0 comments

Comments

@glitch-txs
Copy link

glitch-txs commented Oct 7, 2022

I'm recording a canvas animation and trying to download it as webm file, when using this library I get 0xc00d3e8c error on the media player and duration is neither shown in the properties of the file.
I can open however the animation on my browser but if I download it from there the quality is very low and the duration is still infinity/not fixed.

This is my code:

import ysFixWebmDuration from "fix-webm-duration"


function startRecording() {
    setStartTime(Date.now())
    const canvas = container.current.firstChild as HTMLCanvasElement
    const chunks = []; // here we will store our recorded media chunks (Blobs)  
    const stream = canvas.captureStream(60); // grab our canvas MediaStream
    const rec = new MediaRecorder(stream, {
      mimeType:'video/webm',
      videoBitsPerSecond: 8000000
    }); // init the recorder
    // every time the recorder has new data, we will store it in our array
    rec.ondataavailable = e => chunks.push(e.data);
    // only when the recorder stops, we construct a complete Blob from all the chunks
    rec.onstop = e => exportVid(chunks);
    
    rec.start();
    setTimeout(()=>rec.stop(), 10000); // stop recording in 3s
  }
  
  function exportVid(chunks: BlobPart[]) {

    const duration = Date.now() - startTime

    const blob = new Blob(chunks, {type: 'video/webm'})
    ysFixWebmDuration(blob, duration, {logger: false}).then((fixedBlob) => {
      const a = document.createElement('a');
      a.download = 'Animation.webm';
      a.href = URL.createObjectURL(fixedBlob);
      a.textContent = 'download the video';
      document.body.appendChild(a);
    })
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant