The usage of VOD service is available for CDN zones for big objects.
In order to use HLS you need to create a zone for big objects and generate m3u8 link for the mp4 file to be played. This is done by prefixing '/hls' to the path and appending /index.m3u8 at the end. Please note that you need to only upload your full mp4 files and segmentation is done by the CDN.
The returned m3u8 file will have the corresponding segments for the mp4 file. The default values for first segment and the other segmens are 5 seconds and 10 seconds respectively.
You can change them by using parameters bsd (first few segments) and sd(other segments) in the URL.
In the provided example we set the initial segment to be 10 seconds, the second again 10 seconds, the third is 15 seconds and the rest to be 20 seconds. Please note that the values should be in milliseconds.
Another important thing to notice is that the segment are with relative paths as per the specification:
Which means that the absolute path for segment 'seg-5-v1-a1.ts' is /hls/video/012345.mp4/seg-5-v1-a1.ts, not /seg-5-v1-a1.ts.
Additionally there is functionality to build a playlist from multiple files. This can be used when for a given video source there are multiple resolutions, and we would like the user to be able to change between them without changing the page.
For the example let's say that we have the previous file /video/012345.mp4 in 3 resolutions 240p, 360p and 480p and we have named them /012345_240p.mp4 , /012345_360p.mp4 and /012345_480p.mp4 accordingly.
If we request:
where you can see that the common parts are "012345_" and "0p.mp4" and we divide by commas the three different bitrates - 24,36,48
we will get a playlist which looks like:
This is the master playlist which has a playlist for each of the files provided with additional info for the streams in each of the playlist.
It's important that the end is master.m3u8 not index.m3u8 as with playlist for only one file.
It should be also noted that the playlist inside the master playlist, have the same url as the one that can be used for the individual urls.
UCDN supports multi-language subtitles in VTT format for HLS streaming. In order to demonstrate the feature we will use the same example /video/012345.mp4. In addition we will assume that the subtitles are in the same folder /video or in subfolder /video/subs/.
There should be noted several things for the above request path:
- we use urlset and master.m3u8 to load the subtitles in the playlist, not standard playlist index.m3u8
- we specify the common path first, which in the example is /video
- required part for the URL is lang/ISO 639-2 which is three-letter country code. You can find all codes on this page:
- if the subtitles are in subfolder, the folder should be before the require part.
- all commas are intentional
Our HLS functionallity supports the use of security token in order to block any hotlinking attemps. You can check for more information here:
Combining all features in order to generate security token you should include the following part:
Note that the prefix /hls and suffixes urlset/master.m3u8 and /index.m3u8 are excluded
All the segments have security tokens attached to them when returned inside the m3u8 file. So there is no need to recalculate it for each of them before requesting them.
Because the security token is the same one (including all parameters) for the m3u8 file it's important to note that for longer videos it's possible that the security token can expire before a request for the given segment is made.