14.5. Encoding with the x264 codec

Chapter 14. Encoding with MEncoder

14.5. Encoding with the x264 codec

x264 is a free library for encoding H.264/AVC video streams. Before starting to encode, you need to .

14.5.1. Encoding options of x264

Please begin by reviewing the x264 section of MPlayer's man page. This section is intended to be a supplement to the man page. Here you will find quick hints about which options are most likely to interest most people. The man page is more terse, but also more exhaustive, and it sometimes offers much better technical detail.

14.5.1.1. Introduction

This guide considers two major categories of encoding options:

  1. Options which mainly trade off encoding time vs. quality

  2. Options which may be useful for fulfilling various personal preferences and special requirements

Ultimately, only you can decide which options are best for your purposes. The decision for the first class of options is the simplest: you only have to decide whether you think the quality differences justify the speed differences. For the second class of options, preferences may be far more subjective, and more factors may be involved. Note that some of the "personal preferences and special requirements" options can still have large impacts on speed or quality, but that is not what they are primarily useful for. A couple of the "personal preference" options may even cause changes that look better to some people, but look worse to others.

Before continuing, you need to understand that this guide uses only one quality metric: global PSNR. For a brief explanation of what PSNR is, see on PSNR. Global PSNR is the last PSNR number reported when you include the psnr option in x264encopts. Any time you read a claim about PSNR, one of the assumptions behind the claim is that equal bitrates are used.

Nearly all of this guide's comments assume you are using two pass. When comparing options, there are two major reasons for using two pass encoding. First, using two pass often gains around 1dB PSNR, which is a very big difference. Secondly, testing options by doing direct quality comparisons with one pass encodes introduces a major confounding factor: often varies significantly with each encode. It is not always easy to tell whether quality changes are due mainly to changed options, or if they mostly reflect essentially random differences in the achieved bitrate.

14.5.1.2. Options which primarily affect speed and quality

14.5.1.3. Options pertaining to miscellaneous preferences

14.5.2. Encoding setting examples

The following settings are examples of different encoding option combinations that affect the speed vs quality tradeoff at the same target bitrate.

All the encoding settings were tested on a 720x448 @30000/1001 fps video sample, the target was 900kbps, and the machine was an AMD-64 3400+ at 2400 MHz in 64 mode. Each encoding setting features the measured encoding speed (in frames per second) and the PSNR loss (in dB) compared to the "very high quality" setting. Please understand that depending on your source, your machine type and development advancements, you may get very different results.

Description Encoding options speed (in fps) Relative PSNR loss (in dB)
Very high quality subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b 6fps 0dB
High quality subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b 13fps -0.89dB
Fast subq=4:bframes=2:b_pyramid:weight_b 17fps -1.48dB

14.4. Encoding with the Xvid codec 14.6. Encoding with the Video For Windows codec family