When setting up SDP for high-quality Opus audio transmission, several key factors should be considered. The following steps and recommendations will help achieve optimal audio quality:
1. Choose the Right Bitrate
The Opus encoder supports a bitrate range from 6 kbps to 510 kbps. For high-quality audio, a recommended bitrate of 64 kbps to 128 kbps is typically used. In SDP, this can be set using the maxaveragebitrate parameter:
sdpa=fmtp:111 maxaveragebitrate=128000
In this example, 111 is the default payload type for Opus in SDP.
2. Use Appropriate Bandwidth and Frame Size
Frame size impacts both latency and audio quality. While larger frame sizes enhance encoding efficiency, they also increase latency. Common frame sizes are 20ms, 40ms, and 60ms. This can be set in SDP:
sdpa=ptime:20
Here, ptime is set to 20 milliseconds, meaning each RTP packet contains 20 milliseconds of audio data.
3. Enable Stereo
For audio content with stereo information, enabling stereo can significantly enhance audio quality. In SDP, stereo can be enabled using the sprop-stereo parameter:
sdpa=fmtp:111 stereo=1;sprop-stereo=1
This configuration allows Opus to transmit audio using two channels.
4. Set Appropriate Complexity
The complexity setting of the Opus encoder influences CPU usage and encoding quality. In SDP, this can be controlled via maxcodedaudiobandwidth:
sdpa=fmtp:111 maxcodedaudiobandwidth=fullband
Here, setting it to fullband means the encoder will utilize the widest possible audio bandwidth to enhance audio quality.
5. Consider Packet Loss Concealment
In poor network conditions, enabling packet loss concealment is an effective method to improve audio quality. Opus includes built-in packet loss concealment (PLC), which can be enabled in SDP via the useinbandfec parameter:
sdpa=fmtp:111 useinbandfec=1
This enables Opus's FEC (Forward Error Correction) to recover audio data when packets are lost.
Conclusion
By applying these settings, SDP configuration can be optimized to ensure high-quality Opus audio streams across various network and system conditions. These configurations are essential for achieving high-quality audio transmission in voice and music applications. In practice, adjustments may be necessary based on specific requirements and conditions.