Encoder Settings for HLS Live Streaming

Live streaming is easier today than it ever has been before. Getting started only requires a few elements. You need a camera, an encoder, an internet connection, and a streaming solutions provider. This article will focus on proper encoder settings, especially for HLS streaming.

If you don’t already know, an encoder is a piece of software or hardware that interfaces between your camera and a streaming service provider. Essentially, the task of an encoder is to transform your video from the format created by your camera into a format suitable for live streaming.

The most common format for this stream ingestion is RTMP. This is what we use at DaCast for ingesting live streams. These are then transcoded into the HLS streaming protocol, and delivered via Akamai CDN. Unlike RTMP, HLS is compatible with most browsers and devices with no need for the Flash plugin. Let’s dive in and learn more about HLS and encoder settings.

About HLS streaming (HTTP Live Streaming)

The de-facto standard for delivering internet video used to be Flash. However, due to security and power consumption issues, Flash is being discontinued. Today, HTTP Live Streaming (HLS) is used to deliver streams for iOS, Android, some desktop browsers, and a variety of other internet connected devices.

HLS streaming protocol dominates the market. It is the safest bet to effectively deliver your stream to any viewer on any devices, which is why DaCast delivers all live streams in HLS format.

Proper encoder settings for HLS streaming

As we already mentioned, most live streams are sent from the encoder to the online video platform in RTMP format. The OVP/streaming platform then transcodes this video into HLS. Therefore, this article will look at settings for your RTMP-capable encoder.

RTMP encoders come in a wide variety of types. The simplest are software encoders, which can be installed on a smartphone, tablet, or computer just like any other app. There are free software encoders, as well as highly complex and expensive suites. Additionally, there are hardware encoders. These are well suited for mobile streaming, studio use, and professional-grade settings.

Regardless, RTMP encoders are all configured in the same basic manner. Whether you are using a hardware encoder or a software encoder, the following encoder settings will work to get your HLS streaming up and running.

Let’s dive into the nitty gritty.

Video and audio codec

Encoder Settings for HLS Live Streaming - h.264We’ll start with codecs, since this is foundational and relatively simple. The video codec that you should use is h.264. You may also see an x.264 option; this is simply another implementation of the same protocol. You can use either one. In some cases, x.264 may use less processing power, but the difference is rarely significant.

There is one additional detail here. The h.264 standard is actually a family of standards, which are called “profiles.” There are a lot of these profiles, but you only need to worry about two. If you’re streaming in 720p resolution or lower, use the “Main” protocol. If you’re streaming in 1080p full HD, use the “High” protocol.

You should select AAC or AAC-LC as the audio codec.

For more details on codecs, check out our comprehensive essay on the topic here.

Video resolution

Resolution is simply the size of your video, measured in pixels. The most common video frame sizes in use today are:

  • 426 pixels wide x 240 pixels high (240p)
  • 640 x 360 (360p, Low Definition)
  • 854 x 480 (480p, Standard Definition, or SD)
  • 1280 x 720 (720p High Definition, or HD)
  • 1920 x 1080 (1080p, or Full HD)

Most of the time, you’ll want to broadcast in the highest available resolution. However, higher resolution video requires more bandwidth to deliver. It also requires more bandwidth for the viewer to access.

Because of this, most broadcasters choose to broadcast in multiple resolutions and multiple bitrates. Multi-bitrate streaming allows viewers to be served the best possible quality video. For a tutorial on how to set up multi-bitrate streaming, click here.

Video and audio bitrates

Encoder Settings for HLS Live Streaming - resolutionWe’ve already introduced the word bitrate, but what does it mean? Bitrate refers to the amount of data in your video/audio streams per unit of time. This is measured in Kilobits per second (kbps) or Megabits per second (Mbps). One Mbps is equal to 1000 kbps.

Higher video resolution requires more data. To give you a rough sense of the numbers, a low quality 240p live stream might require around 400 kbps. A full HD 1080p live stream usually requires 4-8 Mbps. Here are some recommended video bitrates at various resolutions:

  • 240p: 300 – 500 kbps
  • 360p: 500 – 800 kbps
  • 480p: 800 kbps – 2 Mbps
  • 720p: 1.5 – 4 Mbps
  • 1080p: 3 – 6 Mbps

Audio bitrates are simpler. For streams at 240p video resolution, we recommend using 64 kbps as your audio bitrate. At 360p or 480p, increase the audio bitrate to 96 kbps. At 720p and above, you can use 128 or 192 kbps. Of course, these are just recommendations. If you’re streaming a concert, you may choose to prioritize audio quality even with low quality video streams. These choices are ultimately up to you!

Other audio settings sometimes include the number of channels: “mono” vs “stereo.” We recommend stereo (two channels) for all live streams above 360p resolution. Additionally, we recommend an audio sample rate of 22 Khz.

Internet speed and bandwidth requirements

When selecting resolution and bandwidth for your live stream, don’t neglect to think about your internet speed. In general, we recommend that your upload speed should be roughly double the total combined bandwidth of your video and audio. If you’re streaming in multiple bandwidths, the total bandwidth of all combined streams must be considered.

Attempting to stream too much data on an internet connection that isn’t fast enough can cause your live stream to fail completely.

To select the correct bit rate, divide the sustained upload speed of your internet connection by two. This is the amount of bandwidth you have to play with. For example, a 10 Mbps upload speed would give you 5 Mbps of bandwidth. In this case, I’d recommend sending out a multi-bitrate stream with the following settings:

  • 720p stream at 2.5 Mbps
  • 480p stream at 1 Mbps
  • 360p stream at 500 kbps
  • 240p stream at 300 kbps

This would ensure that a reliable stream will be available to both people with a fast internet connection and a slow one.

CBR vs. VBR

CBR refers to “Constant Bit Rate,” while VBR in turn means “Variable Bit Rate.” Encoder settings will often include a toggle for CBR vs. VBR for both audio and video.

Constant Bit Rate is simple. With this setting, streams will use the same amount of data regardless of contents of the stream at any given time. In contrast, VBR takes into account the contents of your stream. If, for example, a segment of video contains a lot of fast-moving action, the bitrate will temporarily increase. This increases perceived quality. However, in some situations it can also cause excess load on your internet bandwidth.

In general, we recommend using VBR, although it’s not a make or break issue.

Frames Per Second

Here’s another easy one. Frames per second (fps) should generally be set at 30 for most users. For people in certain regions of the world, 25 frames per second is standard. However, 30 will work anywhere. If you are broadcasting sports or other fast-action video, 60 fps may be preferable. Be aware that it may take a higher bit rate to make these videos look good.

Keyframe interval

Keyframe interval should always be set to two seconds when broadcasting using DaCast.

Connecting your encoder to your OVP

Encoder Settings for HLS Live Streaming - connectionThe final element in encoder settings is to connect to your online video platform. Generally, this requires gathering a few pieces of information. On DaCast, this information includes:

  • Stream name
  • Stream URL
  • Login code (unique for each stream)
  • Login password

This information will be automatically generated when you create a new channel. To get this info, navigate to the “encoder settings” portion of a live channel, and select the requisite RTMP encoder from the list.

Conclusion

That’s all there is to it! Configuring encoder settings can seem impossible to a beginner. However, it’s quite easy with a little practice. Whenever you need a reference, just skim this article. You can either follow our recommendations exactly, or use them as a guide. Whatever settings you choose, we always recommend conducting a test stream before your event.

Any questions? Let us know in the comments section, below! We love to hear from our readers and will respond as soon as we can. For regular tips on live streaming, as well as exclusive offers, we also invite you to join our LinkedIn group.

Not yet a DaCast client but interested to give our platform a try? You can take advantage of our 30-day free trial (no credit card required) by clicking the button below!

button

Leave a Reply

Your email address will not be published. Required fields are marked *

LINKEDIN