{"id":15816618,"url":"https://github.com/muaz-khan/multistreamsmixer","last_synced_at":"2025-05-16T15:04:59.254Z","repository":{"id":41067134,"uuid":"99299963","full_name":"muaz-khan/MultiStreamsMixer","owner":"muaz-khan","description":"MultiStreamsMixer is a JavaScript library that allows you pass multiple streams (e.g. screen+camera or multiple-cameras) and get single stream.","archived":false,"fork":false,"pushed_at":"2022-06-16T03:35:01.000Z","size":87,"stargazers_count":447,"open_issues_count":24,"forks_count":110,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-15T17:48:40.403Z","etag":null,"topics":["audio","mediastream","mixer","multiple","multiple-audios","multiple-cameras","screen","video","webrtc"],"latest_commit_sha":null,"homepage":"https://www.webrtc-experiment.com/MultiStreamsMixer/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muaz-khan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-04T03:39:41.000Z","updated_at":"2025-05-12T01:26:23.000Z","dependencies_parsed_at":"2022-09-09T19:11:09.663Z","dependency_job_id":null,"html_url":"https://github.com/muaz-khan/MultiStreamsMixer","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muaz-khan%2FMultiStreamsMixer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muaz-khan%2FMultiStreamsMixer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muaz-khan%2FMultiStreamsMixer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muaz-khan%2FMultiStreamsMixer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muaz-khan","download_url":"https://codeload.github.com/muaz-khan/MultiStreamsMixer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553938,"owners_count":22090416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","mediastream","mixer","multiple","multiple-audios","multiple-cameras","screen","video","webrtc"],"created_at":"2024-10-05T05:06:03.749Z","updated_at":"2025-05-16T15:04:59.208Z","avatar_url":"https://github.com/muaz-khan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [MultiStreamsMixer.js](https://github.com/muaz-khan/MultiStreamsMixer) | [LIVE DEMO](https://www.webrtc-experiment.com/MultiStreamsMixer/)\n\n* Mix Multiple Cameras or Videos\n* Mix Multiple Microphones or Audios (Mp3/Wav/Ogg)\n* Mix Multiple Screens or Screen+Video\n* Mix Canvas 2D Animation + Camera + Screen\n* and **GET SINGLE STREAM!!**\n\n[![npm](https://img.shields.io/npm/v/multistreamsmixer.svg)](https://npmjs.org/package/multistreamsmixer) [![downloads](https://img.shields.io/npm/dm/multistreamsmixer.svg)](https://npmjs.org/package/multistreamsmixer) [![Build Status: Linux](https://travis-ci.org/muaz-khan/MultiStreamsMixer.png?branch=master)](https://travis-ci.org/muaz-khan/MultiStreamsMixer)\n\n# All Demos\n\n1. **Main Demo:** https://www.webrtc-experiment.com/MultiStreamsMixer/\n2. [Record Multiple Cameras](https://www.webrtc-experiment.com/RecordRTC/simple-demos/multi-cameras-recording.html)\n3. [Record Camera+Screen](https://www.webrtc-experiment.com/RecordRTC/simple-demos/video-plus-screen-recording.html)\n\n\u003e Pass multiple streams (e.g. screen+camera or multiple-cameras) and get single stream. \n\n# Link the library\n\n```html\n\u003cscript src=\"https://www.webrtc-experiment.com/MultiStreamsMixer.js\"\u003e\u003c/script\u003e\n```\n\nOr link specific build:\n\n* https://github.com/muaz-khan/MultiStreamsMixer/releases\n\nOr install using NPM:\n\n```sh\nnpm install multistreamsmixer\n```\n\nAnd import/require:\n\n```javascript\nconst MultiStreamsMixer = require('multistreamsmixer');\nimport MultiStreamsMixer from 'multistreamsmixer';\n```\n\n# How to mix audios?\n\n```javascript\nconst audioMixer = new MultiStreamsMixer([microphone1, microphone2]);\n\n// record using MediaRecorder API\nconst recorder = new MediaRecorder(audioMixer.getMixedStream());\n\n// or share using WebRTC\nrtcPeerConnection.addStream(audioMixer.getMixedStream());\n```\n\n# How to mix screen+camera?\n\n```javascript\nscreenStream.fullcanvas = true;\nscreenStream.width = screen.width; // or 3840\nscreenStream.height = screen.height; // or 2160 \n\ncameraStream.width = parseInt((20 / 100) * screenStream.width);\ncameraStream.height = parseInt((20 / 100) * screenStream.height);\ncameraStream.top = screenStream.height - cameraStream.height;\ncameraStream.left = screenStream.width - cameraStream.width;\n\nconst mixer = new MultiStreamsMixer([screenStream, cameraStream]);\n\nrtcPeerConnection.addStream(mixer.getMixedStream());\n\nmixer.frameInterval = 1;\nmixer.startDrawingFrames();\n\nbtnStopStreams.onclick = function() {\n    mixer.releaseStreams();\n};\n\nbtnAppendNewStreams.onclick = function() {\n    mixer.appendStreams([anotherStream]);\n};\n\nbtnStopScreenSharing.onclick = function() {\n    // replace all old streams with this one\n    // it will replace only video tracks\n    mixer.resetVideoStreams([cameraStreamOnly]);\n};\n```\n\n# How to mix multiple cameras?\n\n```javascript\nconst mixer = new MultiStreamsMixer([camera1, camera2]);\n\nrtcPeerConnection.addStream(mixer.getMixedStream());\n\nmixer.frameInterval = 1;\nmixer.startDrawingFrames();\n```\n\n# API\n\n1. `getMixedStream`: (function) returns mixed MediaStream object\n2. `frameInterval`: (property) allows you set frame interval\n3. `startDrawingFrames`: (function) start mixing video streams\n4. `resetVideoStreams`: (function) replace all existing video streams with new ones\n5. `releaseStreams`: (function) stop mixing streams\n6. `appendStreams`: (function) append extra/new streams (anytime)\n\n# TypeScript / Angular\n\n```javascript\nimport { MultiStreamsMixer } from 'yourPath/MultiStreamsMixer';\nlet mixer = new MultiStreamsMixer([stream1,stream2]);\nmixer.appendStreams(stream3);\nlet mixed = mixer.getMixedStream();\n```\n\nP.S: pollyfills are removed (except for `AudioContext`) use adapter instead.\n\n# Access `\u003ccanvas\u003e` or `\u003cvideo\u003e` using `querySelector`\n\n```javascript\nvar canvas = document.querySelector('canvas.multi-streams-mixer');\nvar videos = document.querySelectorAll('video.multi-streams-mixer');\n\ncanvas.style.opacity = .1;\n```\n\n# API\n\n```javascript\n// default elementClass is \"multi-streams-mixer\"\nvar instance = new MultiStreamsMixer(arrayOfMediaStreams, elementClass);\n\nMultiStreamsMixer.prototype = {\n\t// get readonly MediaStream\n\tgetMixedStream: function() {},\n\n\t// add more streams\n\tappendStreams: function(arrayOfMediaStreams) {},\n\n\t// replace with set of your own streams\n\tresetVideoStreams: function(arrayOfMediaStreams) {},\n\n\t// clear all the data\n\tclearRecordedData: function() {}\n};\n````\n\n## License\n\n[MultiStreamsMixer.js](https://github.com/muaz-khan/MultiStreamsMixer) is released under [MIT licence](https://github.com/muaz-khan/MultiStreamsMixer/blob/master/LICENSE) . Copyright (c) [Muaz Khan](https://MuazKhan.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuaz-khan%2Fmultistreamsmixer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuaz-khan%2Fmultistreamsmixer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuaz-khan%2Fmultistreamsmixer/lists"}