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

mediamtx-toolkit

v0.1.0

Published

Developer toolkit for building real-time video applications on top of MediaMTX

Downloads

148

Readme

mediamtx-toolkit

CI npm version license node

A developer toolkit for building real-time video applications on top of MediaMTX. MediaMTX is infrastructure you configure; this toolkit is a framework you build with.

Instead of installing MediaMTX by hand, writing YAML, and calling its Control API directly, you write:

import { MediaServer } from "mediamtx-toolkit";

await MediaServer.install();

const server = await MediaServer.start({
  config: { protocols: { webrtc: { enabled: true } } },
});

server.on("crashed", () => console.log("MediaMTX crashed, restarting..."));

const paths = await server.paths();

Status

This package currently implements Layer 0: Core — the foundation that later, higher-level APIs (a fluent stream API, recording, pipelines, clustering, a dashboard) will build on. Layer 0 covers:

  • Downloading and installing the MediaMTX binary
  • Managing its process lifecycle, including crash detection and automatic restart
  • Generating its YAML configuration from a typed object, with hot reload
  • A typed client for MediaMTX's Control API (global config and read-only path listing)

Per-path stream management, recording, snapshots, WebRTC session helpers, pipelines, plugins, clustering, and the dashboard are not implemented yet.

Installation

npm install mediamtx-toolkit

Node.js 18 or later is required (for the global fetch API).

Usage

Installing and starting MediaMTX

import { MediaServer } from "mediamtx-toolkit";

// Downloads the latest MediaMTX release for the current OS/arch and marks
// it as the active version. Safe to call repeatedly; it is a no-op if the
// version is already installed.
await MediaServer.install();

const server = await MediaServer.start({
  config: {
    protocols: {
      rtsp: { enabled: true },
      webrtc: { enabled: true },
      hls: { enabled: true },
    },
    record: { enabled: false },
  },
});

MediaServer.start() resolves once MediaMTX's Control API responds successfully, so the returned server is ready to use immediately.

Events

MediaServer is an EventEmitter:

server.on("started", () => console.log("MediaMTX is up"));
server.on("stopped", () => console.log("MediaMTX stopped"));
server.on("crashed", (info) => console.log("MediaMTX crashed", info));
server.on("stdout", (line) => console.log(line));
server.on("stderr", (line) => console.error(line));

If the MediaMTX process exits unexpectedly, the toolkit automatically restarts it with exponential backoff, up to a bounded number of attempts within a rolling time window. stop() is always safe to call, including while a restart is pending.

Reconfiguring and reloading

server.configure({ record: { enabled: true, path: "./recordings/%path" } });
await server.reload();

reload() rewrites the configuration file and waits until MediaMTX's Control API reflects the change before resolving.

Listing paths

const paths = await server.paths();

Stopping

await server.stop();

API reference

MediaServer

| Method | Description | | --- | --- | | MediaServer.download(options?) | Downloads a MediaMTX release without marking it active. | | MediaServer.install(options?) | Downloads (if needed) and marks a MediaMTX release as active. | | MediaServer.start(options?) | Resolves a binary, writes configuration, spawns the process, and waits for readiness. | | server.configure(partial) | Merges a partial configuration into the in-memory config. | | server.reload() | Writes the current configuration and waits for MediaMTX to pick it up. | | server.paths() | Returns the current list of paths from the Control API. | | server.stop() | Gracefully stops the process and cancels any pending restart. |

See src/index.ts for the full set of exported types, including ToolkitConfig, StartOptions, PathInfo, and the error classes (MediaMTXNotInstalledError, MediaMTXDownloadError, MediaMTXStartError, MediaMTXApiError).

Development

npm install
npm run build
npm test              # unit tests, no network or process spawning
npm run test:integration   # real MediaMTX download and process, requires network
npm run typecheck

License

MIT