HLS
Beta
Beta
HLS is still in development and some features such as SignedPolicy and AdmissionWebhooks are not supported.
HLS based on MPEG-2 TS containers is still useful because it provides high compatibility, including support for older devices. Therefore, OvenMediaEngine decided to officially support HLS version 7+ based on fragmented MP4 containers, called LL-HLS, as well as HLS version 3+ based on MPEG-2 TS containers.
Title | Descriptions |
---|---|
To differentiate between LLHLS and HLS playback addresses, we created the following rule for HLS playback addresses:
http[s]://domain[:port]/<app name>/<stream name>/ts:<playlist file name>.m3u8
or
http[s]://domain[:port]/<app name>/<stream name>/<playlist file name>.m3u8?format=ts
To use HLS, you need to add the <HLS>
elements to the <Publishers>
in the configuration as shown in the following example.
Safari Native Player only provides the Seek UI if #EXT-X-PLAYLIST-TYPE: EVENT
is present. Since it is specified that nothing can be removed from the playlist when it is of type EVENT, you must call the concludeHlsLive API to switch to VoD or terminate the stream before MaxDuration is exceeded if you use this option. Otherwise, unexpected behavior may occur in the Safari Player.
HLS is ready when a live source is inputted and a stream is created. Viewers can stream using OvenPlayer or other players.
If your input stream is already h.264/aac, you can use the input stream as is like below. If not, or if you want to change the encoding quality, you can do Transcoding.
HLS Publisher basically creates a playlist.m3u8
Playlist using the first video track and the first audio track. When you create a stream, as shown above, you can play HLS with the following URL:
http[s]://domain[:port]/<app name>/<stream name>/ts:playlist.m3u8
If you use the default configuration, you can start streaming with the following URL:
https://domain:3334/app/<stream name>/ts:playlist.m3u8
We have prepared a test player that you can quickly see if OvenMediaEngine is working. Please refer to the Test Player for more information.
HLS can deliver adaptive bitrate streaming. OME encodes the same source with multiple renditions and delivers it to the players. And HLS Player, including OvenPlayer, selects the best quality rendition according to its network environment. Of course, these players also provide option for users to manually select rendition.
See the Adaptive Bitrates Streaming section for how to configure renditions.
HLS Publisher basically creates a playlist.m3u8
Playlist using the first video track and the first audio track. If you want to create a new playlist for ABR, you can add it to Server.xml as follows:
Since TS files used in HLS must have A/V pre-muxed, the Playlist must have the EnableTsPackaging
option set.
Most browsers and players prohibit accessing other domain resources in the currently running domain. You can control this situation through Cross-Origin Resource Sharing (CORS) or Cross-Domain (CrossDomain). You can set CORS and Cross-Domain as <CrossDomains>
element.
You can set it using the <Url>
element as shown above, and you can use the following values:
You can create as long a playlist as you want by setting <DVR>
to the HLS publisher as shown below. This allows the player to rewind the live stream and play older segments. OvenMediaEngine stores and uses old segments in a file in <DVR><TempStoragePath>
to prevent excessive memory usage. It stores as much as <DVR><MaxDuration>
and the unit is seconds.
Element | Decscription |
---|---|
Url Value | Description |
---|---|
Delivery
HTTP/1.1 HTTP/2
Security
TLS (HTTPS)
Container
MPEG-2 TS (Only supports Audio/Video muxed)
Codecs
H.264
AAC
Bind
Set the HTTP ports to provide HLS.
SegmentDuration
Set the length of the segment in seconds. Therefore, a shorter value allows the stream to start faster. However, a value that is too short will make legacy HLS players unstable. Apple recommends 6 seconds for this value.
SegmentCount
The number of segments listed in the playlist. 5 is recommended for HLS players. Do not set below 3. It can only be used for experimentation.
CrossDomains
Control the domain in which the player works through <CorssDomain>
. For more information, please refer to the CrossDomain section.
DVR
Enable You can turn DVR on or off.
EventPlaylistType Inserts #EXT-X-PLAYLIST-TYPE: EVENT into the m3u8 file.
TempStoragePath Specifies a temporary folder to store old segments.
MaxDuration Sets the maximum duration of recorded files in milliseconds.
*
Allows requests from all Domains
domain
Allows both HTTP and HTTPS requests from the specified Domain
http://domain
Allows HTTP requests from the specified Domain
https://domain
Allows HTTPS requests from the specified Domain