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

studio-merger

v1.1.11

Published

Multi-Source MediaStream, Video, Image, and Audio merger

Downloads

70

Readme

StudioMerger

StudioMerger is a TypeScript library that allows you to merge various media sources, including audio files, video files, image files, and MediaStreams, into a single media output (MediaStream).

It is designed to support multiple types of inputs, such as live audio/video streams, files, and captures from the screen, browser, or window.

Features

  • Multi-Source Merging: Combine multiple media sources like audio streams, video inputs, and image files.
  • Flexible Positioning: Control the position and dimensions of each media source in the final output.
  • Type Safety: Leveraging TypeScript's strong typing system for safer and more predictable code.
  • Works even on background tabs: Uses rxjs to run even on background tabs managing asynchronous data streams.

Installation

To install the package, use npm or yarn:

npm install studio-merger
// or
yarn add studio-merger

Usage

Here’s a basic example of how to use StudioMerger:

  import StudioMerger, { MergerSource, MergerOptions } from 'studio-merger';
  
  const options: MergerOptions = { debug: true };
  const studio = new StudioMerger(options);
  
  const videoSource: MergerSource = {
      id: 'sampleVideo', // OPTIONAL, package will provide an unique id for each source if it's not passed 
      name: 'Sample Video',
      type: 'visual', // 'visual': like image, video, camera stream, or screen stream | 'sound': like audio file, or mic stream.
      kind: 'videofile',
      source: await navigator.mediaDevices.getUserMedia({ video: true }),  // HTMLVideoElement or MediaStream
      position: { x: 0, y: 0, w: 640, h: 480 }, // OPTIONAL, if you don't pass positions, package will auto grid added 'visual' sources inside canvas
  };
  
  studio.addSource(videoSource);

As soon as you add your first source, either 'visual' or 'sound', StudioMerger will start working.

API

StudioMerger

constructor(options: MergerOptions)

  • Initializes a new instance of StudioMerger.
  • Parameters:
    • options: An object containing configuration options.
    • For now, it's only contains debug, If set to true, it will send capture and log WebGL errors.
  • addSource(source: MergerSource): void
    • Adds a new media source to the merger.
    • source: The media source to add, type of MergerSource.
      type MergerSource = {
        id?: string;
        index?: number;
        source: MediaStream | HTMLImageElement | HTMLVideoElement | HTMLAudioElement;
        name: string;
        type: SourceType;
        kind: SourceKind;
        position?: MergerPosition;
      }
  • removeSource(id: string): void
    • Remove a source
  • getSources()
    • Returns the list of all added sources into merger
  • updateIndex(id: string, index: number)
    • Updates the index of a visual source on canvas. Use it to push forward or backward the sources that are shown on each other.
  • updatePosition(id: string, position: MergerPosition)
    • Updates the position of visual source on canvas.
  • setOutputSize(width: number, height: number)
    • Updates the output size of canvas, default is 1920x1080.
  • destroy()
    • Destroys the whole process of StudioMerger and release all sources.
    • Once destroyed, you can use it again. You will have to create a new studio, new StudioMerger().

Types

  • SourceType = 'visual' | 'sound';
  • SourceKind = 'audioinput' | 'videoinput' | 'displaycapture' | 'windowcapture' | 'browsercapture' | 'videofile' | 'audiofile' | 'imagefile';
  • MergerPosition = { x: number; y: number; w: number; h: number; };
  • MergerSource
    • Represents a media source to be merged.
    • Properties:
      • id: Optional, unique identifier for the source.
      • index: Optional, index of the source shown on canvas.
      • name: Name of the source.
      • type: SourceType, Type of the source, either visual or sound.
      • kind: SourceKind, Kind of source.
      • position: MergerPosition,
        • Optional, Position and size of the source in the final output.
        • If not passed, The package will automatically calculate and add sources in grid style.