New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mfx

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mfx

In-browser video editing toolkit, with effects accelerated by WebGL

latest
Source
npmnpm
Version
0.10.2
Version published
Maintainers
1
Created
Source

MFX

In-browser video editing using WebCodecs, WebStreams, and WebGL → mfxlib.com

Usage

Decode MP4 Video -> zoom out -> encode to WebM keeping original Audio (vp8):

import {
  decode,
  encode,
  effect,
  visual,
  writeToFile,
} from "mfx";

// Files can be fetched locally
const file = await fetch("https://example.com/myvideo.mp4");

// Decode video container, returns each track as a WebStream
const { video, audio } = await decode(file, "video/mp4", {
  // Addresses Chromium WebCodecs bug, Set to true for HEVC or if "Can't readback frame textures" is thrown. Has ~10% performance impact.
  forceDecodeToSoftware: false,
});

// Hardware accelerated (WebGL2) effect pipeline
const videoOutput = effect(video, [
  // Apply zoom out effect
  visual.zoom({ factor: 0.5, x: 0.5, y: 0.25 })
]);

// Readable WebStream
const outputStream = encode({
  mimeType: `video/webm; codecs="vp8,opus"`, // Transcode to WebM VP8 (video) and Opus (audio)
  video: {
    ...video.track.config, // Inherit configuration from input video
    stream: videoOutput,
    width: 640,
    height: 360,
    bitrate: 1e6,
    framerate: 30,
  },
  audio: {
    ...audio.track.config, // Inherit configuration from input audio
    stream: audio
  }
});

// Opens a save dialog in the browser
await writeToFile(outputStream, "output.webm");

// Alternatively you can pipeTo a fetch POST request
await fetch("example.com/save", {
  method: "POST",
  body: outputStream
});

Support Table

While codec support heavily depends on the browser, mfx aims to provide support for the following container / codec pairs:

ContainerCodecEncode / Decode
MP4H.264/AVCBoth
MP4H.265/HEVCDecode
MP4VP8Both
MP4VP9Both
WebMVP8Both
WebMVP9Both
GIFLZWEncode
Audio
MP4OpusBoth
MP4AACBoth
WebMOpusBoth
WebMVorbisBoth

Roadmap

Soon

  • Fix Audio trimming to include subframes
  • Regional effects
  • GIF decoder
  • Optimization Pipeline
    • Frame delta GPU pipeline
      • To remove duplicated or near-identical frames based on controllable parameters
      • Auto-quantization based on frame hints
    • RGB -> YUV conversion for better compatibility and output size
    • Multi-pass adaptive bitrate
    • Frame rate pinning to auto-adjust timestamps
      • Optionally disable VFR
    • Temporal Noise Reduction
  • API Documentation
    • Add note on VP9 probe
  • Testing: Source videos with frame duration > fps to showcase frameRate
  • Run tests on Github actions
  • Contribution Guide

Later

Contributing

Install git-lfs to pull sample files:

brew install git-lfs
npm install
npm start

License

MIT License

Disclaimer on Sample Videos

Some test videos are sourced from coverr.co yet they are only used for testing and will not be built into the MFX package. These videos are under a permissive license (https://coverr.co/license).

Keywords

video

FAQs

Package last updated on 18 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts