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
- and GET SINGLE STREAM!!
All Demos
- Main Demo: https://www.webrtc-experiment.com/MultiStreamsMixer/
- Record Multiple Cameras
- Record Camera+Screen
Pass multiple streams (e.g. screen+camera or multiple-cameras) and get single stream.
Link the library
Or link specific build:
Or install using NPM:
npm install multistreamsmixer
And import/require:
const MultiStreamsMixer = ;;
How to mix audios?
const audioMixer = microphone1 microphone2; // record using MediaRecorder APIconst recorder = audioMixer; // or share using WebRTCrtcPeerConnection;
How to mix screen+camera?
screenStreamfullcanvas = true;screenStreamwidth = screenwidth; // or 3840screenStreamheight = screenheight; // or 2160 cameraStreamwidth = ;cameraStreamheight = ;cameraStreamtop = screenStreamheight - cameraStreamheight;cameraStreamleft = screenStreamwidth - cameraStreamwidth; const mixer = screenStream cameraStream; rtcPeerConnection; mixerframeInterval = 1;mixer; btnStopStreams { mixer;}; btnAppendNewStreams { mixer;}; btnStopScreenSharing { // replace all old streams with this one // it will replace only video tracks mixer;};
How to mix multiple cameras?
const mixer = camera1 camera2; rtcPeerConnection; mixerframeInterval = 1;mixer;
API
getMixedStream
: (function) returns mixed MediaStream objectframeInterval
: (property) allows you set frame intervalstartDrawingFrames
: (function) start mixing video streamsresetVideoStreams
: (function) replace all existing video streams with new onesreleaseStreams
: (function) stop mixing streamsappendStreams
: (function) append extra/new streams (anytime)
TypeScript / Angular
;let mixer = stream1stream2;mixer;let mixed = mixer;
P.S: pollyfills are removed (except for AudioContext
) use adapter instead.
<canvas>
or <video>
using querySelector
Access var canvas = document;var videos = document; canvasstyleopacity = 1;
API
// default elementClass is "multi-streams-mixer"var instance = arrayOfMediaStreams elementClass; MultiStreamsMixerprototype = // get readonly MediaStream {} // add more streams {} // replace with set of your own streams {} // clear all the data {};
License
MultiStreamsMixer.js is released under MIT licence . Copyright (c) Muaz Khan.