
Speir Live Streaming App OvenMediaEngine Set Up
Streams
The streams module allows to creation of live video streams for a wide audience. This module requires a separate media server to be set up, currently
Nginx and
OvenMediaEngine are supported
Configuration
Streaming section
- Server Software - live streaming server, for now only
- Nginx and
- OvenMediaEngine are supported. Nginx doesn't support WebRTC, so you can't broadcast from the browser, for now only OvenMediaEngine supports WebRTC and streaming from the browser.
- Server Hostname - server hostname without protocol, for example: live.example.com
- Application Name - application name defined in your streaming server configuration
- Sources Pattern - JSON string with possible sources suitable for
- OvenMediaPlayer, there are the following substitution markers are supported:
{host}
- Server Hostname{app}
- Application Name{key}
- Streaming Key{params}
- Additional Params- Enable MPEG-DASH streaming - enable this option if MPEG-DASH sources are specified in the Sources Pattern
- Enable HLS streaming - enable this option if HLS sources are specified in the Sources Pattern
- Base URL for recordings (experimental) - when recording is enabled set the base URL where recorded videos can be accessed
OvenMediaEngine
Configuration for
OvenMediaEngine server.
- OvenMediaEngine API Key - base64 string of API key defined in config files
- OvenMediaEngine API Protocol - protocol for API requests
- OvenMediaEngine API Port - API port defined in config files
- OvenMediaEngine Signed Policy Secret Key - secret key defined in config files, this is optional, but needed to restrict to allow to use of streaming server only for users who have permission to stream in UNA
- Recording source -
OutputStreamName
fromOutputProfile
section to use for recording, if different from${OriginStreamName}
,{key}
replacement marker is supported here
Sample OvenMediaEngine configuration for WebRTC streaming in Server.xml file. If the Origin and Edge model is used then specify the below configurations for the Origin server.
Enable API Server in
Bind
section:
<Managers>
<API>
<Port>
${env:OME_API_PORT:8081}</Port>
<WorkerCount>
1</WorkerCount>
</API>
<Managers>
Enable WebRTC in
Bind > Providers
section:
<WebRTC>
<Signalling>
<Port>
${env:OME_SIGNALLING_PORT:3333}</Port>
<WorkerCount>
1</WorkerCount>
<TLSPort>
3334</TLSPort>
</Signalling>
<IceCandidates>
<TcpRelay>
${env:OME_TCP_RELAY_ADDRESS:*:3478}</TcpRelay>
<TcpForce>
false</TcpForce>
<TcpRelayWorkerCount>
1</TcpRelayWorkerCount>
<IceCandidate>
${env:OME_ICE_CANDIDATES:*:10006/udp}</IceCandidate>
</IceCandidates>
</WebRTC>
Enable WebRTC in
Bind > Publishers
section:
<WebRTC>
<Signalling>
<Port>
${env:OME_SIGNALLING_PORT:3333}</Port>
<WorkerCount>
1</WorkerCount>
<TLSPort>
3334</TLSPort>
</Signalling>
<IceCandidates>
<TcpRelay>
${env:OME_TCP_RELAY_ADDRESS:*:3478}</TcpRelay>
<TcpRelayWorkerCount>
1</TcpRelayWorkerCount>
<IceCandidate>
${env:OME_ICE_CANDIDATES:*:10006/udp}</IceCandidate>
</IceCandidates>
</WebRTC>
Modern browsers require a secure connection for WebRTC, so OvenMediaEngine needs to be configured to use secure TLS protocol. Specify paths to certificates in
VirtualHost
section:
<Host>
<Names>
<Name>
live.example.com</Name>
</Names>
<TLS>
<CertPath>
/path_here/live.example.com.cer</CertPath>
<KeyPath>
/path_here/live.example.com.key</KeyPath>
<ChainCertPath>
/path_here/fullchain.cer</ChainCertPath>
</TLS>
</Host>
Enable signed policy by specifying
SecretKey
in
SignedPolicy
section, so a special signed policy will be required for broadcasting, for consuming stream no policy is needed according to the configuration below, you also need to specify
SecretKey
from here in
OvenMediaEngine Signed Policy Secret Key setting:
<SignedPolicy>
<PolicyQueryKeyName>
policy</PolicyQueryKeyName>
<SignatureQueryKeyName>
signature</SignatureQueryKeyName>
<SecretKey>
54321ytrewq_change_to_your_own</SecretKey>
<Enables>
<Providers>
rtmp,webrtc,srt</Providers>
</Enables>
</SignedPolicy>
Specify application name in
Application
section, or leave it as it is, the same app name needs to be specified in
Application Name configuration:
<Name>
app</Name>
<Type>
live</Type>
Specify desired output profiles in
VirtualHost > Application > OutputProfiles
section, please note that the following configuration enables transcoding which requires considerable server resources, so probably 8 CPU cores are needed for the configuration below:
<OutputProfile>
<Name>
1080p30</Name>
<OutputStreamName>
${OriginStreamName}_1080p30</OutputStreamName>
<Encodes>
<Audio>
<Codec>
opus</Codec>
<Bitrate>
128000</Bitrate>
<Samplerate>
48000</Samplerate>
<Channel>
2</Channel>
</Audio>
<Video>
<Codec>
h264</Codec>
<Bitrate>
3072000</Bitrate>
<Framerate>
30</Framerate>
<Width>
1920</Width>
<Height>
1080</Height>
</Video>
</Encodes>
</OutputProfile>
<OutputProfile>
<Name>
720p30</Name>
<OutputStreamName>
${OriginStreamName}_720p30</OutputStreamName>
<Encodes>
<Audio>
<Codec>
opus</Codec>
<Bitrate>
128000</Bitrate>
<Samplerate>
48000</Samplerate>
<Channel>
2</Channel>
</Audio>
<Video>
<Codec>
h264</Codec>
<Bitrate>
1536000</Bitrate>
<Framerate>
30</Framerate>
<Width>
1280</Width>
<Height>
720</Height>
</Video>
</Encodes>
</OutputProfile>
You can disable transcoding and bypass the input stream as it is, but it may be some clients will experience problems with supported formats, and result may be inconsistent, in this case much slower streaming server can be used:
<OutputProfile>
<Name>
bypass_stream</Name>
<OutputStreamName>
${OriginStreamName}</OutputStreamName>
<Encodes>
<Audio>
<Bypass>
true</Bypass>
</Audio>
<Video>
<Bypass>
true</Bypass>
</Video>
</Encodes>
</OutputProfile>
Enable WebRTC in
VirtualHost > Application > Providers
section:
<WebRTC />
Enable WebRTC in
VirtualHost > Application > Publishers
section:
<WebRTC>
<Timeout>
30000</Timeout>
<Rtx>
false</Rtx>
<Ulpfec>
false</Ulpfec>
</WebRTC>
Make API access token by token only by adding the following section just before closing
</Server>
tag, base64 string of this key needs to be specified in
OvenMediaEngine API Key setting:
<Managers>
<Host>
<Names>
<Name>
*</Name>
</Names>
</Host>
<API>
<AccessToken>
qwerty12345_change_to_your_own</AccessToken>
</API>
</Managers>
Sources pattern setting in UNA for the above configuration with transcoding would be the following:
[
{
type: "webrtc"
,
file: "wss://{host}:3334/{app}/{key}_1080p30{params}"
,
label: "1080p30"
}
,
{
type: "webrtc"
,
file: "wss://{host}:3334/{app}/{key}_720p30{params}"
,
label: "720p30"
}
]
Sources pattern for above configuration with bypass stream:
[
{
type: "webrtc"
,
file: "wss://{host}:3334/{app}/{key}{params}"
,
label: "bypass_stream"
}
]
For recording functionality add the following code to
VirtualHost > Applications > Application > Publishers
section:
<FILE>
<RootPath>
/path/to/recorded/videos</RootPath>
<FilePath>
/${Stream}_${Id}.ts</FilePath>
<InfoPath>
/${Stream}_${Id}.xml</InfoPath>
</FILE>
NOTE: recording in OvenMediaEngine is still in Beta and it may result in unpredictable results, for best results use
Bypass
mode for recording source and
.ts
file format.