Apple HTTP Live Streaming (HLS) CDN

Basic consepts of HLS

Apple HTTP Live Streaming (HLS) is Apple's implementation of adaptive streaming technology.

This implementation clearly adheres to all principles of adaptive streaming and has a tangible advantage of support for mobile devices based on iOS and Android.

HLS requires the following components:

  • video fragments (ts-file);
  • m3u8-manifest file that contains links to ts-fragments of video
  • An index m3u8 file containing references to m3u8 manifests of several video detail options (which differ in terms of picture quality and bitrate).

Using HLS CDN

To arrange HLS broadcast of a single file without switching between video variants, just pass link with HLS marker to player:

USERNAME.cdn.zerocdn.com/file.mp4:hls:manifest.m3u8

The URL of the fragment will be as follows:

USERNAME.cdn.zerocdn.com/file.mp4:hls:N.ts

where N is the fragment identifier.

USERNAME.cdn.zerocdn.com/file.mp4:hls:manifest.m3u8

To create video broadcasts with switching options it is necessary to create in the corresponding folder an index m3u8-file with the following content:

#EXTM3U

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=352000,RESOLUTION=426x240
./240.mp4:hls:manifest.m3u8

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=608000,RESOLUTION=640x360
./360.mp4:hls:manifest.m3u8

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1152000,RESOLUTION=640x360
./480.mp4:hls:manifest.m3u8

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2692000,RESOLUTION=1280x720
./720.mp4:hls:manifest.m3u8

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5192000,RESOLUTION=1920x1080
./1080.mp4:hls:manifest.m3u8

Where 240.mp4, 360.mp4, 480.mp4, 720.mp4 and 1080.mp4 are the different video variants located in this folder, and the lines

  • #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=352000,RESOLUTION=426x240
  • #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=608000,RESOLUTION=640x360
  • #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1152000,RESOLUTION=1280x720
  • #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2692000,RESOLUTION=1280x720
  • #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5192000,RESOLUTION=1920x1080

description of the characteristics of these files.

Warning! The './' prefix before the file name is mandatory to maintain compatibility with Apple devices!

Signing HLS LINKS

To make HLS links protections work effectively, files should be placed in such a way that different formats of the same video are located in the same folder.

  • video1/
    • 240.mp4
    • 360.mp4
    • 480.mp4
    • 720.mp4
    • 1080.mp4
    • hls.m3u8
  • video2/
    • 240.mp4
    • 360.mp4
    • 480.mp4
    • 720.mp4
    • 1080.mp4
    • hls.m3u8

In this case a common part of URL can be signed for all files inside the specified folder. A Signed HLS URL will look like this:

http://USERNAME.cdn.zerocdn.com/path/to/video1/[sign]:[deadline]/hls.m3u8

The following input data will be used to generate the signature:

md5(/path/to/-[ip]-[deadline]-[secret])

HLS technical requirements

ZeroCDN.com provides HLS streaming support for files subject to the following requirements:

  • mp4-container,
  • h264 video codec,
  • AAC audio codec,
  • faststart support.