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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@megh-computing/metadata-synchronizer

v0.1.0

Published

Synchronizes a metadata stream with a video stream using a shared timestamp

Downloads

2

Readme

Metadata Synchronizer - Megh Computing

npm npm dependencies node npm type definitions

Megh VAS products output video and metadata streams separately. This package can be used to correlate the out-of-band metadata with the MP4 video using timestamps present in both data streams:

  • For the MP4 video, the media presentation timestamp (PTS) of each frame should be used.
  • For the metadata, the timestamp is included in the ZeroMQ multi-part message.

Features

  • Hybrid package: CommonJS and ESM supported
  • Cross-platform: Node.js (16+) and modern browsers (ES2020+)
  • First-class TypeScript support

Installation

Install the package as a dependency using npm:

$ npm install @megh-computing/metadata-synchronizer

or, install using yarn:

$ yarn add @megh-computing/metadata-synchronizer

Example Usage

import type {ImageFrame} from "@megh-computing/image-frame-pool";
import {MetadataSynchronizer} from "@megh-computing/metadata-synchronizer";

...

// Handle up to 10 seconds of de-sync between video and metadata (at 30fps)
// const synchronizer = new MetadataSynchronizer(30 /*fps*/ * 10 /*seconds*/);
const synchronizer = new MetadataSynchronizer(30 /*fps*/ * 10 /*seconds*/, {
    // Optional frame memory management context for pooling and re-using frames
    clone(frame: ImageFrame): ImageFrame {
        return frame.clone();
    },
    release(frame: ImageFrame) {
        frame.release();
    },
});
// Configures the tolerance between timestamps before they are considered equal
synchronizer.setEqualityTolerance(0.001); // 1 millisecond
synchronizer.on("match", (frame: ImageFrame, metadata) => {
    // Render metadata over frame and display
});
synchronizer.on("frameDropped", (frame: ImageFrame) => {
    // Display frame with previous frame's metadata or no metadata at all
});
synchronizer.on("metadataDropped", (metadata) => {
    // Do something with unused metadata?
});
synchronizer.on("warning", (type: string, message: string) => {
    // By default, warnings will be printed to the console unless a handler is added
    if (type === "trim") {
        // Trim warnings indicate that capacity of queues has been reached,
        // and the matching performance may degrade due to missing frames or metadata
        console.warn("trim error:", message);
    } else {
        // Ignore other warnings
    }
});

...

// Simply append the frames and metadata to the synchronizer,
// and the synchronizer will emit the events configured above
synchronizer.appendFrame(frame, frameTimestamp);
synchronizer.appendMetadata(metadata, metadataTimestamp);

// The synchronizer requires that the timestamps are in ascending order,
// so if/when either stream restarts, then the synchronizer must be reset
synchronizer.resetFrame();
synchronizer.resetMetadata();

// The oldest metadata timestamp can be queried to help determine if the metadata stream has restarted,
// and therefore the metadata side of the synchronizer must be reset
const oldestMetadataTimestamp = synchronizer.getOldestMetadataTimestamp();
if (oldestMetadataTimestamp != null) {
    // Check if timestamp is less than oldest timestamp
    if (metadataTimestamp < oldestMetadataTimestamp) {
        // If so, then assume metadata has reset
        synchronizer.resetMetadata();
    }
}
synchronizer.appendMetadata(metadata, metadataTimestamp);

License

Copyright (c) 2021 Megh Computing, Inc.

All rights reserved. No warranty, explicit or implied, provided. Unauthorized use, modification, or distribution is strictly prohibited. Homepage: https://megh.com/

Please contact us if you use Megh VAS and would like to be issued a license to use this package.