Transcoding
OvenMediaEngine has a built-in live transcoder. The live transcoder can decode the incoming live source and re-encode it with the set codec or adjust the quality to encode at multiple bitrates.

Supported Video, Audio and Image Codecs

OvenMediaEngine currently supports the following codecs:
Video Decoding
Audio Decoding
Video Encoding
Audio Encoding
Image Encoding
H.264 (Baseline)
AAC
H.264 (Baseline)
AAC
JPEG
VP8
Opus
PNG

OutputProfiles

OutputProfile

The <OutputProfile> setting allows incoming streams to be re-encoded via the <Encodes> setting to create a new output stream. The name of the new output stream is determined by the rules set in <OutputStreamName>, and the newly created stream can be used according to the streaming URL format.
1
<OutputProfiles>
2
<OutputProfile>
3
<Name>bypass_stream</Name>
4
<OutputStreamName>${OriginStreamName}_bypass</OutputStreamName>
5
<Encodes>
6
<Audio>
7
<Bypass>true</Bypass>
8
</Audio>
9
<Video>
10
<Bypass>true</Bypass>
11
</Video>
12
<Audio>
13
<Codec>opus</Codec>
14
<Bitrate>128000</Bitrate>
15
<Samplerate>48000</Samplerate>
16
<Channel>2</Channel>
17
</Audio>
18
</Encodes>
19
</OutputProfile>
20
</OutputProfiles>
Copied!
According to the above setting, if the incoming stream name is stream, the output stream becomes stream_bypassand the stream URL can be used as follows.

Encodes

Video

You can set the video profile as below:
1
<Encodes>
2
<Video>
3
<Codec>vp8</Codec>
4
<Width>1280</Width>
5
<Height>720</Height>
6
<Bitrate>2000000</Bitrate>
7
<Framerate>30.0</Framerate>
8
<Preset>fast</Preset>
9
</Video>
10
</Encodes>
Copied!
The meaning of each property is as follows:
Property
Description
Codec
Specifies the vp8 or h264 codec to use
Width
Width of resolution
Height
Height of resolution
Bitrate
Bit per second
Framerate
Frames per second
Preset
Presets of encoding quality and performance
Table of presets
A table in which presets provided for each codec library are mapped to OvenMediaEngine's presets. Slow presets are of good quality and use a lot of resources, whereas Fast presets have lower quality and better performance. It can be set according to your own system environment and service purpose.
Presets
x264/x265
libvpx
h264/265 NVC
h264/265 QSV
slower
slower
best
hq
-
slow
slow
best
llhq
-
medium
medium
good
bd
-
fast
fast
realtime
hp
-
faster
*faster
*realtime
*llhp
-
References
  • https://trac.ffmpeg.org/wiki/Encode/H.264
  • https://x265.readthedocs.io/en/stable/presets.html
  • https://trac.ffmpeg.org/wiki/Encode/VP8
  • https://docs.nvidia.com/video-technologies/video-codec-sdk/nvenc-preset-migration-guide/

Audio

You can set the audio profile as below:
1
<Encodes>
2
<Audio>
3
<Codec>opus</Codec>
4
<Bitrate>128000</Bitrate>
5
<Samplerate>48000</Samplerate>
6
<Channel>2</Channel>
7
</Audio>
8
</Encodes>
Copied!
The meaning of each property is as follows:
Property
Description
Codec
Specifies the opus or aac codec to use
Bitrates
Bits per second
Samplerate
Samples per second
Channel
The number of audio channels
It is possible to have an audio only output profile by specifying the Audio profile and omitting a Video one.

Image

You can set the Image profile as below:
1
<Encodes>
2
<Image>
3
<Codec>jpeg</Codec>
4
<Width>1280</Width>
5
<Height>720</Height>
6
<Framerate>1</Framerate>
7
</Image>
8
</Encodes>
Copied!
The meaning of each property is as follows:
Property
Description
Codec
Specifies the jpeg or png codec to use
Width
Width of resolution
Height
Height of resolution
Framerate
Frames per second
The image encoding profile is only used by thumbnail publishers. and, bypass option is not supported.

Bypass without transcoding

You can configure Video and Audio to bypass transcoding as follows:
1
<Video>
2
<Bypass>true</Bypass>
3
</Video>
4
<Audio>
5
<Bypass>true</Bypass>
6
</Audio>
Copied!
You need to consider codec compatibility with some browsers. For example, chrome only supports OPUS codec for audio to play WebRTC stream. If you set to bypass incoming audio, it can't play on chrome.
WebRTC doesn't support AAC, so if video bypasses transcoding, audio must be encoded in OPUS.
1
<Encodes>
2
<Video>
3
<Bypass>true</Bypass>
4
</Video>
5
<Audio>
6
<Codec>opus</Codec>
7
<Bitrate>128000</Bitrate>
8
<Samplerate>48000</Samplerate>
9
<Channel>2</Channel>
10
</Audio>
11
</Encodes>
Copied!

Keep the original with transcoding

If you want to transcode with the same quality as the original. See the sample below for possible parameters that OME supports to keep original. If you remove the Width, Height, Framerate, Samplerate, and Channel parameters. then, It is transcoded with the same options as the original.
1
<Encodes>
2
<Video>
3
<Codec>vp8</Codec>
4
<Bitrate>2000000</Bitrate>
5
</Video>
6
<Audio>
7
<Codec>opus</Codec>
8
<Bitrate>128000</Bitrate>
9
</Audio>
10
<Image>
11
<Codec>jpeg</Codec>
12
</Image>
13
</Encodes>
Copied!

Rescaling while keep the aspect ratio

To change the video resolution when transcoding, use the values of width and height in the Video encode option. If you don't know the resolution of the original, it will be difficult to keep the aspect ratio after transcoding. Please use the following methods to solve these problems. For example, if you input only the Width value in the Video encoding option, the Height value is automatically generated according to the ratio of the original video.
1
<Encodes>
2
<Video>
3
<Codec>h264</Codec>
4
<Bitrate>2000000</Bitrate>
5
<Width>1280</Width>
6
<!-- Height is automatically calculated as the original video ratio -->
7
<Framerate>30.0</Framerate>
8
</Video>
9
<Video>
10
<Codec>h264</Codec>
11
<Bitrate>2000000</Bitrate>
12
<!-- Width is automatically calculated as the original video ratio -->
13
<Height>720</Height>
14
<Framerate>30.0</Framerate>
15
</Video>
16
</Encodes>
Copied!

Supported codecs by streaming protocol

Even if you set up multiple codecs, there is a codec that matches each streaming protocol supported by OME, so it can automatically select and stream codecs that match the protocol. However, if you don't set a codec that matches the streaming protocol you want to use, it won't be streamed.
The following is a list of codecs that match each streaming protocol:
Protocol
Supported Codec
WebRTC
VP8, H.264, Opus
HLS
H.264, AAC
Low-Latency MPEG-Dash
H.264, AAC
Therefore, you set it up as shown in the table. If you want to stream using HLS or MPEG-DASH, you need to set up H.264 and AAC, and if you want to stream using WebRTC, you need to set up Opus.
Also, if you are going to use WebRTC on all platforms, you need to configure both VP8 and H.264. This is because different codecs are supported for each browser, for example, VP8 only, H264 only, or both.
However, don't worry. If you set the codecs correctly, OME automatically sends the stream of codecs requested by the browser.
Currently, OME doesn't support adaptive streaming on HLS, MPEG-DASH. However, it will be updated soon.
Last modified 25d ago