Using HLS Video Presets
HLS is a standard for adaptive streaming, which allows clients to adjust the bitrate of a video stream to match the currently available bandwidth. The way HLS works is that the server produces several streams of different quality (i.e, different bitrates), each of which is divided up into short, fixed-duration segments (say 10 seconds each). The client is then able to monitor the available bandwidth, and if necessary switch stream every 10 seconds in order to maintain the best possible video stream. This description of HLS includes a good illustration of this process.
In order to provide an HLS stream, you have to use HLS presets. Amazon Elastic Transcoder provides a range of predefined HLS presets, or you can define your own. An Elastic transcoder HLS preset generates one of the substreams that go to make up a complete HLS stream. So if you define a preset group like this:
<presetGroup type="video" name="high-res" default="true"> <ui:title>High resolution videos</ui:title> <presets> <preset id="preset-id"> <thumbnails/> </preset> <preset id="preset-id"/> <preset id="preset-id"/> <preset id="hls-preset-id"/> <preset id="hls-preset-id"/> <preset id="hls-preset-id"/> </presets> </presetGroup>
Then the result is four transcoded outputs: three fixed bit-rate videos and one HLS video stream offering three different bitrates.
The short video segments that make up an HLS video stream are stored
in files with the extension .ts
. Each substream is
represented by a playlist file with the extension
.m3u8
. This is a simple text file that contains
correctly ordered references to all the .ts
files
in the stream. The whole HLS stream is represented by yet another
master playlist .m3u8
file
that contains references to each of the substreams. This structure is
automatically created by the Elastic Transcoder, and is the structure
expected by HLS-capable clients. All you need to be aware of is that
the HLS presets you define in a preset group get merged to a single
HLS output stream, represented by a .m3u8
playlist
file.
You can control the length of the .ts
segments
generated by Elastic Transcoder by setting a
segmentDuration
property (see
AWSClientService.properties). This will
determine how quickly a client responds to changes in available
bandwidth.