Flussonic Media Server Documentation

Contents

Transcoder

Transcoding is necessary if you want to:

  • create a multi-bitrate stream
  • change parameters of video — the codec and the bitrate of the stream, the size of the image
  • overlay a logo on top of a video stream.

Flussonic Media Server has a built-in transcoder. It supports transcoding by using a GPU or the CPU.

The Flussonic transcoder module supports the RTMP, RTSP, and MPEG2-TS protocols (over HTTP and UDP).

The HLS protocol is partially supported — some sources may fail to be transcoded. It is recommended to test each HLS source manually to find out whether it works after transcoding.

For hardware-accelerated transcoding, Flussonic can use Intel and Nvidia solutions. When transcoding with Nvidia NVENC, streams with a 10-bit color depth are supported.

Content:

Important!

Transcoding is an extremely computationally-intensive process, and it includes the following steps:

  1. Decoding of the source stream into raw video data.
  2. Processing and encoding of the raw stream according to the specified parameters.

Depending on the configuration, a single server can process from 5 to 20 channels.

Installing the transcoder

If you use an NVENC-capable Nvidia GPU to perform transcoding, you do not need to install any extra packages to enable transcoding (true for up-to date Flussonic versions).

If you use the CPU to perform transcoding, you will need to install the package flussonic-transcoder:

apt-get -y install flussonic-transcoder

This package can be found in the same repository as the flussonic package.

Setting up transcoding options in the configuration file

Transcoding options can be specified in stream settings in the Flussonic configuration file. Alternatively, the web UI can be used.

This section describes how to configure transcoding options by editing the /etc/flussonic/flussonic.conf configuration file.

Important! When changing transcoder options, you must specify them in the correct order. Global options go first, then video options, and then audio options. Below, you will find several common examples detailing the use of the transcoder options.

Transcoder options

  1. Enable the transcoder for the incoming stream as follows:

    stream origin {
      url fake://fake;
      push udp://239.0.0.1:1234;
    }
    stream example {
      url udp://239.0.0.1:1234;
      transcoder vb=2048k size=1280x720 preset=fast ab=128k;
    }
    

  2. Apply the new configuration with the command:

    service flussonic reload
    

Examples of stream transcoding parameters

The following examples show the correct order of transcoding options. Different kinds of options are shown in different colors:

  • blue – required parameters of video encoding
  • yellow – required parameters of audio encoding
  • white – optional parameters.

Configuring a single stream:

Transcoder parameters

vb=2048k preset=veryfast ab=128k

Configuring multi-bitrate streams:

Transcoder new

Example:

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

Transcoder options

Example:

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

Transcoder options for anamorphic video

The Flussonic transcoder supports anamorphic video streams by taking the pixel sizes ratio into account. This was possible by giving the size parameter a new interpretation and by adding the new parameter sar.

  • size is the size on a display — the number of output pixels that Flussonic passes to the player. The size option now includes width, height, the resize strategy (crop, fit, scale), and background color. Thus, you can set the size in one of the ways: size=WxH:fit:#ААFFEE, size=WxH:crop, or size=WxH:scale.

    The parameter size now means the size of a playback window on the screen rather than size of video in pixels of its internal representation. A pixel can have different width and height in different output formats. Previously, size was interpreted as pixel size, and the size of the playback window depended on a stream’s SAR or on the value of the aspect parameter.

  • sar in Flussonic is the ratio of the width of the display representation to the width of the pixel representation of video. The width of the display representation is the number of pixels on the matrix of the display, this is what Flussonic passes to the player for playback. And the width of the pixel representation is the number of pixels in the original YUV.

Learn more about how the transcoder treats the options size and sar in the list of transcoder options on this page.

Apart from size, the parameters aspect, force_original_aspect_ratio, and crop were changed:

  • aspect has been replaced with sar. Almost all transcoder types in Flussonic will interpret it as SAR (not DAR), the only exception is Nvidia NVENC.
  • force_original_aspect_ratio is no longer necessary, and, if it is required, it is added automatically.
  • The NVENC-only crop was added to almost all transcoder types in Flussonic (please don’t confuse it with the resizing strategy 'crop').

The transcoder settings that you configured in earlier versions will stay the same and processed as previously. The transcoder processes the parameters in a new way only if you specify new parameters — SAR or the resize strategy (or both) — while no deprecated parameters (force_original_aspect_ratio) were specified.

Setting up transcoding options in the web interface

The UI supports setting up the transcoding for both streams and publishing locations.

To set up the transcoder via the Flussonic web interface:

In Media > Streams or Media > Locations click the channel (stream) you want to transcode. Then go to the Transcoder tab and click Enable transcoder.

Use the arrows on the right side of the page to expand or collapse groups of settings.

Flussonic transcoder

Audio encoding settings

transcoding options

  • Copy from input — select this to get the same audio characteristics as in the input stream.
  • Bitrate — sets the audio bitrate.
  • Codec (aac|opus|mp2a) — audio codec (the AAC codec is used by default).
  • Sample rate (bypass|0|8000|16000|32000|44100|48000)
  • Channels — sets the number of audio channels in an output stream.

Global options (these will apply to all output video tracks)

transcoding options

  • Device — specifies the transcoding device. For Flussonic Media Server, enables hardware acceleration and specifies the model and ID of the NVENC graphics card. Hardware transcoding allows for more streams to be transcoded on a single server. For Coder, specifies the GPU used for transcoding the stream.

  • Deinterlace — activates deinterlacing mode. Deinterlacing is necessary for comfortable viewing of TV channels on desktop computers and mobile devices. This field lists the methods available for the selected transcoder type (CPU, Nvidia NVENC, or others). For Nvidia, this option represents two options in the configuration file ('deinterlace' and 'deinterlace_rate').

    For Nvidia, this option represents two options in the configuration file (deinterlace and deinterlace_rate) that are used together. There are the following relations between the selected value in the Deinterlace box and the values of the options in the configuration file:

    • off

      deinterlace=false, deinterlace_rate=frame

      Nvidia's deinterlace method — weave.

    • on

      deinterlace=true, deinterlace_rate=frame

      Nvidia's deinterlace method — adaptive.

    • on double rate

      deinterlace=true, deinterlace_rate=field

      Nvidia's deinterlace method — adaptive.

    • adaptive

      deinterlace=adaptive, deinterlace_rate=frame

      Nvidia's deinterlace method — adaptive.

    • adaptive double rate

      deinterlace=adaptive, deinterlace_rate=field

      Nvidia's deinterlace method — adaptive. * Crop after decoding — with the majority of transcoder types, you can crop the video. Cropping allows you to get only part of the image area in the output stream. There are 4 figures with the following meaning: Crop-X and Crop-Y — the coordinates of the upper left corner of the output video image, as compared to the input image (that is, (0,0) is the upper left corner of the input video image), Crop-Width — the width of the output image, and Crop-Height — the height of the output image.

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

* FPS — (Frames per second) frame rate.

**Important!** Transcoder options GOP and FPS are not per-track now but global for a stream. The coniguration file supports both old and new behavior: if in the configuration file these options follow the second or any subsequent video track, they apply locally to that track. If the options go after the very first video track or precede all tracks, then they apply to all tracks.

*

Improve the transcoder performance by running it as part of Flussonic (use with caution). By default, the transcoder runs in a separate process from Flussonic. This is the more reliable option. If you select the option Improve the transcoder performance by running it as part of Flussonic (or specify external=false in the configuration file), the transcoder will run in the same process as Flussonic Media Server. This mode speeds up encoding, especially when encoding audio or when using an Nvidia device. However, a transcoder error may cause Flussonic to crash.

Video encoding options

There are three ways to add a video track settings to the transcoder:

  • Click the button Add video track and (optionally) select a bitrate and height. * To get the same output video characteristics as in the input stream, turn on Copy from input.
  • Click Duplicate to add another track with the characteristics of the track that you have specified and want to duplicate.

Besides, you can copy entire transcoder settings to other streams.

transcoding options

After you have added a video track, you'll be able to edit its settings. To expand a track's transcoding settings, click the arrow:

transcoding options

All options are on a single screen:

transcoding options

  • Width — the picture width in pixels on the display where it will be played by a player.

  • Height — the picture height in pixels on the display where it will be played by a player.

  • SAR (X:Y) — the proportion of the video display width. The pixel width of the input video is multiplied by SAR (X:Y) to get the width on a display. This parameter is used to support non-standard display sizes, to calculate the width of the final image. It can be used in combination with the resize strategy. For Nvidia NVENC this parameter is interpreted as DAR (the ratio of player window's horizontal and vertical sizes). Learn more in the list of transcoder options

  • Resize — the strategy of resizing the video to the specified Height (and Width).

  • Background — the color of the area in the player that is not occupied by the video after resizing. It is used only with the 'fit' strategy.

  • Bitrate — specifies the bitrate of the video track.

  • Codec (H.264|H.265|MP2V) — sets the video codec. The default value is H.264.

  • Profile (baseline|main|high) — limits the output to a specific H.264 profile.

  • Interlace — used to get an interlaced stream from a progressive one. The Progressive value equals false, Interlaced equals true, the rest of the values are methods for producing interlaced video that are supported for the selected type of transcoder. Learn more about the interlace option in the list of transcoder options

  • Preset — affects video quality and download speed. Read more about presets in Preset on this page.

  • B-frames — the values 0|1|2|3 correspond to these sequences of frames: IP|IBP|IBBP|IBBBP.

  • Open GOP — 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 GOP size. This option applies only to encoding on CPU and it might help to reduce traffic a little bit.

  • Refs — (reference frames) used in inter-frame compression to refer to frames that follow. For better quality, use more reference frames.

  • Level — used for compatibility with old devices.

  • Logo

    To burn a logo into your video stream, specify the path to the file containing the logo and then choose where the logo will appear on the video. To use a single logo file for all output tracks, specify it in Logo, and the transcoder will resize it according to the size of each output video track. Learn more about logo in options.

    transcoding options

  • Extended — if the option you would like to add is missing on the screen, add it manually in Extended:

Saving or discarding your settings

To save the new values, click Save.

To delete all specified settings and turn off the transcoder for this stream, click Disable transcoder.

Copying the settings to other streams

To copy the settings to other streams:

  1. Go to the Transcoder tab of a stream where you have already configured the transcoder settings
  2. Click the button Copy settings
  3. Go to the Transcoder tab of the stream where you want to apply the same settings and click Enable and paste settings. If the stream already had transcoder configured, the button will be Paste settings.

Hardware transcoding

You can significantly increase the number of transcoded streams that the server can support by using a hardware transcoder.

Flussonic Media Server supports the Nvidia NVENC and Intel Quick Sync transcoding technologies.

One video stream can be transcoded using only one type of transcoder.

Read more about hardware transcoding in Hardware Transcoding with Nvidia NVENC and Intel Quick Sync Video.

Adding a logo

Flussonic Media Server can add a logo to your video:

Transcoder

Example:

vb=2048k preset=fast logo=/storage/logo.png@10:10 ab=128k

10:10 are the coordinates of the top left corner of the screen.

To place the logo in another part of the screen a slightly more complex formula should be written.

To place the logo in the center:

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

To place the logo in the bottom left corner:

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

To place logo in the top right corner:

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

To place the logo in the bottom right corner:

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

Important! Flussonic Media Server supports adding a logo only when using the CPU and NVENC encoders.

The preset option

Preset is a collection of options that will provide a certain encoding speed/compression ratio. A slower preset will provide better compression (compression is quality per file size).

This means that, for example, if you target a certain file size or constant bitrate, you will achieve better quality with a slower preset. Similarly, for constant quality encoding, you will simply save bitrate by choosing a slower preset.

List of supported presets:

  • veryfast
  • medium
  • slow

Smooth source switching

The Flussonic's transcoder can efficiently handle the changes in the characteristics of an input video stream. Smooth, or seamless, source switching means that the Flussonic's transcoder does not lose any frames when the stream source has changed and the media information has changed. The most common case is the change in the size of the picture in the new source to which the stream has switched. For example, when an ad of a different width and height is inserted into a stream, or when transcoding a server-side playlist consisting of files and streams of various resolutions. The loss of frames can be observed in the resulting stream as flickering or other artifacts.

If you transcode by using the CPU or Nvidia NVENC, seamless source switching is the default behavior. Starting from Flussonic 20.07, our CPU transcoder is able not to lose any frames at the change of a stream's media information.

However, for other hardware transcoders (Intel Quick Sync) it might be necessary to configure the seamless source switching. With the seamless=true option, the transcoder seamlessly switches to another source format without dropping any frames. This is achieved by keeping the initial size of video in the resulting stream. All sources will be transcoded to be the same size - this is the size specified in the option size. If the output size was not specified, the transcoder will transcode to the size of the source that goes first in the input stream.

Example (for transcoders except the CPU and NVENC):

stream STREAM_NAME {
  udp://239.0.0.1:5000;
  transcoder vb=3000k size=320x200 ab=copy hw=qsv seamless=true;
}

Transcoder options

Video options:

vb

vb (video bitrate) — specifies the video bitrate of the 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 — the same as the encoder preset in ffmpeg. Affects the quality and download speed. This option should be specified separately for each video stream. The default value is medium.

Example:

vb=2048k preset=fast ab=128k

Read more about presets below.

size

size — the size of output video on the display where it will be shown. Used together with the resize strategy (crop, fit, scale) and the background color of the areas that will not be filled by the video.

Example:

vb=2048k size=1280x720:fit:#000000 ab=128k

The parameter size now means the size of a playback window on the screen rather than size in pixels. Previously, size was interpreted as pixel size, and the size of the playback window depended on a stream’s SAR or on the value of the aspect parameter.

logo

logo — allows you to overlay a logo. The transcoder adds the logo before the video is resized as specified in the size option. This means that the logo can be visibly stretched if the size was changed significantly.

Example:

vb=2048k size=1280x720 logo=/storage/logo.png@10:10 ab=128k;

Learn more about the logo overlay settings later on this page.

alogo

alogo — allows you to overlay a logo. The transcoder adds the logo after the video was resized as specified in the size option. This measure prevents the logo picture from stretching that might occur when the logo option is used. You will need to prepare and specify a separate file with a logo for each size of the resulting video track.

Example:

vb=2048k size=1280x720 alogo=/path/to/file.png@10:10 ab=128k;

Learn more about the logo overlay settings later on this page.

vcodec

vcodec — allows you to set the video codec. The default value is H.264. Flussonic Media Server allows you to encode in H.265 (HEVC) or MP2V (MPEG -2 Video File). Specify this setting separately for each video stream.

It is not possible to use the MP2V when hardware transcoding.

Example:

vb=2014k vcodec=mp2v ab=128k

fps

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

Example:

vb=2048k fps=24 ab=128k

deinterlace

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

Example:

vb=2000k deinterlace=true deinterlace_rate=frame ab=128k

The UI box Deinterlace corresponds to this option.

deinterlace_rate

deinterlace_rate — when encoding with Nvidia NVENC, you can remove duplicate frames that were produced after deinterlacing, preventing increased bitrate.

  • deinterlace_rate=frame — the fps stays the same,
  • deinterlace_rate=field — the fps increases two times after transcoding.

Example:

vb=2000k deinterlace=true deinterlace_rate=frame ab=128k

In case of using the Nvidia both options (deinterlace and deinterlace_rate) are added in the configuration file when you select some value in the Deinterlace box in the UI. There are the following relations between the selected value in the Deinterlace box and the values in the configuration file:

  • off

    deinterlace=false, deinterlace_rate=frame

    Nvidia's deinterlace method — weave.

  • on

    deinterlace=true, deinterlace_rate=frame

    Nvidia's deinterlace method — adaptive.

  • on double rate

    deinterlace=true, deinterlace_rate=field

    Nvidia's deinterlace method — adaptive.

  • adaptive

    deinterlace=adaptive, deinterlace_rate=frame

    Nvidia's deinterlace method — adaptive.

  • adaptive double rate

    deinterlace=adaptive, deinterlace_rate=field

    Nvidia's deinterlace method — adaptive.

refs

refs — the number of reference frames. This option should be specified separately for each video stream.

Example:

vb=2000k refs=6 ab=128k

bframes

bframes — specifies the number of B-frames. When set to 0, this option disables b-frames. This may be necessary, for example, when broadcasting to RTSP. Specified separately for each video stream.

Example:

vb=2000k bframes=0 ab=128k

hw

hw — enables hardware transcoding. This option should be specified separately for each video stream.

Example:

vb=2048k hw=nvenc deviceid=1 ab=128k

crop

crop — crops the size of video.

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

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

Example:

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

sar

sar — modifies video aspect ratio. Used for creating non-anamorphic video from anamorphic video. Has replaced the deprecated aspect but does not copy the old behavior.

SAR in Flussonic's terminology is the ratio of the width of the display representation to the width of the pixel representation of video. The width of the display representation is the number of pixels on the matrix of the display, this is what Flussonic passes to the player for playback. And the width of the pixel (internal) representation is the number of pixels in the original YUV.

In the UI sar appears in advanced video options.

For the transcoder on CPU and Flussonic Coder aspect is now processed as SAR — meaning the proportions of video display. For the transcoder on Nvidia NVENC aspect is interpreted as DAR (the ratio of player window horizontal and vertical sizes) and processed as in earlier versions of Flussonic.

Important! Aspect ratio modification is not supported when transcoding with Intel QuickSync (the hw=qsv option).

Example:

vb=2048k sar=12:5 ab=128k

Flussonic calculates the output video resolution based on sar. A video with the internal pixel width of 720 and sar 16:11 will have the display width of 1048. A picture of this width, in display pixels, will appear when the stream is played back in players.

force_original_aspect_ratio (deprecated)

force_original_aspect_ratio=true — keeps the original aspect ratio by adding black bars (letterboxing and pillarboxing.) 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

gop=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 gop=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 gop. This option applies only to encoding on CPU (it is not available on hardware transcoders) and it might help reduce traffic a little bit.

Example:

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

interlace

interlace — is used for making an interlaced stream from a progressive one.

The option takes values: interlace=tff|bff|tff_separated|bff_separated|mbaff|true|false

If you enable this option without specifying the encoding method (that is, if you specify as follows — interlace=true), then for producing interlaced video Flussonic will use the default method (the default method depends on the transcoder type). You can also specify another supported method.

  • false - used by default, meaning that the output stream will be progressive.

  • tff - interlaced, top field first, interleaved field store. This method is used with hw=qsv, nvenc.

  • bff - interlaced, bottom field first, interleaved field store. This method is used with hw=qsv, nvenc.

  • tff_separated - interlaced, top field first, separated fields. This method is used with hw=qsv.

  • bff_separated - interlaced, top field first, separated fields. This method is used with hw=qsv.

  • mbaff- interlaced libx264 MBAFF method. This method is used only with hw=cpu.

  • true - enables encoding into interlaced video by using the default method for the encoder specified (mbaff is the default method for hw=cpu, tff is the default method for hw=qsv, hw=nvenc).

Examples:

vb=2048k interlace=bff hw=qsv deviceid=2

Using the default method (mbaff for hw=cpu):

vb=2048k interlace=true hw=cpu

rc_method

rc_method — is used for creating output video with constant bitrate suitable for broadcasting to television networks.

Actually, it is impossible to encode a video stream with constant bitrate due to different size of different types of frames. However, television requires a constant bitrate, and also the transmission channels have their requirements.

In Flussonic transcoder, we have solved a number of problems of making a video stream compatible with such requirements.

The Flussonic encoder uses a combination of techniques to 1) make all frames fit the allowed size; 2) if frames occupy less bytes than required — to fill frames with data up to the required size. In this way, Flussonic parses a stream to every single frame and produces fully DVB-C compliant streams.

The option takes values:

  • rc_method=cbr - the encoder will produce a DVB-C compliant stream.

  • rc_method=vbr - do not encode a stream to be DVB-C compliant.

Example:

transcoder vb=2048k rc_method=cbr

As for now, using this option consumes resources (one CPU core for one MPTS stream with CBR).

See also about where to use the options rc_method and interlace:

Audio options:

ab

ab — sets the audio bitrate. This option should be specified only once, even if there are several audio tracks. The value must always end with k.

Example:

vb=2048k ab=128k

acodec

acodec — sets an 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

Other options

seamless=true

seamless=true — prevents flickering that can occur when a stream's source or its media_info has changed, especially if the size of the picture in a new source is different than in the previous source.

When transcoding by using the CPU or Nvidia NVENC, this option with the value true can be omitted, since seamless switching occurs by default.

Details

Example:

transcoder vb=3000k size=1280x720 ab=copy seamless=true

b-pyramid=strict

b-pyramid=strict — helps achieve a smooth playback of DVB-T streams on devices with the MSD7802+MSB1236C chipset if you use the CPU-based transcoder with 'interlace=true'. This option sets the half-frame sequence in the interlaced video to 'top_first'.

Example:

transcoder vb=3000k size=1280x720 b-pyramid=strict interlace=true