1
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>10.4. Encoding with the Xvid codec</title><link rel="stylesheet" href="default.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="MPlayer - Odtwarzacz filmów"><link rel="up" href="encoding-guide.html" title="Rozdział 10. Kodowanie przy użyciu MEncodera"><link rel="prev" href="menc-feat-enc-libavcodec.html" title="10.3. Encoding with the libavcodec codec family"><link rel="next" href="menc-feat-x264.html" title="10.5. Encoding with the x264 codec"><link rel="preface" href="howtoread.html" title="Jak czytać tę dokumentację"><link rel="chapter" href="intro.html" title="Rozdział 1. Wprowadzenie"><link rel="chapter" href="install.html" title="Rozdział 2. Instalacja"><link rel="chapter" href="usage.html" title="Rozdział 3. Sposób użycia"><link rel="chapter" href="cd-dvd.html" title="Rozdział 4. Używanie CD/DVD"><link rel="chapter" href="tv.html" title="Rozdział 5. TV"><link rel="chapter" href="radio.html" title="Rozdział 6. Radio"><link rel="chapter" href="video.html" title="Rozdział 7. Urządzenia wyjścia video"><link rel="chapter" href="ports.html" title="Rozdział 8. Porty"><link rel="chapter" href="mencoder.html" title="Rozdział 9. Podstawy używania MEncodera"><link rel="chapter" href="encoding-guide.html" title="Rozdział 10. Kodowanie przy użyciu MEncodera"><link rel="chapter" href="faq.html" title="Rozdział 11. FAQ - Często Zadawane Pytania"><link rel="appendix" href="bugreports.html" title="Dodatek A. Jak zgłaszać błędy"><link rel="appendix" href="skin.html" title="Dodatek B. Format skórki MPlayera"><link rel="subsection" href="menc-feat-xvid.html#menc-feat-xvid-intro" title="10.4.1. What options should I use to get the best results?"><link rel="subsection" href="menc-feat-xvid.html#menc-feat-xvid-encoding-options" title="10.4.2. Encoding options of Xvid"><link rel="subsection" href="menc-feat-xvid.html#menc-feat-xvid-encoding-profiles" title="10.4.3. Encoding profiles"><link rel="subsection" href="menc-feat-xvid.html#menc-feat-xvid-example-settings" title="10.4.4. Encoding setting examples"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">10.4. Encoding with the <code class="systemitem">Xvid</code>
2
codec</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="menc-feat-enc-libavcodec.html">Poprzedni</a> </td><th width="60%" align="center">Rozdział 10. Kodowanie przy użyciu <span class="application">MEncodera</span></th><td width="20%" align="right"> <a accesskey="n" href="menc-feat-x264.html">Następny</a></td></tr></table><hr></div><div class="sect1" title="10.4. Encoding with the Xvid codec"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="menc-feat-xvid"></a>10.4. Encoding with the <code class="systemitem">Xvid</code>
3
codec</h2></div></div></div><p>
4
<code class="systemitem">Xvid</code> is a free library for
5
encoding MPEG-4 ASP video streams.
6
Before starting to encode, you need to <a class="link" href="codec-installation.html#xvid" title="2.5.1. Xvid">
7
set up <span class="application">MEncoder</span> to support it</a>.
9
This guide mainly aims at featuring the same kind of information
10
as x264's encoding guide.
11
Therefore, please begin by reading
12
<a class="link" href="menc-feat-x264.html#menc-feat-x264-encoding-options-intro" title="10.5.1.1. Introduction">the first part</a>
14
</p><div class="sect2" title="10.4.1. What options should I use to get the best results?"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-intro"></a>10.4.1. What options should I use to get the best results?</h3></div></div></div><p>
15
Please begin by reviewing the
16
<code class="systemitem">Xvid</code> section of
17
<span class="application">MPlayer</span>'s man page.
18
This section is intended to be a supplement to the man page.
20
The Xvid default settings are already a good tradeoff between
21
speed and quality, therefore you can safely stick to them if
22
the following section puzzles you.
23
</p></div><div class="sect2" title="10.4.2. Encoding options of Xvid"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-encoding-options"></a>10.4.2. Encoding options of <code class="systemitem">Xvid</code></h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
24
<span class="bold"><strong>vhq</strong></span>
25
This setting affects the macroblock decision algorithm, where the
26
higher the setting, the wiser the decision.
27
The default setting may be safely used for every encode, while
28
higher settings always help PSNR but are significantly slower.
29
Please note that a better PSNR does not necessarily mean
30
that the picture will look better, but tells you that it is
31
closer to the original.
32
Turning it off will noticeably speed up encoding; if speed is
33
critical for you, the tradeoff may be worth it.
34
</p></li><li class="listitem"><p>
35
<span class="bold"><strong>bvhq</strong></span>
36
This does the same job as vhq, but does it on B-frames.
37
It has a negligible impact on speed, and slightly improves quality
39
</p></li><li class="listitem"><p>
40
<span class="bold"><strong>max_bframes</strong></span>
41
A higher number of consecutive allowed B-frames usually improves
42
compressibility, although it may also lead to more blocking artifacts.
43
The default setting is a good tradeoff between compressibility and
44
quality, but you may increase it up to 3 if you are bitrate-starved.
45
You may also decrease it to 1 or 0 if you are aiming at perfect
46
quality, though in that case you should make sure your
47
target bitrate is high enough to ensure that the encoder does not
48
have to increase quantizers to reach it.
49
</p></li><li class="listitem"><p>
50
<span class="bold"><strong>bf_threshold</strong></span>
51
This controls the B-frame sensitivity of the encoder, where a higher
52
value leads to more B-frames being used (and vice versa).
53
This setting is to be used together with <tt class="option">max_bframes</tt>;
54
if you are bitrate-starved, you should increase both
55
<tt class="option">max_bframes</tt> and <tt class="option">bf_threshold</tt>,
56
while you may increase <tt class="option">max_bframes</tt> and reduce
57
<tt class="option">bf_threshold</tt> so that the encoder may use more
58
B-frames in places that only <span class="bold"><strong>really</strong></span>
60
A low number of <tt class="option">max_bframes</tt> and a high value of
61
<tt class="option">bf_threshold</tt> is probably not a wise choice as it
62
will force the encoder to put B-frames in places that would not
63
benefit from them, therefore reducing visual quality.
64
However, if you need to be compatible with standalone players that
65
only support old DivX profiles (which only supports up to 1
66
consecutive B-frame), this would be your only way to
67
increase compressibility through using B-frames.
68
</p></li><li class="listitem"><p>
69
<span class="bold"><strong>trellis</strong></span>
70
Optimizes the quantization process to get an optimal tradeoff
71
between PSNR and bitrate, which allows significant bit saving.
72
These bits will in return be spent elsewhere on the video,
73
raising overall visual quality.
74
You should always leave it on as its impact on quality is huge.
75
Even if you are looking for speed, do not disable it until you
76
have turned down <tt class="option">vhq</tt> and all other more
77
CPU-hungry options to the minimum.
78
</p></li><li class="listitem"><p>
79
<span class="bold"><strong>hq_ac</strong></span>
80
Activates a better coefficient cost estimation method, which slightly
81
reduces file size by around 0.15 to 0.19% (which corresponds to less
82
than 0.01dB PSNR increase), while having a negligible impact on speed.
83
It is therefore recommended to always leave it on.
84
</p></li><li class="listitem"><p>
85
<span class="bold"><strong>cartoon</strong></span>
86
Designed to better encode cartoon content, and has no impact on
87
speed as it just tunes the mode decision heuristics for this type
89
</p></li><li class="listitem"><p>
90
<span class="bold"><strong>me_quality</strong></span>
91
This setting is to control the precision of the motion estimation.
92
The higher <tt class="option">me_quality</tt>, the more
93
precise the estimation of the original motion will be, and the
94
better the resulting clip will capture the original motion.
96
The default setting is best in all cases;
97
thus it is not recommended to turn it down unless you are
98
really looking for speed, as all the bits saved by a good motion
99
estimation would be spent elsewhere, raising overall quality.
100
Therefore, do not go any lower than 5, and even that only as a last
102
</p></li><li class="listitem"><p>
103
<span class="bold"><strong>chroma_me</strong></span>
104
Improves motion estimation by also taking the chroma (color)
105
information into account, whereas <tt class="option">me_quality</tt>
106
alone only uses luma (grayscale).
107
This slows down encoding by 5-10% but improves visual quality
108
quite a bit by reducing blocking effects and reduces file size by
110
If you are looking for speed, you should disable this option before
111
starting to consider reducing <tt class="option">me_quality</tt>.
112
</p></li><li class="listitem"><p>
113
<span class="bold"><strong>chroma_opt</strong></span>
114
Is intended to increase chroma image quality around pure
115
white/black edges, rather than improving compression.
116
This can help to reduce the "red stairs" effect.
117
</p></li><li class="listitem"><p>
118
<span class="bold"><strong>lumi_mask</strong></span>
119
Tries to give less bitrate to part of the picture that the
120
human eye cannot see very well, which should allow the encoder
121
to spend the saved bits on more important parts of the picture.
122
The quality of the encode yielded by this option highly depends
123
on personal preferences and on the type and monitor settings
124
used to watch it (typically, it will not look as good if it is
125
bright or if it is a TFT monitor).
126
</p></li><li class="listitem"><p>
127
<span class="bold"><strong>qpel</strong></span>
128
Raise the number of candidate motion vectors by increasing
129
the precision of the motion estimation from halfpel to
131
The idea is to find better motion vectors which will in return
132
reduce bitrate (hence increasing quality).
133
However, motion vectors with quarterpel precision require a
134
few extra bits to code, but the candidate vectors do not always
135
give (much) better results.
136
Quite often, the codec still spends bits on the extra precision,
137
but little or no extra quality is gained in return.
138
Unfortunately, there is no way to foresee the possible gains of
139
<tt class="option">qpel</tt>, so you need to actually encode with and
140
without it to know for sure.
142
<tt class="option">qpel</tt> can be almost double encoding time, and
143
requires as much as 25% more processing power to decode.
144
It is not supported by all standalone players.
145
</p></li><li class="listitem"><p>
146
<span class="bold"><strong>gmc</strong></span>
147
Tries to save bits on panning scenes by using a single motion
148
vector for the whole frame.
149
This almost always raises PSNR, but significantly slows down
150
encoding (as well as decoding).
151
Therefore, you should only use it when you have turned
152
<tt class="option">vhq</tt> to the maximum.
153
<code class="systemitem">Xvid</code>'s GMC is more
154
sophisticated than DivX's, but is only supported by few
156
</p></li></ul></div></div><div class="sect2" title="10.4.3. Encoding profiles"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-encoding-profiles"></a>10.4.3. Encoding profiles</h3></div></div></div><p>
157
Xvid supports encoding profiles through the <tt class="option">profile</tt> option,
158
which are used to impose restrictions on the properties of the Xvid video
159
stream such that it will be playable on anything which supports the
161
The restrictions relate to resolutions, bitrates and certain MPEG-4
163
The following table shows what each profile supports.
164
</p><div class="informaltable"><table border="1"><colgroup><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"><col align="center"></colgroup><tbody><tr><td align="center"> </td><td colspan="4" align="center">Simple</td><td colspan="6" align="center">Advanced Simple</td><td colspan="6" align="center">DivX</td></tr><tr><td align="center">Profile name</td><td align="center">0</td><td align="center">1</td><td align="center">2</td><td align="center">3</td><td align="center">0</td><td align="center">1</td><td align="center">2</td><td align="center">3</td><td align="center">4</td><td align="center">5</td><td align="center">Handheld</td><td align="center">Portable NTSC</td><td align="center">Portable PAL</td><td align="center">Home Theater NTSC</td><td align="center">Home Theater PAL</td><td align="center">HDTV</td></tr><tr><td align="center">Width [pixels]</td><td align="center">176</td><td align="center">176</td><td align="center">352</td><td align="center">352</td><td align="center">176</td><td align="center">176</td><td align="center">352</td><td align="center">352</td><td align="center">352</td><td align="center">720</td><td align="center">176</td><td align="center">352</td><td align="center">352</td><td align="center">720</td><td align="center">720</td><td align="center">1280</td></tr><tr><td align="center">Height [pixels]</td><td align="center">144</td><td align="center">144</td><td align="center">288</td><td align="center">288</td><td align="center">144</td><td align="center">144</td><td align="center">288</td><td align="center">288</td><td align="center">576</td><td align="center">576</td><td align="center">144</td><td align="center">240</td><td align="center">288</td><td align="center">480</td><td align="center">576</td><td align="center">720</td></tr><tr><td align="center">Frame rate [fps]</td><td align="center">15</td><td align="center">15</td><td align="center">15</td><td align="center">15</td><td align="center">30</td><td align="center">30</td><td align="center">15</td><td align="center">30</td><td align="center">30</td><td align="center">30</td><td align="center">15</td><td align="center">30</td><td align="center">25</td><td align="center">30</td><td align="center">25</td><td align="center">30</td></tr><tr><td align="center">Max average bitrate [kbps]</td><td align="center">64</td><td align="center">64</td><td align="center">128</td><td align="center">384</td><td align="center">128</td><td align="center">128</td><td align="center">384</td><td align="center">768</td><td align="center">3000</td><td align="center">8000</td><td align="center">537.6</td><td align="center">4854</td><td align="center">4854</td><td align="center">4854</td><td align="center">4854</td><td align="center">9708.4</td></tr><tr><td align="center">Peak average bitrate over 3 secs [kbps]</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">800</td><td align="center">8000</td><td align="center">8000</td><td align="center">8000</td><td align="center">8000</td><td align="center">16000</td></tr><tr><td align="center">Max. B-frames</td><td align="center">0</td><td align="center">0</td><td align="center">0</td><td align="center">0</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">0</td><td align="center">1</td><td align="center">1</td><td align="center">1</td><td align="center">1</td><td align="center">2</td></tr><tr><td align="center">MPEG quantization</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td></tr><tr><td align="center">Adaptive quantization</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td></tr><tr><td align="center">Interlaced encoding</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">X</td><td align="center">X</td><td align="center">X</td></tr><tr><td align="center">Quarterpixel</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td></tr><tr><td align="center">Global motion compensation</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center">X</td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td><td align="center"> </td></tr></tbody></table></div></div><div class="sect2" title="10.4.4. Encoding setting examples"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-example-settings"></a>10.4.4. Encoding setting examples</h3></div></div></div><p>
165
The following settings are examples of different encoding
166
option combinations that affect the speed vs quality tradeoff
167
at the same target bitrate.
169
All the encoding settings were tested on a 720x448 @30000/1001 fps
170
video sample, the target bitrate was 900kbps, and the machine was an
171
AMD-64 3400+ at 2400 MHz in 64 bits mode.
172
Each encoding setting features the measured encoding speed (in
173
frames per second) and the PSNR loss (in dB) compared to the "very
174
high quality" setting.
175
Please understand that depending on your source, your machine type
176
and development advancements, you may get very different results.
177
</p><div class="informaltable"><table border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Description</th><th>Encoding options</th><th>speed (in fps)</th><th>Relative PSNR loss (in dB)</th></tr></thead><tbody><tr><td>Very high quality</td><td><tt class="option">chroma_opt:vhq=4:bvhq=1:quant_type=mpeg</tt></td><td>16fps</td><td>0dB</td></tr><tr><td>High quality</td><td><tt class="option">vhq=2:bvhq=1:chroma_opt:quant_type=mpeg</tt></td><td>18fps</td><td>-0.1dB</td></tr><tr><td>Fast</td><td><tt class="option">turbo:vhq=0</tt></td><td>28fps</td><td>-0.69dB</td></tr><tr><td>Realtime</td><td><tt class="option">turbo:nochroma_me:notrellis:max_bframes=0:vhq=0</tt></td><td>38fps</td><td>-1.48dB</td></tr></tbody></table></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="menc-feat-enc-libavcodec.html">Poprzedni</a> </td><td width="20%" align="center"><a accesskey="u" href="encoding-guide.html">Początek rozdziału</a></td><td width="40%" align="right"> <a accesskey="n" href="menc-feat-x264.html">Następny</a></td></tr><tr><td width="40%" align="left" valign="top">10.3. Encoding with the <code class="systemitem">libavcodec</code>
178
codec family </td><td width="20%" align="center"><a accesskey="h" href="index.html">Spis treści</a></td><td width="40%" align="right" valign="top"> 10.5. Encoding with the
179
<code class="systemitem">x264</code> codec</td></tr></table></div></body></html>