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.

Content:

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.

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. The video options go first, then the global options, and then the 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 ort {
      url udp://239.0.0.1:5000;
      transcoder vb=2048k size=1280x720 preset=fast ab=128k;
    }
    
  2. Apply the new configuration with the command:

    /etc/init.d/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=fast 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

Recent changes in transcoder options

Important.

We modified our transcoder to make all our transcoder types process options in the same way and to support 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.

Changes in versions starting from 20.03:

  • 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.

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

  • aspect is not recommended to use, it will be replaced with sar in future versions. Almost all transcoder types in Flussonic will interpret it as SAR (not DAR), the only exception is Nvidia NVENC. See aspect in the reference list on this page.
  • 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 before 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

To set up the transcoder via the Flussonic web interface:

  1. In the Media menu, select the channel you want to transcode.
  2. Go to the Transcoder tab and click Enable transcoder. You will be able to specify transcoder settings only after you add an output video track (see the next step).
  3. Click the button Add video track and (optionally) select a bitrate and height:

    transcoding options After you have added a video track, you'll be able to edit its settings.

  4. If your server has transcoding hardware installed, enable hardware transcoding:

    transcoding options

    • Hardware acceleration — enables hardware transcoding. Hardware transcoding allows for significantly more streams to be transcoded on a single server.
    • Deinterlace mode — activates deinterlacing. 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).
    • Device ID — specifies the number of the NVENC graphics card.
    • Seamless source changeprevents blinking when a stream source is changed.
  5. To keep the input stream's video characteristics, turn on Copy from origin:

    transcoding options

  6. If you want to alter the parameters of the input stream, use the form on the screen. Below is a description of all the options.

    To see more video options, click the arrow next to a vidoe track. The logo options, Advanced options and Extra parameters will appear:

    transcoding options

    If the option you would like to add is missing on the screen, you can add it manually. Just expand the Extra parameters and add the options:

    transcoding options

Video options

transcoding options

  • Bitrate — specifies the bitrate of the video track.
  • Codec (H.264|H.265|MP2V) — sets the video codec. The default value is H.264.
  • Preset — affects video quality and download speed. Read more about presets in Preset on this page.
  • 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.
  • Strategy — the strategy of resizing the video to the specified width and height.
  • 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.

To get the same output video characteristics as in the input stream, turn on Copy from origin.

Advanced video options

transcoding advanced options

  • Profile (baseline|main|high) — limits the output to a specific H.264 profile.
  • Level — used for compatibility with old devices.
  • Aspect (X) (deprecated, will be replaced with sar) — the proportion of the video display width. The ratio Aspect (X) to Aspect (Y) represent SAR. The pixel width of the input video is multiplied by SAR 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).
  • Aspect (Y) (deprecated, will be replaced with sar). See the description of Aspect (X) above.
  • Frames per second — frame rate.
  • Reference frames — used in inter-frame compression to refer to frames that follow. For better quality, use more reference frames.
  • B-frames — the values 0|1|2|3 correspond to these sequences of frames: IP|IBP|IBBP|IBBBP.
  • Frames in GOP — sets the number of frames in a GOP. The encoder will create all GOPs of an exactly identical size — as specified in this option.
  • Disable CGOP — 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 Frames in GOP. This option applies only to encoding on CPU and it might help to reduce traffic a little bit.

Logo options

If you would like to burn a logo into your video stream, specify the path to the logo file in Alogo. The file should be resized with respect to the output video size, so prepare a separate logo for each output track. If you want to use a logo without resizing, specify it in Logo. Then select where the logo will appear on the video. Learn more about logo and alogo in options.

transcoding options

Audio settings

transcoding options

  • Audio bitrate — sets the audio bitrate.
  • Sample rate (bypass|0|8000|16000|32000|44100|48000)
  • Codec (aac|opus|mp2a) — audio codec (the AAC codec is used by default).
  • Channels — sets the number of audio channels in an output stream.

To get the same audio characteristics as in the input stream, select Copy from origin.

If the option Use defaults is selected, it means that no audio options at all were specified in the configuration file. Selecting this option removes all audio options for this stream.

Other settings

Note. Depending on the transcoder type (CPU, Nvidia, or others), you will see only some of these options:

  • Speed up the transcoder 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 Speed up the transcoder 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.

When encoding with the CPU:

  • Decoder threads — the number of threads when decoding a stream. This option appears when using the CPU to transcode. Use this option only after you consult with our technical support team.

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.

  • 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.
  • Crop-Height — the height of the output image. transcoding options

When encoding with Nvidia NVENC, you can remove duplicate frames:

  • Drop second (field) — removes duplicate frames that were produced after deinterlacing, preventing increased bitrate. Turned off by default. In the configuration file, this parameter is called deinterlace_rate. If selected, then deinterlace_rate=frame and the fps stays the same, otherwise deinterlace_rate=field and the fps increases two times after transcoding.

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.

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 was resized with the size option.

Example:

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

Learn more about the logo overlay settings below.

alogo

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

Example:

vb=2048k size=1280x720 alogo=/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. 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=25 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=1 ab=128k

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 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 crop=0:0:100:100 ab=128k

aspect (sar)

aspect — modifies video aspect ratio. Will be replaced with sar.

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.

For the transcoder on CPU and Flussonic Coder aspect is processed as SAR — meaning the proportions of video display. In the UI it is represented by Aspect (X) and Aspect (Y) in advanced video options.

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 hw=nvenc aspect=12:5 ab=128k

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

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 (it is not available on hardware transcoders) and it might help reduce traffic a little bit.

Example:

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

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 flashing that can occur when a stream's source was changed, especially if the size of the picture in a new source is different than in the previous source. Details

Example:

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

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.

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=/path/to/file.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=/path/to/file.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=/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 the 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 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.

When transcoding using the CPU, the following presets are supported:

ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. The default value is medium. The value placebo is not very helpful, do not use it.

When transcoding using an NVENC-capable Nvidia GPU, the list of presets is as follows:

default, slow, medium, fast, hp, hq, bd, ll, llhq, llhp, lossless, losslesshp.

When transcoding using Intel QuickSync, the following values are supported:

veryfast, faster, fast, medium, slow, slower, veryslow.

Smooth source switching

The seamless=true option improves transcoded output streams. It prevents flashing that might sometimes occur when a stream's source has been changed, especially if the size of the picture in the new source differs. 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.

With this 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:

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