问题描述
我正在开发一个 webRTC 网络应用程序,到目前为止它运行良好.例如,我还没有弄清楚如何告诉 Opus 编解码器(强制)使用全频带".
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.
为 510 kHz 比特率设置编解码器很容易:
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');
但是有没有办法告诉 Opus 使用哪个乐队?
But is there a way to tell Opus which band to use?
推荐答案
指定乐队并没有那么糟糕.使用 opus,您只需指定 MAX 速率功能并让它从那里运行.默认情况下,OPUS 会使用其最大容量(48000,又名全频带).
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).
此外,请记住,无论您指定什么捕获速率,rtp 时钟速率都必须为 48000.
Also, keep in mind that rtp clock rate must be 48000 no matter what capture rate you specify.
m=audio 54312 RTP/AVP 101
a=rtpmap:101 opus/48000/2
a=fmtp:101 maxplaybackrate=16000; sprop-maxcapturerate=16000
这指定了 16kHz(又名宽带)发送器的最大捕获和播放速率.
That specifies a max capture and play back rate for the sender of 16kHz (aka Wideband).
双向全频段立体声
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:关于最大输出采样率的提示接收器能够以 Hz 为单位进行渲染.
- sprop-maxcapturerate:关于最大输入采样率的提示发件人可能会产生.
不同的乐队及其受人尊敬的最大值:
The different bands and their respected max:
- 注意:8 kHz
- MB:12 kHz
- 白平衡:16 kHz
- SWB:24 kHz
- FB: 48 kHz//webrtc 中的默认编解码器
另外,请注意,比特率和采样率之间存在差异.您修改了比特率,这可能迫使 Opus 更改采样率,但我展示的选项根本不修改比特率,仅更改采样率.
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,所有这些都取决于 webrtc 的实现,以及它是否真的关心 SDP 中指定的内容,以及它是否真的影响了 opus 的编码/解码.我注意到(过去,它很可能已经改变了)Firefox 中的实现并不关心 SDP 中的内容,并且默认情况下只是做它想要的.
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.
这篇关于webRTC:如何告诉 Opus 编解码器使用超宽带/全频段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!