webRTC: How to tell Opus codec to use super wide band/full band

不想你离开。 提交于 2021-02-18 12:26:52

问题


I am working on a webRTC web application which works wonderfully so far. What I have not figured out yet is how to tell the Opus codec to (force) use "full band", for example.

Setting the codec up for 510 kHz bit rate is easy:

desc.sdp=desc.sdp.replace(/a=mid:audio\r\n/g,'a=mid:audio\r\nb=AS:510\r\n');

But is there a way to tell Opus which band to use?


回答1:


Specifying the band is not that bad. With opus, you just specify the MAX rate capabilities and let it run from there. By default OPUS goes to its max capabilities(48000, aka fullband).

Also, keep in mind that rtp clock rate must be 48000 no matter what capture rate you specify.

The below examples are taken from the rfc section-7.

m=audio 54312 RTP/AVP 101
a=rtpmap:101 opus/48000/2
a=fmtp:101 maxplaybackrate=16000; sprop-maxcapturerate=16000

That specifies a max capture and play back rate for the sender of 16kHz (aka Wideband).

Two-way full band stereo

m=audio 54312 RTP/AVP 101
a=rtpmap:101 opus/48000/2
a=fmtp:101 stereo=1; sprop-stereo=1

The options that you will be most concerned with if you want to specify the prefered band are:

  • maxplaybackrate: a hint about the maximum output sampling rate that the receiver is capable of rendering in Hz.
  • sprop-maxcapturerate: a hint about the maximum input sampling rate that the sender is likely to produce.

The different bands and their respected max:

  • NB: 8 kHz
  • MB: 12 kHz
  • WB: 16 kHz
  • SWB: 24 kHz
  • FB: 48 kHz //the codec default in webrtc

Also, note, there is a difference between Bitrate and Sample Rate. You modified the bitrate which may have forced Opus to change the sample rate but the options I have showed do not modify the bitrate at all and only change the sample rate.

Post Script, all this is contingent on the webrtc implementation and if it actually cares about what is specified in the SDP and if it actually effects the opus encoding/decoding. I have noticed(in the past, it very well may have changed) that the implementation in Firefox couldn't care less about what is in the SDP and just does what it wants by default.



来源:https://stackoverflow.com/questions/32473078/webrtc-how-to-tell-opus-codec-to-use-super-wide-band-full-band

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!