Search code examples
amazon-web-servicesvideo-streaminghtml5-videotranscodingamazon-elastic-transcoder

HLS, AWS Elastic Encoder, and adaptive streaming


I'm currently working on simple VOD browser-based service, using mostly AWS technologies. HLS will be used as the streaming protocol, which is supported by Elastic Transcoder.

Currently, the source material is 720p (1280x720), and this is also the resolution I want to show to all devices that can handle it. I would like the videos to work on desktops, iPad's, and most smartphones. I'm using ViBlast with videojs, as the player.

I have the following questions:

  • the m3u8 playlist allows to specify multiple streams. Should each resolution get's it own playlist (with different source-streams on different bitrates), or can I put everything in one playlist (so one playlist can serve different resolutions and bitrates).
  • Seems desktops and most recent tablets can display 1280x720, I assume the same playlist can be used. I just need to specify bitrates. However, what is the best resolution for mobile phones? Seems every device has other dimensions (looking at Android here).
  • Which bitrate should I use for each device? I'm doing some research, but it seems every article has a different recommendation for the "best" setting, but never explain how they got those numbers.
  • If I use a playlist which contains different sources with different resolutions, does the order in the playlist matter? I've read somewhere that lowest bitrates should be listed first, but does this also apply to resolutions? Or does the player automatically picks the stream which best matches the screen?

I'm looking for a "good enough" solution that will fit most devices.


Solution

  • Hope this helps.

    the m3u8 playlist allows to specify multiple streams. Should each resolution get's it own playlist (with different source-streams on different bitrates), or can I put everything in one playlist (so one playlist can serve different resolutions and bitrates).

    For reference, here is Apple's 'Technical Note TN2224' on the subject which is a good guideline for the info below. https://developer.apple.com/library/content/technotes/tn2224/_index.html

    Short answer: Each resolution should have its own variant playlist.

    Typically there is one master playlist with references to the variant playlists (aka renditions). The variant playlists are different quality streams of the same video, varying in bitrate and resolution. But each variant only contains one bitrate level. Sample master playlist:

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4648000,RESOLUTION=3840x2160
    4648k/stream.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2670000,RESOLUTION=1920x1080
    2670k/stream.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1823000,RESOLUTION=1280x720
    1823k/stream.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=975000,RESOLUTION=854x480
    975k/stream.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=491000,RESOLUTION=640x360
    491k/stream.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=186000,RESOLUTION=256x144
    186k/stream.m3u8
    

    "The bitrates are specified in the EXT-X-STREAM-INF tag using the BANDWIDTH attribute" (TN2224). And each descending bandwidth (bitrate) level has a corresponding lower resolution because there is less data available and usually expected to be viewed on smaller, mobile screens.

    Seems desktops and most recent tablets can display 1280x720, I assume the same playlist can be used. I just need to specify bitrates. However, what is the best resolution for mobile phones? Seems every device has other dimensions (looking at Android here).

    Resolution and bitrate go together. A stream encoded with a 186K bitrate (very low) does not have enough data to fill a 1280x720 screen. But a mobile device on a cell network might not be able to download a high bitrate. So you need several variants options available, each with the appropriate resolution and bitrate.

    Don't focus on a specific device or else you'll never finish. Build a ladder of bitrate/resolution variants using common 16:9 aspect ratios. E.g. 1280x720, 1024x576, 640x360,...

    There are several things to consider though. Bitrate, resolution you are already considering. But are these videos encoded using H.264? If so you should consider the profile level. Here is a good article on the topic: http://www.streamingmedia.com/Articles/ReadArticle.aspx?ArticleID=94216&PageNum=1.

    enter image description here

    Which bitrate should I use for each device? I'm doing some research, but it seems every article has a different recommendation for the "best" setting, but never explain how they got those numbers.

    Same answer as resolution. Don't focus on the actual device. Build a ladder of bitrate/resolution variants that allows the device to select the most appropriate based on available bandwidth, battery life, processing power, etc.

    If I use a playlist which contains different sources with different resolutions, does the order in the playlist matter? I've read somewhere that lowest bitrates should be listed first, but does this also apply to resolutions? Or does the player automatically picks the stream which best matches the screen?

    Each publisher or manufacturer might build their player differently. But this is what Apple recommends in TN2224.

    "First bit rate should be one that most clients can sustain The first entry in the master playlist will be played at the initiation of a stream and is used as part of a test to determine which stream is most appropriate. The order of the other streams is irrelevant. Therefore, the first bit rate in the playlist should be the one that most clients can sustain."

    Hope that helps.

    Ian