Streaming with HLS
Developers can start live streaming sessions with HLS (HTTP Live Streaming) with Daily. HLS is a multi-bitrate network 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
Receive a $15 credit for freeTry Daily pay-as-you-go features for free! New accounts have a $15 credit automatically applied when you add a credit card to the account. Learn more about pay-as-you-go features on our pricing page.
HLS support is configured through a room property called
In this example, we are creating an HLS live streaming configuration 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,
false. This can be used as a replacement for cloud recording.
variants: specifies all the HLS variants to generate. Specified as array with following properties.
width: output width.
height: output height.
fps: output FPS.
bitrate: output bitrate in kilobits per second (kbps).
iframe_only: whether this is iframe-only variant.
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: (deprecated, use path_template) the S3 key path prefix for where to store the output HLS. The final master.m3u8 path template is
path_template: define the template to derive the S3 key path prefix where HLS is stored.
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:
HLS is a livestream, i.e. it is available for consumption soon after
startLiveStreaming() call. This livestream can also be saved for later viewing with
save_hls_recording: true: During the livestream, the m3u8 playlist is
[EVENT type playlist] and segments are not deleted. At the end of streaming, the playlist is converted to
[VOD type playlist].
save_hls_recording: false: During the livestream, new segments are appended to the m3u8 playlist and old segments are deleted from the playlist (as well as from S3). This keeps only the most recent 5 segments in the playlist at any point of time.
In the code example below, we use
call to start the HLS stream, after completing the
call represents a
DailyCall client, 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 if your use case requires both HLS and cloud recording or HLS and RTMP in the same meeting session, then multiple instances are required, each with a unique
instanceId. HLS cannot run with same instanceId as RTMP or cloud recording.
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 and access.
|Width||Height||Frames per Second||Bitrate(kbps)|
Daily also generates an i-frames-only-stream of 640x480, used for trick play features. These bitrates cover most use cases and content types (eg. screenshares and talking heads). These default bitrates can be changed via streaming-endpoint-config.
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.