Enable GPU Acceleration
OvenMediaEngine supports GPU-based hardware decoding and encoding. Currently supported GPU acceleration devices are Intel's QuickSync and NVIDIA's NVDECODE/NVENCODE. This document describes how to install the video driver for OvenMediaEngine to use the GPU and how to set the Config file. Please check what graphics card you have and refer to the NVIDIA or Intel driver installation guide.

Reference

Install GPU Driver

Intel QuickSync Driver

If you are using an Intel CPU that supports QuickSync, please refer to the following guide to install the driver. The OSes that support installation using the provided scripts are CentOS 7/8 and Ubuntu 18/20 versions. If you want to install the driver on a different OS, please refer to the Manual Installation Guide document.
When the Intel QuickSync driver installation is complete, the OS must be rebooted for normal operation.
1
(curl -LOJ https://github.com/AirenSoft/OvenMediaEngine/archive/master.tar.gz && tar xvfz OvenMediaEngine-master.tar.gz)
2
OvenMediaEngine-master/misc/install_intel_driver.sh
Copied!

How to check driver installation

After the driver installation is complete, check whether the driver operates normally with the Matrix Monitor program.
1
# Use the samples provided in the Intel Media SDK
2
# Check the list of codecs supported by iGPU
3
/MediaSDK-intel-mediasdk-21.1.2/build/__bin/release/simple_7_codec
Copied!

NVIDIA GPU Driver

If you are using an NVIDIA graphics card, please refer to the following guide to install the driver. The OS that supports installation with the provided script are CentOS 7/8 and Ubuntu 18/20 versions. If you want to install the driver in another OS, please refer to the manual installation guide document.
CentOS environment requires the process of uninstalling the nouveau driver. After uninstalling the driver, the first reboot is required, and a new NVIDIA driver must be installed and rebooted. Therefore, two install scripts must be executed.
1
(curl -LOJ https://github.com/AirenSoft/OvenMediaEngine/archive/master.tar.gz && tar xvfz OvenMediaEngine-master.tar.gz)
2
OvenMediaEngine-master/misc/install_nvidia_driver.sh
Copied!

How to check driver installation

After the driver installation is complete, check whether the driver is operating normally with the nvidia-smi command.
1
$ nvidia-smi
2
3
Thu Jun 17 10:20:23 2021
4
+-----------------------------------------------------------------------------+
5
| NVIDIA-SMI 465.19.01 Driver Version: 465.19.01 CUDA Version: 11.3 |
6
|-------------------------------+----------------------+----------------------+
7
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
8
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
9
| | | MIG M. |
10
|===============================+======================+======================|
11
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | N/A |
12
| 20% 35C P8 N/A / 75W | 156MiB / 1997MiB | 0% Default |
13
| | | N/A |
14
+-------------------------------+----------------------+----------------------+
15
16
+-----------------------------------------------------------------------------+
17
| Processes: |
18
| GPU GI CI PID Type Process name GPU Memory |
19
| ID ID Usage |
20
|=============================================================================|
21
| 0 N/A N/A 1589 G /usr/libexec/Xorg 38MiB |
22
| 0 N/A N/A 1730 G /usr/bin/gnome-shell 115MiB |
23
+-----------------------------------------------------------------------------+
Copied!

Container Toolkit for Docker

Describes how to enable GPU acceleration for users running OvenMediaEngine in the Docker runtime environment. To use GPU acceleration in Docker, the NVIDIA Driver must be installed on the host OS and the NVIDIA Container Toolkit must be installed. This toolkit includes container runtime libraries and utilities to use NVIDIA GPUs in Docker containers.
Reference : https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/overview.html
1
OvenMediaEngine-master/misc/install_nvidia_docker_container.sh
Copied!
The NVIDIA Driver must have been previously installed

How to run docker

To use GPU when running Docker, you need to add the --gpus all option.
1
docker run -d \
2
-p 1935:1935 -p 4000-4005:4000-4005/udp -p 3333:3333 -p 3478:3478 -p 8080:8080 -p 9000:9000 -p 9999:9999/udp -p 10006-10010:10006-10010/udp \
3
--gpus all
4
airensoft/ovenmediaengine:dev
Copied!

Manual Installation

If the provided installation script fails, please refer to the manual installation guide.

Prerequisites Additional Options

If you have finished installing the driver to use the GPU, you need to reinstall the open source library using Prerequisites.sh . The purpose is to allow external libraries to use the installed graphics driver.

When using NVIDIA Driver

1
OvenMediaEngine-master/misc/prerequisites.sh --enable-nvc
Copied!

When using Intel QuickSync Driver

1
OvenMediaEngine-master/misc/prerequisites.sh --enable-qsv
Copied!

When using Docker container

1
docker build --file Dockerfile.nv -t airensoft/ovenmediaengine:dev .
Copied!

Configuration

To use hardware acceleration, set the HardwareAcceleration option to true under OutputProfiles. If this option is enabled, a hardware codec is automatically used when creating a stream, and if it is unavailable due to insufficient hardware resources, it is replaced with a software codec.
1
<VirtualHosts>
2
<VirtualHost>
3
<Name>default</Name>
4
5
<!-- Settings for multi domain and TLS -->
6
<Host>
7
...
8
</Host>
9
10
<!-- Settings for applications -->
11
<Applications>
12
<Application>
13
<Name>app</Name>
14
<Type>live</Type>
15
<OutputProfiles>
16
<!-- Settings to use hardware codecs -->
17
<HardwareAcceleration>true</HardwareAcceleration>
18
<OutputProfile>
19
<Name>bypass_stream</Name>
20
<OutputStreamName>${OriginStreamName}_o</OutputStreamName>
21
<Encodes>
22
<Video>
23
<Codec>h264</Codec>
24
<Width>1920</Width>
25
<Height>1080</Height>
26
<Bitrate>5000000</Bitrate>
27
<Framerate>30</Framerate>
28
</Video>
29
30
<Video>
31
<Codec>h265</Codec>
32
<Width>1280</Width>
33
<Height>720</Height>
34
<Bitrate>5000000</Bitrate>
35
<Framerate>30</Framerate>
36
</Video>
37
</Encodes>
38
</OutputProfile>
39
40
</OutputProfiles>
41
<Providers>
42
...
43
</Providers>
44
<Publishers>
45
...
46
</Publishers>
47
</Application>
48
</Applications>
49
</VirtualHost>
50
</VirtualHosts>
Copied!

Build & Run

You can build the OvenMediaEngine source using the following command. Same as the contents of Getting Started.
Ubuntu 18+
Fedora 28+
CentOS 7+
1
sudo apt-get update
2
cd OvenMediaEngine-master/src
3
make release
4
sudo make install
5
systemctl start ovenmediaengine
6
# If you want automatically start on boot
7
systemctl enable ovenmediaengine.service 
Copied!
1
sudo dnf update
2
cd OvenMediaEngine-master/src
3
make release
4
sudo make install
5
systemctl start ovenmediaengine
6
# If you want automatically start on boot
7
systemctl enable ovenmediaengine.service
Copied!
1
sudo yum update
2
source scl_source enable devtoolset-7
3
cd OvenMediaEngine-master/src
4
make release
5
sudo make install
6
systemctl start ovenmediaengine
7
# If you want automatically start on boot
8
systemctl enable ovenmediaengine.service
Copied!

Support Format

The codecs available using hardware accelerators in OvenMediaEngine are as shown in the table below. Different GPUs support different codecs. If the hardware codec is not available, you should check if your GPU device supports the codec.
Device
H264
H265
VP8
VP9
QuickSync
D / E
D / E
-
-
NVIDIA
D / E
D / E
-
-
Docker on NVIDIA Container Toolkit
D / E
D / E
-
-
D : Decoding, E : Encoding

Reference

Last modified 5d ago