Finding the perfect recipe for quality in your live stream can be tricky. There are many ways to manipulate your settings in Wirecast to help boost or lower quality in order to take full advantage of your upload speeds, but even these can prove to be tricky as well. One variable in particular can take you one step closer to finding that perfect balance of quality and data usage: Key Framing
What are Key Frames?
Key frames at their most basic level are single frames within video that provide a reference point, similar to mile markers on a freeway. These special frames serve many purposes in video animation, non-linear editing, and in our case, video compression. In animation, key frames mark points at the beginning and end of a single animation, whereas in editing, they are used as markers for certain editing actions like volume changes. Key frames in video compression, though, are arguably more complicated.
In order to understand how a key frame helps to encode video, let’s first do a quick overview of the encoding process. Live HD video is too data intensive to be quickly and smoothly transferred over most networks, so Wirecast has built in encoding processes that allow the stream to be compressed to a more manageable size. In order to do this, the encoder will only store data that is seeing significant change frame by frame. For example, in a talking head video like you see here:
The only change to the video over the course of a 30 minute stream will be the movement of my mouth and a couple side by side movements of my head. Half of the shot is the background, which is static for the entire stream. Wirecast can recognize the difference between the static background and more dynamic foreground and will store only the data corresponding to the changes that occur frame by frame. This allows Wirecast to focus its energy on half of the video stream, allowing for a smaller file size.
Key frames are used to mark the basis for detecting these changes. Depending on where I put my key frames, Wirecast will use those specific frames as a starting point for encoding video in the least resource intensive manner, leading to a smaller and more manageable stream
How Can it Help?
Now that the concept is clear, how can we start to implement the practice? By setting a key frame rate. Similar to setting the frame rate of the video itself, we can set a key frame rate that will create a key frame every “x” frames. Remember, a key frame rate is different than the key frame itself. A high key frame rate actually means less key frames, as it refers to the interval between each one. The larger number used for the key frame rate results in more time between key frames.
Depending on the amount of movement you expect in your video, you can adjust the rate up or down. If you have very little movement, like the piano player to the left, you can get away with a longer interval between key frames, meaning a high key frame rate is possible. Conversely, if you are streaming something incredibly dynamic like the soccer/football game below, it is better to have a shorter interval between key frames in order to capture the constant movement, therefore necessitating a lower key frame rate.
While it is easy to boost or lower your key frame rate to match your subject matter, we still have bandwidth limitations to worry about. In sports, a low key frame rate (many key frames) is nice, but also very data intensive. Because we are creating numerous full data frames to base our movement off of, the overall stream size is increased. Make sure you spend some time exploring the best ratio of quality to resource usage in order to stay within the parameters set by your bandwidth.
How Can I Manipulate my Key Frames in Wirecast?
Adding key frames in Wirecast is simple. In the “Window” menu tab, open “Encoder Presets.” As long as you are using a h.264 or x264 encoder, which comprise a majority of the encoder options, there will be a box to add your key frame rate. Start with a low frame rate for video with constant movement, and see how high you can get it with more static video. There are no concrete guidelines to apply to your settings, so make adjustments as you see necessary. After a few tries, an adjusted key frame rate will help to keep your video quality high, while lowering the required bandwidth needed for a flawless stream.