- Backup before tuning
- Use x86_64 architecture in production environment
- System timer precision
- Enable thread priorities mapping
- Start Wowza server as root
- Set TcpNoDelay and QoS lowlatency for RTMP
- Set QoS lowlatency for RTP
- Configure outgoing RTMP stream
- Configure incoming RTMP stream
- Configure quality - latency balance
- Configure jitter buffer on VoIP server or SIP endpoint
- Speex voice quality tuning
- Downstream is a stream from Flash-Server to Flash-client
- Upstream is a stream from Flash-client to Flash-Server
- Yasm video optimization
Flashphoner works in complex environment. This is a tuning guide, which helps you to adjust quality and performance in your environment.
Backup SERVER_HOME dir before tuning
You can restore you default parameters in this case.
[quality, performance, memory]
Use 64-bit system if it is possible.
Use highest available system timer on Linux. We have tested our system with such kernel parameters:
Example - configuring of kernel 22.214.171.124 for CentOS 5.5, Centos 5.6:
Example - Red Hat Enterprise Linux 6 x86_64 has such kernel parameters by default.
Configure setenv.sh as described here: http://www.wowzamedia.com/forums/content.php?5-general-tuning [5,6,13]
So, your config should look like this:
Thread priorities may impact on quality of audio-video conversation.
This settings gives Flashphoner permissions to set priority for internal threads.
If java process started as non-root user, Linux does not use thread priority mapping.
You can avoid starting the server as root. See this workaround: http://www.akshaal.info/2008/04/javas-thread-priorities-in-linux.html
Also, look latest JVM documentation here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Set TcpNoDelay and QoS lowlatency for RTMP sockets.
Configure VHost.xml file as described on this page http://www.wowzamedia.com/forums/content.php?5-general-tuning [7,11]
We believe, this socket configuration may impact on latency in some cases.
Flashphoner use buffering of incoming and outgoing stream to adjust quality and drop packets if latency is too big.
|in_jitter_buffer_enabled||true/false||false||Enables/disables using of jitter buffer algorithms for incoming streams|
||true/false||true|| Enables/disables using of jitter buffer algorithms for outgoing streams
||percents||0.5||If current drop rate < min_drop rate, we decrease queue size and decrease latency|
||percents||1||If current drop rate > max_drop_rate, we increase queue size and increase latency, but up to max_queue_size maximum|
||packets||10||Minimum queue size|
||packets||50||Maximum queue size. Latency may grow up to max_queue_size. Then packets will be dropped regardless max_drop_rate|
Note, system timer precision tuning is mandatory for using this options.
Jitter buffer is a thread which flush audio packets every 20ms, using system timer.
If your system timer is not configured properly, you may get worse or unacceptable quality, using jitter buffer.
Jitter buffer may reduce voice chopping and give smoothly conversation.
If you have problems with voice quality, you can setup jitter buffer for your VoIP server, if VoIP server located in your environment of course.
Example of configuring jitter buffer for Asterisk 1.6
This example uses fixed implementation of jitter buffer with 200 milliseconds size.
Please, consult with your VoIP server documentation to configure jitter buffer properly.
Flashphoner uses speex codec for RTMP downstreams and RTMP upstreams.
Some quotes from speex documentation:
Speex is a lossy codec, which means that it achives compression at the expense of fidelity of the input speech signal. Unlike
some other speech codecs, it is possible to control the tradeoff made between quality and bit-rate. The Speex encoding process
is controlled most of the time by a quality parameter that ranges from 0 to 10. In constant bit-rate (CBR) operation, the quality
parameter is an integer, while for variable bit-rate (VBR), the parameter is a float.
With Speex, it is possible to vary the complexity allowed for the encoder. This is done by controlling how the search is
performed with an integer ranging from 1 to 10 in a way that's similar to the -1 to -9 options to gzip and bzip2 compression
utilities. For normal use, the noise level at complexity 1 is between 1 and 2 dB higher than at complexity 10, but the CPU
requirements for complexity 10 is about 5 times higher than for complexity 1. In practice, the best trade-off is between
complexity 2 and 4, though higher settings are often useful when encoding non-speech sounds like DTMF tones.
Variable Bit-Rate (VBR)
Variable bit-rate (VBR) allows a codec to change its bit-rate dynamically to adapt to the "difficulty" of the audio being
encoded. In the example of Speex, sounds like vowels and high-energy transients require a higher bit-rate to achieve good
quality, while fricatives (e.g. s,f sounds) can be coded adequately with less bits. For this reason, VBR can achive lower bit-rate
for the same quality, or a better quality for a certain bit-rate. Despite its advantages, VBR has two main drawbacks: first, by
only specifying quality, there's no guaranty about the final average bit-rate. Second, for some real-time applications like voice
over IP (VoIP), what counts is the maximum bit-rate, which must be low enough for the communication channel.
Since patch Flashphoner-126.96.36.1992-p.760 you able to configure policy for the downstream on server-side. See table below:
|Policy name||quality||VBR enabled||VBR quality||Algorithm complexity|
Default policy is "good".
Edit server-side flashphoner.properties file:
You can use custom policy too:
|Higher policies like ultimate policy may increase CPU usage and cause the latency grow. But it gives higher sound quality|
in client-side SoundControl.as
It may optimize video encoding to decrease CPU usage and increase performance.
Get yasm. Yasm is a modular assembler that will optimize video encoding for MMX/SSE.
You can download yasm here
Use simple magic to install it:
|You should install yasm BEFORE you install Flashphoner|
If the Flashphoner has already installed, you need to do 3 steps:
- Uninstall Flashphoner
- Install yasm
- Install Flashphoner