npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mp4maker

v1.1.5

Published

Based on [mp4-muxer](https://github.com/Vanilagy/mp4-muxer) , this project provide a straight forward way to encode a MP4 file , frame by frame, directly in the browser on the client-side using WebCodecs.

Downloads

98

Readme

Mp4Maker

Based on mp4-muxer , this project provide a straight forward way to encode a MP4 file , frame by frame, directly in the browser on the client-side using WebCodecs.

You can install the dependancies with this command :

npm install mp4maker

The project contains only 2 classes : Mp4Maker and Mp4Config.

Mp4Config is an object that describe the properties of the output mp4.

    public width: number;
    public height: number;
    public fps: number = 30;
    public audio: boolean = false;
    public audioSamplerate: number = 44100;
    public nbAudioChannel: number = 1;
    public videoBitrate: number = 1e6;
    public audioBitrate: number = 128000;
    public fileName: string = "output.mp4";
    
    //--------used with fastEncode-----------
    public fastEncodingBufferLimit: number = 5; 
    //the maximum difference between the frame sent to VideoEncoder and the frame really encoded
    //you may use a lower value if you encode with a very high resolution like 4k 
    //---------------------------------------
    
    public get audioFrameBufferLength(): number {
        return this.audioSamplerate / this.fps;
    }  

Mp4Maker contains only 4 methods :

public init(config: Mp4Config) {
   //setup and initialize Muxer, VideoEncoder and AudioEncoder (if requird)
}

public encodeFrame(frame: { video: ImageBitmap , audio?: Float32Array[] }){
    
     //frame.video : the current video-frame shaped as ImageBitmap 
     //frame.audio : an array of Float32Array. Each Float32Array represents an audio channel.
     //              the length of each Float32Array must equal mp4config.audioFrameBufferLength

}

public finish(){
    //stop the encoder and save the video as an MP4 file
}

//----------

public fastEncode(nbFrame: number, createFrame: (frameId: number) => Promise<{ video: ImageBitmap, audio?: Float32Array[] }>) {
    //use this method if you want to update the encoding process faster than requestAnimationFrame
    
    //nbFrame : the duration , in frame, of the video. 
    //createFrame: a function that return an object {video:ImageBitmap,audio?:Float32Array[]} 
    //             that represent the current frame to encode
    
    //the process will call createFrame(frameId) then call encodeFrame until frameId != nbFrame
    //when frameId === nbFrame, call finish 
    
    //it also ensure that VideoEncoder cannot be saturated by data during the process and create 
    //some "breathing" to let VideoEncoder the time to work efficiently and never be overbusy
}

check Example1.ts to see a complete example that expose how to encode a canvas-movie frame by frame with an audiotrack containing a basic generated sin wave


I added a second example that show how to use Mp4Maker.fastEncode

Demo : https://mp4maker-fastencode.netlify.app/