This section lists VP9 encoding recommendations for a variety of common profiles:

  • Highly optimized video for web and mobile (VOD)
  • Premium content distribution (VOD)
  • Sports, Animation, 10-bit content (VOD)
  • Live encoding
  • WebRTC

Introduction

When encoding video, there are a number of considerations:

  • Are you creating a single version of your media, or multiple versions at different bitrates and resolutions?
  • Are you creating a live video stream, or on-demand video files?
  • What type of media are you encoding - does it have a lot of motion? Detail? Animation?
  • Are you encoding for maximum quality (e.g. premium content) or speed (e.g. web conferencing?)

This section starts with settings for a basic on-demand video file, and then makes recommendations for all of these questions.

Basic Settings

Encoding Bitrates

The following bitrates are suggested as baselines for web and mobile distribution. These suggestions minimize bitrate which achieving video quality suitable for consumer web and mobile distribution; think of them as a 'low' bit rate recommendation that can still achieve reasonable quality.

Suggested Target Bitrates

Frame Size/Rate Avg. Bitrate (VOD, kbps) Avg. Bitrate (Live, kbps)
320x240p @ 24,25,30 150 250
640x360p @ 24,25,30 276 386
640x480p @ 24,25,30 512 (LQ), 750 (MQ) 720 (LQ), 1024 (MQ)
1280x720p @ 24,25,30 1024 1440
1280x720p @ 50,60 1800 2500
1920x1080p @ 24,25,30 1800 2500
1920x1080p @ 50,60 3000 4200
2560x1440p @ 24,25,30 6000 8400
2560x1440p @ 50,60 9000 12600
3840x2160p @ 24,25,30 12000 16800
3840x2160p @ 50,60 18000 25200

Figure 2a: Target Bitrates

VOD Encoding Settings

Settings for Most Types of Content

For most content types, we recommend using constrained quality (CQ) mode, with bitrate caps. Most videos contain a mix of high-motion scenes (e.g. action sequences), and scenes with less detail (e.g. conversations). CQ mode allows the encoder to maintain a reasonable quality level during longer, easier scenes (without wasting bits) while allocating more bits for difficult sequences.

We also recommend allowing the bitrate range from 50% to 150% of target, using quality values as indicated in the chart below. This mode requires two- pass encoding, and it is recommended to use faster settings for HD and above as indicated below.

Encoder Settings for CQ Encoding

Frame Height Target Quality (CQ) Encoding Mode
240 37 TWO_PASS_MEDIUM
360 36 TWO_PASS_MEDIUM
480 34 (low quality) or 33 (medium quality) TWO_PASS_MEDIUM
720 32 TWO_PASS_FAST
1080 31 TWO_PASS_FAST
1440 24 TWO_PASS_FAST
2160 15 TWO_PASS_FAST

Figure 2b: CQ recommended settings

We finally recommend 240 frames of video between keyframes (for 30fps content this translates to 8 seconds). Keyframes are video frames which are self- sufficient; they don't rely upon any other frames to render (see GOP Structure for a more detailed explanation). For web and mobile playback, we allow generous spacing between keyframes because this allows the encoder to choose the 'best' placement of keyframes to maximize quality.

Example Command-Line Parameters: 640x360 Video

From above, the recommendations for 360p video are as follows:

  1. CQ level of 36 (see Figure 2b)
  2. Target bitrate of 276kbps (see Figure 2a)
  3. Minimum allowed bitrate of 138kbps (50% of target)
  4. Maximum allowed bitrate of 414kbps (150% of target)
  5. Maximum keyframe spacing of 240 seconds
  6. Two-pass, "Medium" profile

This gives the following command-line parameters for libvpx and FFmpeg:

libvpx

--end-usage=cq --cq-level=36 --target-bitrate=276 --minsection-pct=50 \
  --maxsection-pct=150 --kf-max-dist=240 --passes=2 --good --cpu-used=2

FFmpeg

-crf 36 -b:v 276k -minrate 138k -maxrate 414k -g 240 -good -speed 2

Premium Content Settings

In the examples above, we used fairly fast encoding settings to create our video streams efficiently. However, for some content (such as premium movies) it is worth spending more time during encoding to get a higher quality output.

For premium content, we recommend the same settings as above, but with different presets, instructing the encoder to spend more time optimizing for quality:

Premium Content Encoding Modes and Command-Line Parameters

Frame Height Encoding Mode libvpx FFmpeg
240 TWO_PASS_VERY_SLOW --good --cpu-used 0 -good -speed 0
360 TWO_PASS_VERY_SLOW --good --cpu-used 0 -good -speed 0
480 TWO_PASS_VERY_SLOW --good --cpu-used 0 -good -speed 0
720 TWO_PASS_SLOW --good --cpu-used 1 -good -speed 1
1080 TWO_PASS_MEDIUM --good --cpu-used 2 -good -speed 2
1440 TWO_PASS_MEDIUM --good --cpu-used 2 -good -speed 2
2160 TWO_PASS_MEDIUM --good --cpu-used 2 -good -speed 2

Figure 2c: Premium Content encoding modes

Sports, High Motion Content Settings

We recommend VBR encoding for sports content. Sports tend to have a fairly consistent level of high motion and complexity, and using VBR achieves higher quality during periods of lower motion than QP encoding.

For the command-line, the primary difference between QP and VBR mode is that you will not specify a CQ level; otherwise, the recommended settings are the same.

Example VBR Command-Line Parameters: 640x360 Video

libvpx

--end-usage=vbr --target-bitrate=276 --minsection-pct=50 --maxsection-pct=150 \
  --kf-max-dist=240 --passes=2 --good --cpu-used=2

FFmpeg

-b:v 276k -minrate 138k -maxrate 414k -g 240 -good -speed 2

Animation and Gaming Settings

Noisy / Low Quality Content Settings

For noisy content, we recommend increasing the number, and strength, of alt-ref frames. Alternate reference frames are 'invisible' frames, never shown to the user, but which are used as a reference when creating the final frames (you can read more information here).

The following parameters are recommended to instruct VP9 to use more alt-ref frames:

libvpx

--auto-alt-ref=1 --lag-in-frames-16 --arnr-maxframes=5 --arnr-strength=3

FFmpeg

10-Bit/HDR Encoding

For 10-bit encoding, you will want to use VP9 Profile 2. Encoding at 10-bit does not require any more bits, so the rest of the parameters are the same:

libvpx

--profile=2

FFmpeg

-profile 2

Live Encoding Settings

Live Streaming

Live encoding is typically done as CBR, which restricts the encoder's ability to maximize quality. For this reason, we will use higher bitrates as indicated in Figure 2a.

For live encoding, we also want to maximize threading. This is done by:

  1. Allowing VP9 to split the video into columns (which can be no less than 256 pixels wide, and must be a power of two);
  2. Indicating to VP9 to use more CPU power. The following table lists recommendations for each resolution.

Tiling and Threading Recommendations

Encoder Settings for CQ Encoding
Frame Size Number of tile-columns Number of threads
320x240 1 2
640x360 2 4
640x480 2 4
1280x720 4 8
1920x1080 4 8
2560x1440 8 16
3840x2160 8 16

Figure 2d. Recommended tiling and threading for live encoding

Live encoding will also set the deadline to 'realtime' to ensure performance, and will instruct alt-ref frames to not look into the future (which would introduce latency):

From this, the recommendations for live 360p video are as follows:

  1. CBR, target bitrate of 386kbps (see Figure 2a)
  2. 2 tile columns (see Figure 2d)
  3. 4 threads (see Figure 2d)
  4. Real-time performance
  5. No latency due to alternate frames (no frame lag)

This gives the following command-line parameters for libvpx and FFmpeg:

libvpx

--end-usage=cbr --target-bitrate=386 --cpu-used=4 --tile-columns=2 --rt --lag-in-frames=0

FFmpeg

ffmpeg -i tears_of_steel_1080p.webm -vf scale=640x480 -r 29.97 -b:v 386k \
  -minrate 386k -maxrate 386k -c:v libvpx-vp9 -c:a libopus output.webm

Live VP9 Encoding for DASH/YouTube

WebRTC Encoding