About encoding source video
Configuring source encoding presetsCalculating source encoding presets
Source encode cheat sheet
Testing your encoding setup
About encoding source video
When using Wowza Streaming Cloud, you create one bitrate rendition, also called a source encode, of the stream you're publishing to Wowza Streaming Cloud. This is the master bitrate rendition, if you will. Wowza Streaming Cloud uses the master rendition to create one or more renditions of equal or smaller size that it delivers to your audience. In other words, Wowza Streaming Cloud transcodes the stream and creates multiple, keyframe-aligned, adaptive-bitrate output renditions that play seamlessly regardless of where the audience is watching, or what device or connectivity they're using.
Creating source encoding presets is a balancing act, a tradeoff between quality and bandwidth. Of course you want to create the best possible quality source encode, but higher quality means more data, and the stream size is limited by the bandwidth you have to transmit the encode from your encoder to Wowza Streaming Cloud.
Configuring source encoding presets
Since you only send one--count 'em, one--source encode to Wowza Streaming Cloud, make it a good one. As the old adage goes, garbage in, garbage out: Wowza Streaming Cloud can't generate any output renditions that are of higher quality than what it receives from the video source.
With the basic live stream workflow, Wowza Streaming Cloud creates output renditions automatically based on the resolution of source video. The higher the resolution of the source video, the more output renditions Wowza Streaming Cloud transcodes. You can edit or remove renditions in the Wowza Streaming Cloud advanced mode, but generally speaking, you should prepare a source encode that allows Wowza Streaming Cloud to automatically deliver suitable, high-quality streams across any kind of client connection, to any device.
In your camera or source encoder, you'll be able to configure some or all of the attributes described here. Use these guidelines to help you create high-quality encoding presets tailored for streaming live events using Wowza Streaming Cloud.
Note: These guidelines are intended to supplement, not replace, the documentation provided by the publisher or manufacturer of your camera or source encoder. Check your camera or source encoder documentation for more information on its capabilities and settings.
H.264 encoding presets can be contained in any of several types of wrapper--.MP4, .F4V, and others. Wowza Streaming Cloud accepts H.264-encoded content in an MP4 container for live streams.
- Accepted encode format - H.264
- Accepted audio formats - AAC, MP3
- Accepted container - MP4
Aspect ratio and frame size - Aspect ratio and frame size are interrelated.
- Frame size refers to the dimensions, or the width and height, of the video frame, measured in pixels. Width comes first, followed by height: The frame size 640x480 is 640 pixels wide by 480 pixels high.
Resolution is often used interchangeably with frame size, but it's not the same thing. Resolution is the total number of pixels in a frame: the width times the height of the frame. The resolution of a 640x480 frame is 307,200 pixels. Higher resolutions mean sharper images.
- Aspect ratio is the width of the video frame divided by its height. The aspect ratio of a 640x480 frame is 1.33 or, when expressed as a proportion of width to height, 4:3 (the frame contains 4 vertical lines for every 3 horizontal lines).
Two aspect ratios are commonly used in video streaming: 4:3, which was the standard for traditional CRT television sets and is still used by DVDs; and 16:9, which is the newer, widescreen aspect ratio used with high-definition (HD) playback.
High-definition video is considered any 16:9 video whose frame height is 720 pixels or higher--in other words, 1280x720 or 1920x1080 pixels. Standard-definition video has a 4:3 aspect ratio and a frame height of 480 pixels (640x480).
Some common aspect ratios for source video include:
Aspect Ratio Frame Size Often called 16:9 3840 x 2160 4K UHD, Ultra HD (UHD), UHDTV-1, 2160p 1920 x 1080 Full HD (FHD), 1080p, or 1080i 1280 x 720 HD or 720p 1024 x 576 Wide Super VGA (WSVGA) 4:3 800 x 600 Super VGA (SVGA) 640 x 480 VGA 320 x 240 Quarter VGA (QVGA)
Note: Encodings and bitrate renditions are often named for the frame height, such as 1080p or 1080i, where "p" refers to "progressive" (noninterlaced) scanning and the "i" refers to "interlaced" scanning. The "p" does not mean "pixels."
When specifying the aspect ratio in your source encoder, use the same one that you intend to deliver to viewers, either 16:9 or 4:3. Otherwise, the video will be cropped or stretched in the player. Then, choose a frame size that corresponds to the aspect ratio.
Encoders compress video using 16x16-pixel blocks. For the most efficient encoding, make sure the frame width and height are divisible by 16, or at least by 8.
Bits per pixel - The number of bits per pixel varies depending on the content of the video. The more motion and action in the stream, the more bits per pixel you need and the less compression can be performed. Bits per pixel typically range from 0.10 for limited action content to 0.15 for high motion, complex action.
Video bitrate - The video bitrate is the amount of data in 1 second of video and it is typically measured in kilobits per second, or Kbps. The formula for calculating bitrate is:
(bits/pixel x (width x height) x frame rate)/1000
Again, a higher bitrate can contain more data, but you must have the bandwidth to accommodate it. See Calculating source encoding presets.
Audio bitrate - The audio bitrate is the amount of data in 1 second of audio, also measured in Kbps. Audio bitrate can scale for bandwidth and device, too. Typical audio bitrates are 32 Kbps or 64 Kbps for voice content, or 96 Kbps or 128 Kbps for music or more complex audio.
Audio sample rate - The higher the sample rate, the more accurately the sound plays back. Audio for streaming video is typically sampled at 48,000 Hz.
Frame rate - The number of frames in 1 second of video. The slower the frame rate, the lower the video quality. High-definition devices typically capture video at 30 or 60 frames per second (fps), but the standard for video streaming is 29.97 fps in the US and Japan, 25 fps in the rest of the world. By default, Wowza Streaming Cloud uses the source encode frame rate for all output renditions that it transcodes.
Keyframes - Keyframes mark the interval used to compress a group of video frames. Keyframe intervals, also called i-frame intervals, are also used as seek points in players. A seek point indicates where an adaptive bitrate rendition can be switched in a stream. For live streams, keyframe intervals should be 2 seconds, so if your frame rate is 30 fps, the keyframe interval will be 60 frames. Note that too many keyframes can result in poor (stuttered) playback.
Constant or variable bitrate - Constant bitrate (CBR) encoding is faster than variable bitrate (VBR) but results in lower-quality video in complex or high-motion content. VBR encoding adjusts the bitrate depending on the complexity of the content, which yields higher-quality playback. When using VBR for live streaming, constrain the data rate of VBR source encode to 110% of the target bitrate to avoid buffering or dropped frames.
Profile - The profile determines how the H.264 codec compresses the stream. Greater compression produces smaller streams; less compression generally means better quality. Profiles are based on the streaming application:
- Main is suited for standard-definition broadcast and desktop streaming.
- Baseline is suited for playback on mobile devices and for compatibility with older playback devices.
- High is geared for high-definition playback devices.
When choosing a profile for your source encode, consider how the majority of your viewers will ultimately watch your stream--don't use the High profile if your audience will be watching on their iPhones, but do remember that your source encode is your master bitrate rendition. Wowza Streaming Cloud generates its highest bitrate rendition directly from the source encode, so always prepare the best-quality source encode that you can.
Calculating source encoding presets
When preparing a source encode, use the following rules of thumb to make sure the size of the encode doesn't exceed your available bandwidth.
- Determine the bandwidth for your source encode.
- If you're sending a backup source encode, factor in 50% more data.
- Allow 40% of your total bandwidth for overhead.
Say you have a 10 Mbps connection between your encoder and Wowza Streaming Cloud. Allowing 40% for overhead, your total encoding presets (primary and backup) should not exceed 6 Mbps total, or 3 Mbps each. You could easily prepare a primary and backup encode of 1080p quality (1920x1080) at the maximum video bitrate (6000 Kbps) with an audio bitrate of 128 Kbps.
Source encode cheat sheet
If you're not mathematically inclined--or you just want a good starting point--use the following recommended settings to create source encoding presets for Wowza Streaming Cloud.
|Maximum video bitrate
||400 Kbps||700 Kbps||1200 Kbps||2000 Kbps||4000 Kbps||6000 Kbps||20,000 Kbps|
|Recommended video bitrate
||256 Kbps||512 Kbps||1024 Kbps||1600 Kbps||2640 Kbps||4400 Kbps||12,000 Kbps|
|Minimum video bitrate
||128 Kbps||300 Kbps||400 Kbps||512 Kbps||1600 Kbps||3200 Kbps||8000 Kbps|
Testing your encoding setup
After you've configured your encoder, test your setup to make sure that your live event runs smoothly. Under the Wowza Streaming Cloud standard plan, Wowza support offers a 48-hour turnaround during business hours (6am to 8pm Eastern time, excluding holidays), so make sure to test your entire setup at least three business days before your event. Testing your end-to-end setup a week ahead is even better, as it allows you time to troubleshoot and fix problems. To test your entire setup:
- Run the primary and backup encoders with a test stream for at least 30 minutes each.
- Preview the stream using the Wowza Streaming Cloud player on all kinds of screens and devices.
- View the stream on your Wowza Streaming Cloud hosted page, if you have one.
- View the stream on external players and websites, if you're using them.
- If you're recording, check that the recording captures supported audio and video as expected.
It's also a good idea, on the day of the event, to make sure your video source is ready to stream at least 2 hours before the scheduled start time, and to start the video source at least 15 minutes before the event begins.
Originally Published: 02-24-2015.
If you're having problems or want to discuss this article, post in our forum.