Skip to content

Instantly share code, notes, and snippets.

@DanielKoohmarey
Last active January 22, 2022 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielKoohmarey/62508ed96e0d1a0bfb65674a4ab6e533 to your computer and use it in GitHub Desktop.
Save DanielKoohmarey/62508ed96e0d1a0bfb65674a4ab6e533 to your computer and use it in GitHub Desktop.
Force VP9 as WebRTC video codec
// note the following should be called before before calling either RTCPeerConnection.createOffer() or createAnswer()
let tcvr = pc.getTransceivers()[0];
let codecs = RTCRtpReceiver.getCapabilities('video').codecs;
let vp9_codecs = [];
// iterate over supported codecs and pull out the codecs we want
for(let i = 0; i < codecs.length; i++)
{
if(codecs[i].mimeType == "video/VP9")
{
vp9_codecs.push(codecs[i]);
}
}
// currently not all browsers support setCodecPreferences
if(tcvr.setCodecPreferences != undefined)
{
tcvr.setCodecPreferences(vp9_codecs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment