Streaming with HLS
Developers can start live streaming sessions with HLS (HTTP Live Streaming) with Daily. HLS is a multi-bitrate adaptive streaming protocol. It means that the audience watching your stream receives fair-quality video playback over a cellular network while also supporting the best-quality playback on a high-speed connection. The downside is latency; there is roughly a 12-to-20 second delay between what is happening "live". If you are hosting your own streams and want control on where that video output is stored on the Internet, then this guide to HLS is for you.
If you want your audience to watch your streams on Twitch, YouTube, and other providers, then you'll want to take advantage of Daily's RTMP support.
This guide covers:
- The HLS architecture at Daily
- How to configure HLS
- Starting an HLS live stream
- Enabling HLS playback for your audience
- Current limitations for HLS with Daily
HLS live streams are a beta feature. The API is subject to change.
HLS support is configured through a room property called
In this example, we are creating two live streaming configurations:
- an RTMP config for YouTube (named
- an HLS config (named
Each object inside the
streaming_endpoints array represents a live streaming configuration:
name: the label that will be used in
daily-jsto reference a specific configuration
hlsfor an RTMP and HLS configuration
rtmp_config: the RTMP configuration details (when
url: the RTMP url
hls_config: the HLS configuration details (when
truewhen you want to save the output of the live stream once the stream is finished; otherwise,
storage: the storage details when
save_hls_recordingis set to
bucket_name: the name of the S3 bucket where the HLS output will be stored
bucket_region: the AWS region of the S3 bucket (this is an S3 bucket that you own)
assume_role_arn: The Amazon Resource Name to assume in order to write to the S3 bucket
path: the S3 key path prefix for where to store the output (HLS recording). The final master.m3u8 path template is
For a complete list of the properties available on
streaming_endpoints, check out the rooms configuration.
/rooms API to configure the
streaming_endpoints for your room:
In the code example below, we use
call to start the HLS stream, after completing the
call represents an instance of the
DailyIframe class, which is initiated in projects utilizing either call object or Daily Prebuilt projects.
In this example,
hls_s3 is the name of endpoint that we defined as a
Note that it is possible to start multiple live streams with
It is not possible to use
endpoints at the same time with
Define your existing
streaming_endpoints room properties in order to start live streaming with both RTMP and HLS.
We recommend that the HLS video be served from a CDN (like CloudFront). We advise you to not serve it directly from an S3 bucket. In order to reduce security risk, your S3 resources should implement a "least privilege access" model. From a geographical perspective, serving the HLS video through a CDN ensures that the video is served closest to where your audience is located on the planet.
CDN setup is outside the scope of this guide. We have an example project that creates the necessary AWS infrastructure to serve HLS video through CloudFront.
Output is stored in one of your AWS S3 buckets. This allows you to have more control over your data and its storage.
|Width||Height||Frames per Second||Bitrate|
These bitrates cover most use case needs. It is currently not possible to change this configuration, but may be possible in a future release.
HLS configuration (
streaming_endpoints) is only available as a room property, not a domain property.
This means it cannot currently be set as a default at the domain level, but can be used by any room under your domain.
You can store up to 20
streaming_endpoints configuration objects per room.