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

mediax-sdk

v1.2.0

Published

Node.js SDK for ffmpeg media processing (convert, compress, thumbnails, audio, GIF, watermark, frames, etc.)

Readme

MediaX SDK

MediaX SDK is a Node.js TypeScript library for high-level video/audio/media processing built on ffmpeg. It provides a simple, typed interface to convert, compress, extract audio, generate thumbnails, clip, GIF conversion, watermark, frames extraction, and more. It supports real-time progress, accurate percent calculation, and job queues for production-grade pipelines.


Features

  • Convert video/audio formats
  • Compress videos with bitrate control
  • Extract audio tracks
  • Replace audio in video
  • Generate thumbnails at specific timestamps
  • Clip or segment videos
  • Convert video segments to GIF
  • Concatenate multiple videos
  • Add image watermarks
  • Extract frames as an image sequence
  • Retrieve media metadata
  • Real-time progress events with accurate percentage
  • Typed events for TypeScript safety
  • Job queue support for concurrent processing

Installation

# Using npm
npm install mediax-sdk

# Using pnpm
pnpm add mediax-sdk

Make sure ffmpeg is installed on your system. On Windows, you can download it from FFmpeg.org. On Mac/Linux, you can use brew install ffmpeg or your package manager.


Quick Start

import { MediaX } from "mediax-sdk";

const mx = new MediaX();

// Convert video
const job = mx.convert("input.mp4", "output.mkv");

job.on("start", (cmd) => console.log("Started:", cmd));
job.on("progress", (p) => console.log(`Progress: ${p.percent?.toFixed(1)}%`));
job.on("done", (output) => console.log("Done:", output));
job.on("error", (err) => console.error("Error:", err));

job.start();

Supported Methods

| Method | Description | | ---------------------------------------------------- | --------------------------------------- | | convert(input, output, format?) | Convert video/audio to specified format | | compress(input, output, bitrate?) | Compress video with bitrate | | thumbnail(input, output, time?) | Generate thumbnail at time | | metadata(input) | Get media metadata | | extractAudio(input, output, codec?) | Extract audio track | | replaceAudio(video, audio, output) | Replace audio track in video | | toGif(input, output, { start?, duration? }) | Convert video segment to GIF | | clip(input, output, { start?, duration? }) | Clip video segment | | concat(inputs[], output) | Concatenate multiple videos | | addWatermark(input, watermark, output, { x?, y? }) | Add image watermark | | extractFrames(input, pattern, { fps? }) | Extract frames as images |


Events

Each job emits typed events:

  • start(cmdLine: string) → FFmpeg command started
  • progress(progress: ProgressInfo) → Progress update with percent, frames, fps, kbps
  • done(output?: string) → Job completed
  • error(err: Error) → Job failed
job.on("progress", p => console.log(`Percent: ${p.percent?.toFixed(1)}%`));

Job Queue

Run multiple jobs concurrently:

import { Queue } from "mediax-sdk";

const queue = new Queue(2); // 2 concurrent jobs

queue.add(mx.convert("a.mp4", "a_out.mkv"));
queue.add(mx.compress("b.mp4", "b_out.mp4"));
queue.add(mx.toGif("c.mp4", "c.gif", { start: 1, duration: 5 }));

queue.on("jobProgress", (job, progress) => console.log(`${job.opts.input}: ${progress.percent?.toFixed(1)}%`));
queue.on("jobDone", (job) => console.log(`${job.opts.input} done`));
queue.on("empty", () => console.log("All jobs completed"));

ProgressInfo Type

export interface ProgressInfo {
  percent?: number;
  frames?: number;
  currentFps?: number;
  currentKbps?: number;
  time?: string;
}

Development

Clone and build:

git clone https://github.com/ksaurav24/mediax.git
cd mediax/packages/core
pnpm install
pnpm build

Run tests:

pnpm test

Notes

  • ffmpeg and ffprobe are automatically configured using @ffmpeg-installer/ffmpeg and @ffprobe-installer/ffprobe.
  • Percent progress is accurate using ffprobe to fetch media duration.
  • All events are typed for TypeScript, preventing common runtime errors.
  • Designed for production pipelines with queue and concurrent processing support.