Giter VIP home page Giter VIP logo

Comments (2)

talltyler avatar talltyler commented on June 18, 2024 1

You are totally correct, all of this is working as it should, thank you for the reply.

from webm-muxer.

Vanilagy avatar Vanilagy commented on June 18, 2024

I actually do call close in my demo code! Here:

// ...
const encodeVideoFrame = () => {
    let elapsedTime = document.timeline.currentTime - startTime;
    let frame = new VideoFrame(canvas, {
        timestamp: framesGenerated * 1e6 / 30
    });
    framesGenerated++;

    let needsKeyFrame = elapsedTime - lastKeyFrame >= 10000;
    if (needsKeyFrame) lastKeyFrame = elapsedTime;

    videoEncoder.encode(frame, { keyFrame: needsKeyFrame });
    frame.close(); // <=== THIS LINE HERE

    recordingStatus.textContent =
        `${elapsedTime % 1000 < 500 ? 'πŸ”΄' : '⚫'} Recording - ${(elapsedTime / 1000).toFixed(1)} s`;
};
// ...

The warning you're talking about is typically benign and just wants to encourage the programmer to manually GC video frames for better memory management.

In your line:

this.videoEncoder.encode(new VideoFrame(frame, { timestamp: time * 1000 }), {
  keyFrame: !(frameIndex % 50),
});

you'll need to keep a reference to the frame to garbage collect it later on:

let frame = new VideoFrame(frame, { timestamp: time * 1000 });
this.videoEncoder.encode(frame, {
  keyFrame: !(frameIndex % 50),
});
frame.close();

from webm-muxer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.