1
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"><title>14.4. Encoding with the XviD
2
codec</title><link rel="stylesheet" href="default.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="MPlayer - Odtwarzacz film�w"><link rel="up" href="encoding-guide.html" title="Rozdzia� 14. Kodowanie przy u�yciu MEncodera"><link rel="prev" href="menc-feat-enc-libavcodec.html" title="14.3. Encoding with the libavcodec
3
codec family"><link rel="next" href="menc-feat-x264.html" title="14.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="faq.html" title="Rozdzia� 5. FAQ - Cz�sto Zadawane Pytania"><link rel="chapter" href="formats.html" title="Rozdzia� 6. Kontenery"><link rel="chapter" href="codecs.html" title="Rozdzia� 7. Obs�ugiwane kodeki"><link rel="chapter" href="video.html" title="Rozdzia� 8. Urz�dzenia wyj�cia video"><link rel="chapter" href="audio.html" title="Rozdzia� 9. Urz�dzenia wyj�ciowe audio"><link rel="chapter" href="tv.html" title="Rozdzia� 10. TV"><link rel="chapter" href="radio.html" title="Rozdzia� 11. Radio"><link rel="chapter" href="ports.html" title="Rozdzia� 12. Porty"><link rel="chapter" href="mencoder.html" title="Rozdzia� 13. Podstawy u�ywania MEncodera"><link rel="chapter" href="encoding-guide.html" title="Rozdzia� 14. Kodowanie przy u�yciu MEncodera"><link rel="appendix" href="bugreports.html" title="Dodatek A. Jak zg�asza� b��dy"><link rel="appendix" href="bugs.html" title="Dodatek B. Znane b��dy"><link rel="appendix" href="skin.html" title="Dodatek C. Format sk�rki MPlayera"><link rel="appendix" href="history.html" title="Dodatek D. Historia"><link rel="subsection" href="menc-feat-xvid.html#menc-feat-xvid-intro" title="14.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="14.4.2. Encoding options of XviD"><link rel="subsection" href="menc-feat-xvid.html#menc-feat-xvid-encoding-profiles" title="14.4.3. Encoding profiles"><link rel="subsection" href="menc-feat-xvid.html#menc-feat-xvid-example-settings" title="14.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">14.4. Encoding with the <code class="systemitem">XviD</code>
4
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� 14. 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" lang="pl"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="menc-feat-xvid"></a>14.4. Encoding with the <code class="systemitem">XviD</code>
5
codec</h2></div></div></div><p>
6
<code class="systemitem">XviD</code> is a free library for
7
encoding MPEG-4 ASP video streams.
8
Before starting to encode, you need to <a href="video-codecs.html#xvid" title="7.1.7. XviD">
9
set up <span class="application">MEncoder</span> to support it</a>.
11
This guide mainly aims at featuring the same kind of information
12
as x264's encoding guide.
13
Therefore, please begin by reading
14
<a href="menc-feat-x264.html#menc-feat-x264-encoding-options-intro" title="14.5.1.1. Introduction">the first part</a>
16
</p><div class="sect2" lang="pl"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-intro"></a>14.4.1. What options should I use to get the best results?</h3></div></div></div><p>
17
Please begin by reviewing the
18
<code class="systemitem">XviD</code> section of
19
<span class="application">MPlayer</span>'s man page.
20
This section is intended to be a supplement to the man page.
22
The XviD default settings are already a good tradeoff between
23
speed and quality, therefore you can safely stick to them if
24
the following section puzzles you.
25
</p></div><div class="sect2" lang="pl"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-encoding-options"></a>14.4.2. Encoding options of <code class="systemitem">XviD</code></h3></div></div></div><div class="itemizedlist"><ul type="disc"><li><p>
26
<span class="bold"><strong>vhq</strong></span>
27
This setting affects the macroblock decision algorithm, where the
28
higher the setting, the wiser the decision.
29
The default setting may be safely used for every encode, while
30
higher settings always help PSNR but are significantly slower.
31
Please note that a better PSNR does not necessarily mean
32
that the picture will look better, but tells you that it is
33
closer to the original.
34
Turning it off will noticeably speed up encoding; if speed is
35
critical for you, the tradeoff may be worth it.
37
<span class="bold"><strong>bvhq</strong></span>
38
This does the same job as vhq, but does it on B-frames.
39
It has a negligible impact on speed, and slightly improves quality
42
<span class="bold"><strong>max_bframes</strong></span>
43
A higher number of consecutive allowed B-frames usually improves
44
compressibility, although it may also lead to more blocking artifacts.
45
The default setting is a good tradeoff between compressibility and
46
quality, but you may increase it up to 3 if you are bitrate-starved.
47
You may also decrease it to 1 or 0 if you are aiming at perfect
48
quality, though in that case you should make sure your
49
target bitrate is high enough to ensure that the encoder does not
50
have to increase quantizers to reach it.
52
<span class="bold"><strong>bf_threshold</strong></span>
53
This controls the B-frame sensitivity of the encoder, where a higher
54
value leads to more B-frames being used (and vice versa).
55
This setting is to be used together with <tt class="option">max_bframes</tt>;
56
if you are bitrate-starved, you should increase both
57
<tt class="option">max_bframes</tt> and <tt class="option">bf_threshold</tt>,
58
while you may increase <tt class="option">max_bframes</tt> and reduce
59
<tt class="option">bf_threshold</tt> so that the encoder may use more
60
B-frames in places that only <span class="bold"><strong>really</strong></span>
62
A low number of <tt class="option">max_bframes</tt> and a high value of
63
<tt class="option">bf_threshold</tt> is probably not a wise choice as it
64
will force the encoder to put B-frames in places that would not
65
benefit from them, therefore reducing visual quality.
66
However, if you need to be compatible with standalone players that
67
only support old DivX profiles (which only supports up to 1
68
consecutive B-frame), this would be your only way to
69
increase compressibility through using B-frames.
71
<span class="bold"><strong>trellis</strong></span>
72
Optimizes the quantization process to get an optimal tradeoff
73
between PSNR and bitrate, which allows significant bit saving.
74
These bits will in return be spent elsewhere on the video,
75
raising overall visual quality.
76
You should always leave it on as its impact on quality is huge.
77
Even if you are looking for speed, do not disable it until you
78
have turned down <tt class="option">vhq</tt> and all other more
79
CPU-hungry options to the minimum.
81
<span class="bold"><strong>hq_ac</strong></span>
82
Activates a better coefficient cost estimation method, which slightly
83
reduces filesize by around 0.15 to 0.19% (which corresponds to less
84
than 0.01dB PSNR increase), while having a negligible impact on speed.
85
It is therefore recommended to always leave it on.
87
<span class="bold"><strong>cartoon</strong></span>
88
Designed to better encode cartoon content, and has no impact on
89
speed as it just tunes the mode decision heuristics for this type
92
<span class="bold"><strong>me_quality</strong></span>
93
This setting is to control the precision of the motion estimation.
94
The higher <tt class="option">me_quality</tt>, the more
95
precise the estimation of the original motion will be, and the
96
better the resulting clip will capture the original motion.
98
The default setting is best in all cases;
99
thus it is not recommended to turn it down unless you are
100
really looking for speed, as all the bits saved by a good motion
101
estimation would be spent elsewhere, raising overall quality.
102
Therefore, do not go any lower than 5, and even that only as a last
105
<span class="bold"><strong>chroma_me</strong></span>
106
Improves motion estimation by also taking the chroma (color)
107
information into account, whereas <tt class="option">me_quality</tt>
108
alone only uses luma (grayscale).
109
This slows down encoding by 5-10% but improves visual quality
110
quite a bit by reducing blocking effects and reduces filesize by
112
If you are looking for speed, you should disable this option before
113
starting to consider reducing <tt class="option">me_quality</tt>.
115
<span class="bold"><strong>chroma_opt</strong></span>
116
Is intended to increase chroma image quality around pure
117
white/black edges, rather than improving compression.
118
This can help to reduce the "red stairs" effect.
120
<span class="bold"><strong>lumi_mask</strong></span>
121
Tries to give less bitrate to part of the picture that the
122
human eye cannot see very well, which should allow the encoder
123
to spend the saved bits on more important parts of the picture.
124
The quality of the encode yielded by this option highly depends
125
on personal preferences and on the type and monitor settings
126
used to watch it (typically, it will not look as good if it is
127
bright or if it is a TFT monitor).
129
<span class="bold"><strong>qpel</strong></span>
130
Raise the number of candidate motion vectors by increasing
131
the precision of the motion estimation from halfpel to
133
The idea is to find better motion vectors which will in return
134
reduce bitrate (hence increasing quality).
135
However, motion vectors with quarterpel precision require a
136
few extra bits to code, but the candidate vectors do not always
137
give (much) better results.
138
Quite often, the codec still spends bits on the extra precision,
139
but little or no extra quality is gained in return.
140
Unfortunately, there is no way to foresee the possible gains of
141
<tt class="option">qpel</tt>, so you need to actually encode with and
142
without it to know for sure.
144
<tt class="option">qpel</tt> can be almost double encoding time, and
145
requires as much as 25% more processing power to decode.
146
It is not supported by all standalone players.
148
<span class="bold"><strong>gmc</strong></span>
149
Tries to save bits on panning scenes by using a single motion
150
vector for the whole frame.
151
This almost always raises PSNR, but significantly slows down
152
encoding (as well as decoding).
153
Therefore, you should only use it when you have turned
154
<tt class="option">vhq</tt> to the maximum.
155
<code class="systemitem">XviD</code>'s GMC is more
156
sophisticated than DivX's, but is only supported by few
158
</p></li></ul></div></div><div class="sect2" lang="pl"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-encoding-profiles"></a>14.4.3. Encoding profiles</h3></div></div></div><p>
159
XviD supports encoding profiles through the <tt class="option">profile</tt> option,
160
which are used to impose restrictions on the properties of the XviD video
161
stream such that it will be playable on anything which supports the
163
The restrictions relate to resolutions, bitrates and certain MPEG-4
165
The following table shows what each profile supports.
166
</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">Quaterpixel</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" lang="pl"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-xvid-example-settings"></a>14.4.4. Encoding setting examples</h3></div></div></div><p>
167
The following settings are examples of different encoding
168
option combinations that affect the speed vs quality tradeoff
169
at the same target bitrate.
171
All the encoding settings were tested on a 720x448 @30000/1001 fps
172
video sample, the target bitrate was 900kbps, and the machine was an
173
AMD-64 3400+ at 2400 Mhz in 64 bits mode.
174
Each encoding setting features the measured encoding speed (in
175
frames per second) and the PSNR loss (in dB) compared to the "very
176
high quality" setting.
177
Please understand that depending on your source, your machine type
178
and development advancements, you may get very different results.
180
</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><p>
181
</p></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">14.3. Encoding with the <code class="systemitem">libavcodec</code>
182
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">�14.5. Encoding with the <code class="systemitem">x264</code> codec</td></tr></table></div></body></html>