Last active
January 22, 2022 05:07
-
-
Save DanielKoohmarey/62508ed96e0d1a0bfb65674a4ab6e533 to your computer and use it in GitHub Desktop.
Force VP9 as WebRTC video codec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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