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

@mastashake08/wt-recorder

v1.5.6

Published

WTRecorder is a JavaScript library that enables media recording and low-latency transmission using the WebTransport and MediaRecorder APIs. It is designed for real-time media streaming applications requiring efficient media capture and transmission.

Readme

WTRecorder

WTRecorder is a JavaScript library that enables media recording and low-latency transmission using the WebTransport and MediaRecorder APIs. It is designed for real-time media streaming applications requiring efficient media capture and transmission.


Installation

To install the package, use npm:

npm install @mastashake08/wt-recorder

Importing the Library

Ensure that your project supports ES Modules by:

  • Adding "type": "module" in package.json
  • OR renaming your file to .mjs
import { WTRecorder } from '@mastashake08/wt-recorder';

Usage

Obtaining a Media Stream

To capture video and audio from the user's device:

const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });

Creating an Instance and Starting the Recorder

const serverUrl = "https://your-server.com/webtransport";
const wtOptions = { allowPooling: true }; // Optional WebTransport configuration

const recorder = new WTRecorder(serverUrl, stream, wtOptions);
await recorder.start(500); // Start recording with a 500ms timeslice

Stopping the Recorder and Retrieving the Recorded Data

setTimeout(async () => {
  await recorder.stop();
  const recordedBlob = recorder.getRecordedBlob();
  console.log("Recorded Blob:", recordedBlob);
}, 5000); // Stop recording after 5 seconds

API Reference

WTRecorder Constructor

const recorder = new WTRecorder(serverUrl, stream, wtOptions, mimeType);

Parameters

  • serverUrl (string) – WebTransport server URL.
  • stream (MediaStream) – Video/audio stream to be recorded.
  • wtOptions (Object, optional) – WebTransport configuration settings (default: {}).
  • mimeType (string, optional) – MIME type for recording (default: "video/webm").

Methods

start(timeslice = 1000)

Initializes WebTransport and starts recording.

| Parameter | Type | Default | Description | |------------|--------|---------|-------------| | timeslice | number | 1000 | Time interval (ms) for collecting data chunks |

Returns: Promise<void>


stop()

Stops recording and closes the WebTransport session.

Returns: Promise<void>


getRecordedBlob()

Returns the recorded media as a Blob.

Returns: Blob

Throws an error if no recorded data is available.


cleanup()

Cleans up resources and resets the instance.


convertBase64Digest(base64Digest)

Converts a Base64-encoded server digest into a format compatible with WebTransport.

Parameters:

  • base64Digest (string) – Base64-encoded SHA-256 digest.

Returns: Uint8Array

Throws an error if the input is not a valid Base64 string.

const digest = "c29tZUJhc2U2NERpZ2VzdA=="; // Example Base64 digest
const uint8Array = WTRecorder.convertBase64Digest(digest);
console.log(uint8Array);

Example Implementation

import { WTRecorder } from '@mastashake08/wt-recorder';

(async () => {
  try {
    const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });

    const wtOptions = { allowPooling: true };
    const recorder = new WTRecorder("https://your-server.com/webtransport", stream, wtOptions);

    await recorder.start(500);

    setTimeout(async () => {
      await recorder.stop();
      const recordedBlob = recorder.getRecordedBlob();
      console.log("Recorded Blob:", recordedBlob);
    }, 5000);
  } catch (error) {
    console.error("WTRecorder Error:", error);
  }
})();

Error Handling

WTRecorder includes robust error handling:

  • Validates input parameters (server URL, media stream).
  • Logs WebTransport initialization failures.
  • Handles errors from MediaRecorder and stops the recording if necessary.
  • Ensures cleanup after failures.
  • Throws explicit errors for invalid input formats.

License

This project is licensed under the MIT License.


Contributions

Contributions are welcome. Submit issues or pull requests for improvements and feature requests.