Live Streaming: RTMP and HLS

By Sven Baumgartner
Updated on January 28, 2020
Live Streaming: RTMP and HLS

KeyCDN supports HTTP Live Streaming (HLS) based on a normal Pull Zone. This article describes shortly each protocol and elaborates the high level concept implemented by KeyCDN how live streaming can be done.

Real Time Messaging Protocol (RTMP)

RTMP is used to stream audio, video or data and is originally a proprietary protocol introduced by Macromedia (owned by Adobe). The protocol is TCP-based and offers therefore persistent connections. In short, RTMP encapsulates MP3/AAC audio and MP4/FLV video multimedia streams.

If you do live streaming with KeyCDN, RTMP will not be used for video delivery to end users. If the streaming software is based on RTMP, you can use this protocol to initially stream your content to your server or a third party service that transforms the RTMP stream to HLS. A wide range of RTMP encoders can be used to create the live stream (e.g. FMLE, OBS, or WireCast).

HTTP Live Streaming (HLS)

HTTP Live Streaming is known as HLS. As the name implies, it is the media streaming communications protocol based on HTTP; developed by Apple as part of their QuickTime, Safari, macOS, and iOS products.

How does it work? It breaks the overall stream into a sequence of small HTTP-based transport stream (.ts) files. These transport stream files are indexed in the UTF-8 M3U playlist (.m3u8) file. It is required to first download the M3U8 playlist to play a live stream.

Why HLS for live steaming?

iOS devices do not support RTMP and most web-based players such as JW player or Flowplayer require the Flash based version to play RTMP streams, but iOS devices can not handle the Flash players. The only proper solution is HLS.

How does live streaming work with KeyCDN?

If you do live streaming with KeyCDN, video delivery to end users is based on HLS (not RTMP). The basic sequence looks like this:

RTMP encoder > Encoding (from RTMP) to HLS > Pull Zone

The HLS feature for Pull Zones (called Optimize for HLS) manages the different HLS files accordingly. The index file (.m3u8) will not be cached. The actual video files (.ts) will be cached for 5 minutes. The following Zone settings are automatically updated:

  • Expire to -1 (Cache-Control: no-cache)
  • Max Expire to 5 (relevant for the .ts files)
  • Ignore Cache Control to enabled

The HLS stream will then be pulled from your Origin URL (either your own server or a third party service that offers HLS). It's also possible to use different ports to pull the content from your HLS source (e.g. https://www.example.com:9999).

Here is an example of how to integrate HTTP Live Streaming (HLS) with JW Player:

...
    <!-- jQuery is required! -->
    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

</head>

<body>
    <div id="content">
    <h1>KeyCDN JW Player HLS Demo</h1>

    <script src="http://jwpsrv.com/library/4+R8PsscEeO69iIACooLPQ.js"></script>

    <div id="my-video"></div>
    <script type="text/javascript">
        jwplayer("my-video").setup({
            file: "http://example-hexid.kxcdn.com/example.m3u8",
            width: "530",
            height: "300",
            primary: "html",
        });
    </script>
    ...
  • Share

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started

Comments

Comment policy: Comments are welcomed and encouraged. However, all comments are manually moderated and those deemed to be spam or solely promotional in nature will be deleted.
  • **bold**
  • `code`
  • ```block```
KeyCDN uses cookies to make its website easier to use. Learn more