...
When OpenH264 codec is used for transcoding, it is possible to change bitrate of mixer output stream with the following parameter in flashphoner.properties file
Code Block | ||||
---|---|---|---|---|
| ||||
mixer_video_bitrate_kbps=2000 |
By default, mixer output stream bitrate is set to 2 Mbps. If a channel bandwith between server and viewer is not enough, bitrate can be reduced, for example
Code Block | language | bash|
---|---|---|
| ||
encoder_priority=OPENH264 mixer_video_bitrate_kbps=1500 |
If picture quality with default bitrate is low, or distortion occurs, it is recommended to rise mixer outout stream bitrate to 3-5 Mbps
Code Block | ||||
---|---|---|---|---|
| ||||
encoder_priority=OPENH264 mixer_video_bitrate_kbps=5000 |
Mixer
...
Sometimes it is necessary to reach a minimum (zero) padding between mixer stream puctures. To do this use the following parameter in flashphoner.properties file
Code Block | ||||
---|---|---|---|---|
| ||||
mixer_use_center_no_padding_layout=true |
In this case input stream pictures are placed in mixer output stream as close as possible:
This feature works only for input streams of equal resolution with the same aspect ratio.
Mixer output stream sound management
...
output stream sound management
By default, mixer output stream sound is encoded to Opus with sample rate 48 kHz. These settings may be changed using the parameters in flashphoner.properties file. For example, to use mixer output stream in SIP call the following value can be set:
Code Block | ||
---|---|---|
| ||
audio_mixer_output_codec=pcma
audio_mixer_output_sample_rate=8000 |
In this case, sound will be encoded to PCMA (alaw) with sample rate 8 kHz.
Using custom lossless videoprocessor for incoming streams handling
To handle mixer incoming streams, if additional bufferizing or audio and video tracks syncronizing is required for example, the custom lossless videoprocessor may be used. This feature is enabled with the following parameter in flashphoner.properties file
Code Block | ||
---|---|---|
| ||
mixer_lossless_video_processor_enabled=true |
The maximum size of mixer buffer in milliseconds is set with this parameter
Code Block | ||
---|---|---|
| ||
mixer_lossless_video_processor_max_mixer_buffer_size_ms=200 |
By default, maximum mixer buffer size is 200 ms. After filling this buffer, the custom lossless videoprocessor uses its own buffer and waits for mixer buffer freeing. The period of mixer buffer checking is set in milliseconds with this parameter
Code Block | ||
---|---|---|
| ||
mixer_lossless_video_processor_wait_time_ms=20 |
By default, the mixer buffer checking period is 20 ms.
Note that using the custom lossless videoprocessor may degrade realtime perfomance.
When custom lossless videoprocessor is used, it is necessary to stop mixer with REST query /mixer/terminate to free all consumed resources. Mixer can be stopped also by stopping all incoming streams, in this case mixer will stop when following timeout in milliseconds expires
Code Block | ||
---|---|---|
| ||
mixer_idle_timeout=60000 |
By default, mixer will stop after 60 seconds if there are no active incoming streams.
Mixer output stream layout management
By default, three mixer output stream layouts are implemented:
1. Grid layout
This layout can be enabled with the following parameter in flashphoner.properties file
Code Block | ||
---|---|---|
| ||
mixer_layout_class=com.flashphoner.media.mixer.video.presentation.GridLayout |
2. Zero padding grid layout
This layout can be enabled with the following parameter
Code Block | ||
---|---|---|
| ||
mixer_layout_class=com.flashphoner.media.mixer.video.presentation.CenterNoPaddingGridLayout |
and works for input streams of equal resolution with the same aspect ratio only
3. Desktop (screen sharing) layout
This layout is enabled if one of mixer input streams has a name defined in the following parameter
Code Block | ||
---|---|---|
| ||
mixer_video_layout_desktop_key_word=desktop |
By default, desktop
name is used for screen sharing stream.
Custom mixer layout implementation
For more fine tuning of mixer layout, custom Java class should be developed to implement IVideoMixerLayout
interface, for example
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package com.flashphoner.mixerlayout;
import com.flashphoner.sdk.media.IVideoMixerLayout;
import com.flashphoner.sdk.media.YUVFrame;
import java.awt.*;
import java.util.ArrayList;
public class TestLayout implements IVideoMixerLayout {
private static final int PADDING = 5;
@Override
public Layout[] computeLayout(YUVFrame[] yuvFrames, String[] strings, int canvasWidth, int canvasHeight) {
ArrayList<IVideoMixerLayout.Layout> layout = new ArrayList<>();
for (int c = 0; c < yuvFrames.length; c++) {
Point prevPoint = new Point();
Dimension prevDimension = new Dimension(canvasWidth, canvasHeight);
if (layout.size() > 0) {
prevPoint.setLocation(layout.get(c-1).getPoint());
prevDimension.setSize(layout.get(c-1).getDimension());
}
Point currentPoint = new Point((int) (prevPoint.getX()+prevDimension.getWidth()+PADDING),
(int)(prevPoint.getY()+prevDimension.getHeight()));
layout.add(new IVideoMixerLayout.Layout(currentPoint, new Dimension(canvasWidth/yuvFrames.length,
canvasHeight/yuvFrames.length), yuvFrames[c]));
}
return layout.toArray(new IVideoMixerLayout.Layout[layout.size()]);
}
} |
Then the class should be complied into byte code. To do this, create folder tree according to TestLayout class package name
Code Block | ||||
---|---|---|---|---|
| ||||
mkdir -p com/flashphoner/mixerlayout |
and execute the command
Code Block | ||||
---|---|---|---|---|
| ||||
javac -cp /usr/local/FlashphonerWebCallServer/lib/tbs-flashphoner.jar ./com/flashphoner/mixerlayout/TestLayout.java |
Now, pack the code compiled to jar file
Code Block | ||||
---|---|---|---|---|
| ||||
jar -cf testlayout.jar ./com/flashphoner/mixerlayout/TestLayout.class |
and copy this file to WCS libraries folder
Code Block | ||||
---|---|---|---|---|
| ||||
audio_mixer_output_codec=pcma
audio_mixer_output_sample_rate=8000 |
...
cp testlayout.jar /usr/local/FlashphonerWebCallServer/lib |
To use custom mixer layout class, set it to the following parameter in flashphoner.properties file
Code Block | ||
---|---|---|
| ||
mixer_layout_class=com.flashphoner.mixerlayout.TestLayout |
and restart WCS.
With this custom layout, mixer output stream for three input streams will look like:
Quick manual on testing
...