Skip to content

Hardware transcoding with NVIDIA NVENC

Transcoding video by using NVIDIA NVENC

Flussonic Media Server supports hardware video transcoding using the GPU on NVIDIA graphics cards. The list of supported cards can be found at NVIDIA website.

This feature requires the installed Nvidia driver of version 400 or higher.

The Flussonic transcoder can process 10-bit streams if you use Nvidia NVENC.

Transcoding of AV1 video is supported by NVIDIA Ada Lovelace or later generation cards only.

Note

Some Nvidia NVENC graphic cards have a limitation for a number of concurrent sessions (transcoded streams). If too many streams are transcoded with an Nvidia NVENC card, the corresponding alert message will be displayed in Flussonic UI. To check maximum of concurrent sessions for your type of a card, please refer to NVIDIA website.

Installing the driver

Install the driver from the package:

Ubuntu 20.04:

apt-get install nvidia-driver-515-server --no-install-recommends

Make sure the non-free component is enabled in sources.list.

Official Nvidia driver downloads can be found on the Nvidia website. For help installing the drivers on Ubuntu, you may refer to the Ubuntu Knowledge Base.

To work with a lot of transcoder processes (more than 40), you'll need to increase the operating system's limit on open files. To do this, run the ulimit command:

ulimit -n 4096

And add the following lines to the /etc/security/limits.conf file:

* soft nofile 4096
* hard nofile 4096

Enabling the transcoder

There are two ways to set up transcoding:

  • In a stream's configuration entry, using the transcoder directive with various options.
  • In the Web UI, under Media > choose a stream > Transcoder.

In both cases, you should add the hw=nvenc option to enable NVENC transcoding:

transcoder vb=2048k hw=nvenc ab=128k

Selecting a codec

The default codec is H.264. When using NVIDIA NVENC, you can also use:

  • H.265 (HEVC):
transcoder vb=2048k hw=nvenc vcodec=hevc ab=128k
  • AV1:
transcoder vb=2048k hw=nvenc vcodec=av1 ab=128k

The support for 10-bit color streams

If you use NVIDIA NVENC, the Flussonic transcoder can process 10-bit streams. This feature is supported for all input and output codec options.

Use the pix_fmt option ending at p10 if you want to transcode a non-10-bit video to 10-bit. Please refer to the API reference for the full list of pix_fmt values.

For example, you can use this transcoder configuration to transcode 8-bit HEVC/H.264/AV1 to 10-bit HEVC:

transcoder vb=3000k vcodec=hevc pix_fmt=yuv420p10 ab=128k

Make sure that you have an up-to-date version of the NVIDIA drivers — 400 or higher. An Ubuntu version of at least 18.04 is also required.

Selecting the graphics card

Manual

If the system has multiple graphics cards, you can choose which one to use with the deviceid=N option:

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

The number of the card can be retrieved with the Linux console command nvidia-smi. By default, the first graphics card is used: deviceid=0.

Automatic

If you have a lot of streams, Flussonic will help you automatically allocate them between video cards for transcoding. Flussonic takes into account the GPU load and GPU memory consumption. With automatic allocation, you no longer have to determine that a GPU is overloaded and manually move streams to another card.

To enable automatic allocation of streams among GPUs, edit the configuration file and add the option deviceid=auto to transcoder of each stream:

transcoder vb=2048k hw=nvenc deviceid=auto ab=128k

Cropping video

The option crop=left:right:width:height allows you to crop video:

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

Decoding on the CPU

Decoding and encoding is performed on the GPU by default. To use the CPU for decoding, specify hw=nvenc2 instead of hw=nvenc:

transcoder vb=2048k hw=nvenc2 ab=128k

Deinterlacing

Deinterlacing is enabled by default when using nvenc. Additionally, you can specify a certain method with the deinterlace option. For example, add deinterlace=yadif to apply the CUDA yadif method when transcoding a stream:

stream test {
   input file://vod/test.ts;
   transcoder vb=4000k ab=128k deinterlace=yadif hw=nvenc;
}

All methods that you can use on NVIDIA Nvenc can be found in the UI in transcoder settings for a stream, in Deinterlace mode.

When using nvenc2 (using the CPU to decode), deinterlacing has to be turned on explicitly with the deinterlace=yes option.

To disable resource-consuming deinterlacing, specify deinterlace=0 in the transcoding settings.

Other parameters, such as size, preset, bframes, level are used in the same manner as the CPU transcoder options.

The preset parameter can have one of these values: veryfast, medium, slow.

Reading teletext from VBI in SDI with NVIDIA NVENC transcoding

Flussonic can read teletext from VBI in SDI input when transcoding SDI using NVIDIA NVENC. See Configuration examples for reading teletext from different sources for configuration examples.

Statistics on NVIDIA performance

You can collect statistics on the operation of Nvidia GPU if you enable saving statistics in the Pulse database. To start saving data, add the following directive to the Flussonic configuration file:

nvidia_monitor true;

To stop saving statistics on Nvidia, update the configuration file:

nvidia_monitor false;

For visualizing your data, go to the Pulse page in the side menu of the administrator interface, create a query to the Pulse database in the Custom pulse query field and run it:

Custom query

Note

GPU statistics (GPU usage, GPU temperature, Decoder usage, Encoder usage) is displayed by default and there is no need to create a query and run it. There must be at least one nvenc device in use and the directive nvidia_monitor true; should exist in the Flussonic configuration file.

The IN and OUT indicators show the effective traffic on sessions and streams.

The following metrics may be used (temperature metrics might not be supported by the graphics card):

  • gpu_pwr — Power usage (in Watts)
  • gpu_temp — GPU temperature (in degrees Celsius)
  • gpu_sm — SM (streaming multiprocessor) utilization (in %)
  • gpu_mem — Memory utilization (in %)
  • gpu_enc — Encoder utilization (in %)
  • gpu_dec — Decoder utilization (in %)
  • gpu_usedmem — Used video memory (in bytes or kilobytes).

Here is a query example:

sum:1m-avg:gpu_dec{from=-2h,gpu=nv0}

Other metrics:

  • gpu_mclk, gpu_pclk — Memory and processor clocks (in MHz)
  • gpu_pviol, gpu_tviol — Power overdraw (in %) and thermal overdraw (as a boolean value)
  • gpu_fb, gpu_bar1 — Frame buffer and Bar1 memory usage (in MB)
  • gpu_sbecc, gpu_dbecc — ECC (number of aggregated single bit, double bit ECC errors) and PCIe replay errors
  • gpu_pci, gpu_rxpci, gpu_txpci — PCIe Rx and Tx throughput in MB/s (Maxwell and above).

If you need to export the graphs as images (PNG), click the Save Pulse As Image button below the Custom pulse query field on the Pulse page (see the above screenshot).