What is HLS
By default, our CDN supports HLS streaming. HLS (HTTP Live Streaming) is an adaptive HTTP-based streaming communication protocol for distribution both live and on-demand video files, created by Apple. When a video is encoded to HLS, a stream is divided into several video segments and multiple files are created for different bandwidths and different resolutions. Video segments are loaded consecutively via HTTP along with a M3U8 playlist which has data of included playlists and video segments. The video stream is encoded in MPEG-2 TS with MPEG H.264 codec for video and AAC for audio.
Configure the service
- Create a CDN Resource in the control panel
- Configure caching settings for playlists (.m3u8) and video segments (.ts)
Configure general caching settings on your origin with the Cache-Control HTTP header. By default, a CDN inherits all HTTP headers and follows all stated directives. For playlists set a no-cache directive (this prohibits caching), for video segments caching time should be a little longer than the length of a segment itself (usually it's about a minute). Read more about configuring caching settings in the control panel.
- Integrate your stream with the CDN.
Change your domain address in URLs to your CNAME. Please check CNAME settings beforehand.
For example, this is URL to the stream from origin: http://myhls.com/playlist.m3u8
The same stream from CDN will have the following URL: http://cdn.myhls.com/playlist.m3u8
You can check your stream in any player which supports online HLS streaming, for example, VLC.
- Publish stream at your website
Now you can publish a URL for stream via a CDN at your website and allow visitors to download M3U8 or show video in browsers using a player, for example, hls.js.
If you expect more than 100 viewers from different locations, we strongly recommend you to activate origin shielding to improve failover capability.