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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mp4-to-gif-wasm

v0.1.2

Published

MP4 to GIF conversion with a bundled FFmpeg-based WebAssembly H.264 decoder and GIF pipeline.

Readme

mp4-to-gif-wasm

mp4-to-gif-wasm is a focused npm package for converting short H.264 MP4 clips into GIFs with a bundled FFmpeg-based WebAssembly pipeline.

It is usable as:

  • a generic npm package
  • a low-level Wasm-backed conversion library
  • a Cloudflare Worker handler when you want an HTTP wrapper

Scope

Current input and runtime constraints:

  • input container: MP4
  • supported video codec: avc1 / H.264 only
  • B-frames: supported
  • audio: ignored
  • input limits: <= 5s, <= 480px width
  • output: GIF

The current architecture keeps MP4 demux in JavaScript and runs decode plus GIF generation in Wasm.

Features

  • H.264 decode in WebAssembly
  • B-frame-safe MP4 sample handling
  • FFmpeg-based GIF palette pipeline in Wasm
  • TypeScript API surface
  • Cloudflare Worker entrypoint included

Install

npm install mp4-to-gif-wasm

API Surface

The package exports:

  • convertMp4ToGif(buffer, options)
  • parseMp4Video(buffer)
  • encodeGif(frames, options)
  • H264Decoder
  • worker

Example

import { convertMp4ToGif } from "mp4-to-gif-wasm";

const gif = await convertMp4ToGif(mp4ArrayBuffer, {
  startMs: 0,
  durationMs: 2000,
  fps: 8,
  maxWidth: 160,
  colors: 96
});

Worker Endpoint

The included Worker handler exposes:

POST /v1/mp4-to-gif

Query parameters:

  • startMs default 0
  • durationMs default 5000, max 5000
  • fps default 10, max 12
  • maxWidth default 320, max 480
  • colors default 128, max 256

Error codes:

  • unsupported_codec
  • unsupported_container
  • unsupported_feature
  • input_too_large
  • decode_failed

Development

npm install
npm run prepare:ffmpeg
npm run build:native
npm run build
npm run check
npm test
npm run test:real-videos
npm run test:e2e-native
npx wrangler deploy --dry-run

Native Build Prerequisites

  • Node.js >= 22
  • Emscripten
  • Binaryen / wasm-opt
  • FFmpeg source checkout in vendor/ffmpeg

Fetch the pinned FFmpeg checkout with:

npm run prepare:ffmpeg

The helper script uses:

Repository Layout

  • src/: package entrypoints, Worker wrapper, parser, decoder wrapper, types
  • native/: FFmpeg build glue and C ABI layer
  • scripts/: fixture generation, native build helpers, experiments, benchmarks
  • test/: unit and integration tests

Open Source Notes

This repository ships a bundled Wasm binary linked against FFmpeg libraries. The repository is therefore published under LGPL-2.1-or-later.

Third-party dependencies and upstream source links are tracked in THIRD_PARTY.md.

CI

GitHub Actions cover:

  • type checking
  • unit tests
  • native Wasm rebuild
  • real-video boundary tests
  • end-to-end Wasm decode/GIF tests
  • Wrangler dry-run packaging