Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including multistreamsmixer with all npm packages installed. Try it out:

var multistreamsmixer = require("multistreamsmixer")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

multistreamsmixer v1.2.2

Pass multiple streams (e.g. screen+camera or multiple-cameras) and get single stream.

MultiStreamsMixer.js | LIVE DEMO

  • Mix Multiple Cameras or Videos
  • Mix Multiple Microphones or Audios (Mp3/Wav/Ogg)
  • Mix Multiple Screens or Screen+Video
  • Mix Canvas 2D Animation + Camera + Screen

npm downloads Build Status: Linux

All Demos

  1. Main Demo:
  2. Record Multiple Cameras
  3. Record Camera+Screen

Pass multiple streams (e.g. screen+camera or multiple-cameras) and get single stream.

Link the library

<script src=""></script>

Or link specific build:


Or install using NPM:

npm install multistreamsmixer

And import/require:

const MultiStreamsMixer = require('multistreamsmixer');
import MultiStreamsMixer from 'multistreamsmixer';

How to mix audios?

const audioMixer = new MultiStreamsMixer([microphone1, microphone2]);

// record using MediaRecorder API
const recorder = new MediaRecorder(audioMixer.getMixedStream());

// or share using WebRTC

How to mix screen+camera?

screenStream.fullcanvas = true;
screenStream.width = screen.width; // or 3840
screenStream.height = screen.height; // or 2160 

cameraStream.width = parseInt((20 / 100) * screenStream.width);
cameraStream.height = parseInt((20 / 100) * screenStream.height); = screenStream.height - cameraStream.height;
cameraStream.left = screenStream.width - cameraStream.width;

const mixer = new MultiStreamsMixer([screenStream, cameraStream]);


mixer.frameInterval = 1;

btnStopStreams.onclick = function() {

btnAppendNewStreams.onclick = function() {

btnStopScreenSharing.onclick = function() {
    // replace all old streams with this one
    // it will replace only video tracks

How to mix multiple cameras?

const mixer = new MultiStreamsMixer([camera1, camera2]);


mixer.frameInterval = 1;


  1. getMixedStream: (function) returns mixed MediaStream object
  2. frameInterval: (property) allows you set frame interval
  3. startDrawingFrames: (function) start mixing video streams
  4. resetVideoStreams: (function) replace all existing video streams with new ones
  5. releaseStreams: (function) stop mixing streams
  6. appendStreams: (function) append extra/new streams (anytime)

TypeScript / Angular

import { MultiStreamsMixer } from 'yourPath/MultiStreamsMixer';
let mixer = new MultiStreamsMixer([stream1,stream2]);
let mixed = mixer.getMixedStream();

P.S: pollyfills are removed (except for AudioContext) use adapter instead.

Access <canvas> or <video> using querySelector

var canvas = document.querySelector('canvas.multi-streams-mixer');
var videos = document.querySelectorAll('video.multi-streams-mixer'); = .1;


// default elementClass is "multi-streams-mixer"
var instance = new MultiStreamsMixer(arrayOfMediaStreams, elementClass);

MultiStreamsMixer.prototype = {
    // get readonly MediaStream
    getMixedStream: function() {},

    // add more streams
    appendStreams: function(arrayOfMediaStreams) {},

    // replace with set of your own streams
    resetVideoStreams: function(arrayOfMediaStreams) {},

    // clear all the data
    clearRecordedData: function() {}


MultiStreamsMixer.js is released under MIT licence . Copyright (c) Muaz Khan.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free