This WebRTC sample shows how to use simulcast on a video application.
- Node v14+
- Clone this repository
git clone https://github.com/muriware/simulcast-in-webrtc.git
- Copy the
.env.example
file into a file named.env
in the server folder
cp .env.example server/.env
STATIC_DIR
tells the server where to the client files are located and does not need to be modified.
- Install dependencies
cd server && yarn
- Run the application
yarn start
- Go to
localhost:4242
to see the demo
Disable second layer
var sender = pc1.getSenders()[0];
var parameters = sender.getParameters();
parameters.encodings[1].active = false;
sender.setParameters(parameters);
Enable second layer
var sender = pc1.getSenders()[0];
var parameters = sender.getParameters();
parameters.encodings[1].active = true;
sender.setParameters(parameters);
Limit first layer bitrate to 100kbps, and second layer to 300kbps.
var sender = pc1.getSenders()[0];
var parameters = sender.getParameters();
parameters.encodings[0].maxBitrate = 100000;
parameters.encodings[1].maxBitrate = 300000;
sender.setParameters(parameters);
Set the resolution of the second layer to be a quarter of the original resolution.
var sender = pc1.getSenders()[0];
var parameters = sender.getParameters();
parameters.encodings[1].scaleResolutionDownBy = 4;
sender.setParameters(parameters);
Set the resolution of the second layer to be a half of the original resolution.
var sender = pc1.getSenders()[0];
var parameters = sender.getParameters();
parameters.encodings[1].scaleResolutionDownBy = 2;
sender.setParameters(parameters);
Limit the bandwidth available to 800kbps on the remote end
await pc1.setLocalDescription()
pc1.setRemoteDescription({type: 'answer', sdp: pc1.remoteDescription.sdp + "b=AS:800\r\n"})