Best Practices for Live Streaming
Part 2. - Compression
In addition to bitrate and framerate there are several settings you can adjust for optimal quality. In many cases the preset values will be adequate, however it is important to know how and when to change these settings.
- Key frame. A key frame is a point in encoded video where the data for the entire frame is transmitted, rather than just the changes. Key frames are generally inserted when there is a scene change. The key frame setting is the minimum time between points where the encoder will insert key frames (they may be inserted more often automatically, if necessary). Decreasing the distance between key frames can improve the quality of the video. If you use a longer key frame distance, additional key frames are inserted when necessary; for example, when a scene changes. Keep in mind, though, that a long key frame distance will affect the amount of time a user may need to wait for video in a broadcast scenario.
- Buffer size. The bit rate and quality of content fluctuate within the confines of the buffer size. A larger buffer size enables more bits within the buffer range to be allocated to complex scenes. For example, if you set the buffer size to 10 seconds, the codec may choose to allocate x number of bytes to the first 8 seconds, and the rest during the last 2 seconds. This allows for the more complex parts of the video to have more bits allocated within the buffer. Typically, increasing the buffer will improve overall quality. However, it also increases the delay between the time when the user requests the content, and playing starts. For lower bit rates, it is recommended to increase the buffer size. For higher bit rates, increasing the buffer size has a smaller impact on quality.
- Video smoothness. Video smoothness determines the tradeoff between sharp images and smooth motion. Video appears smooth when objects move easily from one position to another on the screen, and the edges of objects are not jagged. Video appears clear when images and motion are well-defined and clearly delineated. The bit rate setting determines the number of bits that can be allocated over a period of video. Based on this setting, the codec can choose to include more frames, which results in the images appearing smoother. However, each frame uses fewer bits. With a higher video smoothness value, the codec may include fewer frames. This increases the number of bits allocated per frame, resulting in sharper images; however, the image may not appear as smooth. The video smoothness setting only comes into effect when there are not enough bits to encode at the specified frame rate, and a tradeoff must be made. At higher bit rates, this value can be increased. If you are dropping frames during encoding, consider decreasing video smoothness.