简体   繁体   English

使用原生 webRTC 将视频编解码器从 VP8 更改为 VP9

[英]Change video codec from VP8 to VP9 with native webRTC

I'm trying to figure out how to change the video codec on webRTC from vp8 to vp9, and do not find a suiting answer to this anywhere.我试图弄清楚如何将 webRTC 上的视频编解码器从 vp8 更改为 vp9,并且在任何地方都找不到合适的答案。 May someone lead/show me how its done?有人可以带领/告诉我它是如何完成的吗? Thanks谢谢

I think you would need to munge SDP to make it happen. 我认为你需要使用SDP来实现它。 To my understanding the idea is that the endpoints negotiate the best possible codecs to be used. 据我所知,这个想法是端点协商要使用的最佳编解码器。

The VP9 release news has some hints on how to change the preferred codec from VP8 to VP9 https://developers.google.com/web/updates/2016/01/vp9-webrtc?hl=en . VP9发布新闻提供了一些关于如何将首选编解码器从VP8更改为VP9的提示https://developers.google.com/web/updates/2016/01/vp9-webrtc?hl=en

As browsers start to support setCodecPreferences<\/a> , you can check for the mimetype of the codec you want to use by default to set the codec preference.随着浏览器开始支持setCodecPreferences<\/a> ,您可以检查默认情况下要使用的编解码器的 mimetype 以设置编解码器首选项。 For example if you want to prefer vp8 for video you can check for the "video\/vp8" mimetype and set your codec preferences to vp8 codecs:例如,如果您希望将 vp8 用于视频,您可以检查“video\/vp8”mimetype 并将您的编解码器首选项设置为 vp8 编解码器:

// 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 vp8_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/VP8")
   {
      vp8_codecs.push(codecs[i]);
   }
}
// currently not all browsers support setCodecPreferences
if(tcvr.setCodecPreferences != undefined)
{
   tcvr.setCodecPreferences(vp8_codecs);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM