GithubHelp home page GithubHelp logo

siathalysedi / streamswitcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from meething/streamswitcher

0.0 2.0 0.0 4.83 MB

Allows MediaStream to switch tracks without setting srcObject this allows MediaRecording to continue recording

Home Page: https://meething.github.io/StreamSwitcher/

CSS 5.51% HTML 13.15% JavaScript 81.35%

streamswitcher's Introduction

StreamSwitcher

Allows MediaStream to switch tracks without setting srcObject this allows MediaRecording to continue recording.

Problem

The MediaRecorder is designed to stop recording when you switch streams during recording.

Solution

Use RTCPSender to switch stream without MediaRecorder to stop recording. Another solution would be using MediaSourceBuffers but that is way more error sensitive in case of different codes etc..

Result

A stream where you switch for instance camera with screenshare and back without need to stop and start the MediaRecorder

How to use it

HTML file

<head>
<script src="https://cdn.jsdelivr.net/gh/meething/StreamSwitcher@latest/js/ReplaceableMediaStream.js"></script>
</head>

JS file

//Setup video with empty stream
var temporaryStream = new MediaStream();
video.srcObject = temporaryStream.remoteStream;

//Change the track from a stream
video.srcObject.replaceVideoTrack(stream.getVideoTracks()[0])//Video
video.srcObject.replaceAudioTrack(stream.getAudioTracks()[0])//Audio

//If not autoplay
video.play();

Resource

streamswitcher's People

Contributors

qvdev avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.