Flussonic Media Server documentation

Transcoder

Transcoding is necessary to create a multi-bitrate stream, or to change the codec, the bitrate of the stream, the size of the image and the overlay of the logo.

Flussonic Media Server has a built-in transcoder.

Content:

The following protocols are supported: RTMP, RTSP, MPEG-TS (HTTP and UDP).

The HLS protocol is partially supported - some sources may fail to be transcoded. Efficiency of transcoding of an HLS source should be tested for each individual source.

Important!

Transcoding is an extremely resource-intensive CPU-based process and it includes the following steps:

  1. Decoding of the source stream.
  2. Processing and coding of the raw stream according to the specified parameters.

Depending on the configuration, the number of channels per server may vary between 5 and 20.

Installation Anchor Anchor x2

Install the flussonic-ffmpeg package from the same repository as the flussonic package.

apt-get -y install flussonic-ffmpeg

Configuration Anchor Anchor x2

In the config file /etc/flussonic/flussonic.conf

The transcoder is set as a text string in the configuration file /etc/flussonic/flussonic.conf or in the administrative interface.

Important! Please note that to activate the transcoder it is important to follow the sequence of options. First, you specify all video parameters, then global options, and then audio options. In the examples below, we show the correct layout of options.

Transcoder options

The transcoder for the incoming stream in the /etc/flussonic/flussonic.conf configuration file is included as follows:

stream ort {
  url  udp://239.0.0.1:5000;
  transcoder vb=2048k size=1280x720 preset=fast ab=128k;
}

Do not forget to apply new configuration via command: /etc/init.d/flussonic reload

In the administrator interface

To enable the transcoder via the Flussonic Media Server administrative interface:

  • In the «Media» menu, select the channel you want to set up transcoding.
  • Go to the «Process» tab.
  • In the «Option for transcoding» line enter the options in the format like this vb=2048k size=1280x720 preset=fast ab=128k
  • Click «Save».

Transcoder

Examples of stream transcoding parameters Anchor Anchor x2

Example of settings one stream:

Transcoder parameters

vb=2048k preset=fast ab=128k

Examples of configuring multi-bitrate stream parameters:

Transcoder new

Example:

vb=2048k preset=fast vb=700k size=720x576 preset=fast vb=300k size=320x240 preset=fast ab=128k

Transcoder price

Example:

vb=copy vb=1600k size=1280x720 preset=fast vb=400k size=640x480 preset=fast ab=copy

Options Anchor Anchor x2

Video options:

vb

vb — (video bitrate) — parameter that specifies the video bitrate track. It is specified as a numerical value (1000k, 1500k, 2000k, etc). The value must always end with k. Each vb option creates a new video track in the output stream.

Example:

vb=2048k ab=128k

The option vb=copy saves the parameters of the original stream, that is, it is simply copied to the outgoing stream.

preset

preset — same as encoder preset in ffmpeg. Affects the quality and download speed. Indicated separately for each video stream. The default is medium.

Example:

vb=2048k preset=fast ab=128k

Read more about presets below.

size

size — video size. Indicated separately for each video stream.

Example:

vb=2048k size=1280x720 ab=128k

logo

logo — allows you to overlay the logo.

Example:

vb=2048k preset=fast logo=/path/to/file.png@10:10 ab=128k;

Learn more about the logo overlay settings below.

vcodec

vcodec — allows you to set the video codec. Default value is H.264. Flussonic Media Server allows you to encode in H.265 (hevc) or mp2v.

Indicated separately for each video stream.

Example:

vb=2014k vcodec=mp2v ab=128k

fps

fps — frame rate. Indicated separately for each video stream.

Example:

vb=2048k fps=25 ab=128k

deinterlace

deinterlace — activate deinterlacing. Deinterlacing is necessary for comfortable viewing of TV on PC / mobile devices. It is specified once and acts immediately on all video streams.

Example:

vb=2000k deinterlace=1 ab=128k

refs

refs — number of reference frames. Indicated separately for each video stream.

Example:

vb=2000k refs=6 ab=128k

bframes

bframes — disable b-frames. This may be necessary, for example, when broadcasting to RTSP. Indicated separately for each video stream.

Example:

vb=2000k bframes=0 ab=128k

hw

hw — enable hardware transcoding. Indicated separately for each video stream.

Example:

vb=2048k hw=nvenc ab=128k

crop

crop — crop video. Available only with hardware transcoding: hw=nvenc. Indicated separately for each video stream.

Usage: crop = x: y: width: height:

  • x:y — is the coordinates of the upper-left corner of the output video within the input video.
  • width — output video width.
  • height — height of the output video.

Example:

vb=2048k hw=nvenc crop=0:0:100:100 ab=128k

aspect

aspect — modifies video aspect ratio. Specify this setting separately for each video stream.

Important! Aspect ratio modification is not compatible with the hw=qsv option at this moment.

Example:

vb=2048k hw=nvenc aspect=12:5 ab=128k

force_original_aspect_ratio

force_original_aspect_ratio=true — keeps an original video aspect rate by adding black pads. This option is useful when you want to keep output resolution while switching between sources with different parameters.

Example:

vb=2048k size=1280x720 force_original_aspect_ratio=true

g

g=150 — sets the number of frames in a GOP. The encoder will create all GOPs of an exactly identical size — as specified in this option.

Example:

vb=2048k fps=25 size=1280x720 g=150

If you use encoding on CPU, you can use the disable_cgop option in addition to this option. It allows the transcoder to vary the GOP size slightly.

disable_cgop

disable_cgop=1 — allows an open GOP, meaning that the transcoder will divide an output stream into GOPs with slightly different number of frames, but close to the number specified in g. This option applies only to encoding on CPU (by contrast to hardware transcoders) and it might help to reduce traffic a little bit.

Example:

vb=2048k fps=25 size=1280x720 g=150 disable_cgop=1

Any ffmpeg options for video

For example -profile:v high -level 4.1 in Flussonic config would look as follows: profile=high level=4.1.

Audio options:

ab

ab — audio bitrate. Specify it only once, even if there are several audio tracks. The value must always end with k.

Example:

vb=2048k ab=128k

acodec

acodec — audio codec. Accepts the following values: ac3, mp2a. By default all audio tracks are encoded with AAC.

Example:

vb=2014k vcodec=mp2v ab=128k acodec=mp2a

ar

ar — sample rate.

Example:

vb=2014k ab=128k ar=44100

ac

ac — the number of audio channels.

Example:

vb=2014k ab=128k ac=1

Hardware transcoding Anchor Anchor x2

You can seriously increase the number of transcoded streams on the server by using a hardware transcoder.

Flussonic Media Server supports Nvidia NVENC and Intel Quick Sync Video.

Read more about hardware transcoder here.

Add logo Anchor Anchor x2

Flussonic Media Server can add a logo to the video:

Transcoder

Example:

vb=2048k preset=fast logo=/path/to/file.png@10:10 ab=128k

10:10 are coordinates of the top left corner of the screen. To place a logo in another part of the screen a slightly more complex formula should be written. To place logo in the center:

vb=2048k preset=fast logo=/path/to/file.png@(main_w-overlay_w-10)/2:(main_h-overlay_h-10)/2 ab=128k

To place logo in the bottom left corner:

vb=2048k preset=fast logo=/path/to/file.png@10:(main_h-overlay_h-10) ab=128k

To place logo in the top right corner:

vb=2048k preset=fast logo=/path/to/file.png@(main_w-overlay_w-10):10 ab=128k

To place logo in the bottom right corner:

vb=2048k preset=fast logo=/path/to/file.png@(main_w-overlay_w-10):(main_h-overlay_h-10) ab=128k

Important! Flussonic Media Server can add logo with CPU and NVENC encoders.

Preset option Anchor Anchor x2

Preset - is a collection of options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression (compression is quality per filesize). This means that, for example, if you target a certain file size or constant bit rate, you will achieve better quality with a slower preset. Similarly, for constant quality encoding, you will simply save bitrate by choosing a slower preset.

Use the slowest preset that you have patience for. There are following values: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Default value is medium.

placebo is not very helpfull, ignore it.