1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
Description of what all those libavcodec options do ...
WARNING: I am no encoding expert so the recommendations might be bad ...
if you find any errors, missing stuff, ... send a patch or cvs commit if you
have an cvs account :)
lavcopts: (encoder options)
---------------------------
vqmin 2-31 (minimum quantizer) for pass1/2
1 is not recommended (much larger file, little quality difference (if u are lucky)
and other weird things (if u are less lucky))
weird things: msmpeg4, h263 will be very low quality
ratecontrol will be confused -> lower quality
some decoders will not be able to decode it
2 is recommended for normal mpeg4/mpeg1video encoding (default)
3 is recommended for h263(p)/msmpeg4
the reason for 3 instead of 2 is that 2 could lead to overflows
(this will be fixed for h263(p) by changing the quanizer per MB in
the future, but msmpeg4 doesnt support that so it cant be fixed for
that)
vqscale 1-31 quantizer for constant quantizer / constant quality encoding
1 is not recommended (much larger file, little quality difference and
possible other weird things)
lower means better quality but larger files
see vqmin
vqmax 1-31 (maximum quantizer) for pass1/2
31 default
10-31 should be a sane range
vqdiff 1-31 (maximum quantizer difference between I or P frames) for pass1/2
3 default
vmax_b_frames 0-4 (maximum number of B frames between non B frames)
0 no b frames (default)
0-2 is a sane range for mpeg4
vme 0-5 (motion estimation)
0 none (not recommanded, very lq)
1 full (not recommanded, too slow)
2 log (not recommanded, lq)
3 phods (not recommanded, lq)
4 EPZS (default)
5 X1
vhq (high quality mode)
encode each MB as in all modes and choose the best (this is slow but
better filesize/quality)
disabled by default
v4mv
allow 4 MV per MB (little difference in filesize/quality)
disabled by default
cannot be used with B frames (should now work in lq mode)
keyint 0-300 (maximum interval between keyframes)
keyframes are needed for seeking as seeking is only possible to a
keyframe but they need more space than non-keyframes so larger numbers here
mean slightly smaller files, but less precise seeking
0 no keyframes
>300 is not recommended as the quality might be bad (depends upon
decoder, encoder and luck)
for strict mpeg1/2/4 compliance this would have to be <=132
vb_strategy 0-1 for pass 2
0 allways use the max number of B frames (default)
1 avoid B frames in high motion scenes (this will cause bitrate
misprediction)
vpass
1 first pass
2 second pass
(only need to specify if two-pass encoding is used)
vbitrate (kbits per second) for pass1/2
800 is default
(if value is bigger then 16000 it is interpreted as bit not kbit!)
vratetol (filesize tolerance in kbit) for pass1/2
this is just an approximation, the real difference can be much smaller
or larger
1000-100000 is a sane range
8000 is default
vrc_maxrate (maximum bitrate in kbit/sec) for pass1/2
vrc_minrate (minimum bitrate in kbit/sec) for pass1/2
vrc_buf_size (buffer size in kbit) for pass1/2
this is for stuff like VCD
VCD: FIXME
SVCD: ...
DVD: ...
Note: vratetol should not be too large during the 2.pass or there might
be problems if vrc_(min|max)rate is used
vb_qfactor (-31.0-31.0) for pass1/2
1.25 is default
vi_qfactor (-31.0-31.0) for pass1/2
0.8 is default
vb_qoffset (-31.0-31.0) for pass1/2
1.25 is default
vi_qoffset (-31.0-31.0) for pass1/2
0.0 is default
if v{b|i}_qfactor > 0
I/B-Frame quantizer = P-Frame quantizer * v{b|i}_qfactor + v{b|i}_qoffset
else
do normal ratecontrol (dont lock to next P frame quantizer) and
set q= -q * v{b|i}_qfactor + v{b|i}_qoffset
tip: to do constant quantizer encoding with different quantizers for
I/P and B frames you can use:
vqmin=<ip_quant>:vqmax=<ip_quant>:vb_qfactor=<b_quant/ip_quant>
vqblur (0.0-1.0) quantizer blur (pass1)
0.0 qblur disabled
0.5 is the default
1.0 average the quantizer over all previous frames
larger values will average the quantizer more over time so that it will
be changed slower
vqblur (0.0-99.0) quantizer blur (pass2)
gaussian blur (gaussian blur cant be done during pass 1 as the future quantizers arent known)
0.5 is the default
larger values will average the quantizer more over time so that it will
be changed slower
vqcomp quantizer compression (for pass1/2)
depends upon vrc_eq
vrc_eq the main ratecontrol equation (for pass1/2)
1 constant bitrate
tex constant quality
1+(tex/avgTex-1)*qComp approximately the equation of the old ratecontrol code
tex^qComp with qcomp 0.5 or something like that (default)
infix operators: +,-,*,/,^
variables:
tex texture complexity
iTex,pTex intra, non intra texture complexity
avgTex average texture complexity
avgIITex average intra texture complexity in I frames
avgPITex average intra texture complexity in P frames
avgPPTex average non intra texture complexity in P frames
avgBPTex average non intra texture complexity in B frames
mv bits used for MVs
fCode maximum length of MV in log2 scale
iCount number of intra MBs / number of MBs
var spatial complexity
mcVar temporal complexity
qComp qcomp from the command line
isI, isP, isB is 1 if picture type is I/P/B else 0
Pi,E see ur favorite math book
functions:
max(a,b),min(a,b) maximum / minimum
gt(a,b) is 1 if a>b, 0 otherwise
lt(a,b) is 1 if a<b, 0 otherwise
eq(a,b) is 1 if a==b,0 otherwise
sin,cos,tan,sinh,cosh,tanh,exp,log,abs
vrc_override user specified quality for specific parts (ending credits ...) (for pass1/2)
<start-frame>,<end-frame>,<quality>[/<start-frame>,<end-frame>,<quality>[/...]]
quality 2..31 -> quantizer
quality -500..0 -> quality correcture in %
vrc_init_cplx (0-1000) initial complexity for pass1
vqsquish (0 or 1) for pass1/2 how to keep the quantizer between qmin & qmax
0 use cliping
1 use a nice differentiable function (default)
vlelim (-1000-1000) single coefficient elimination threshold for luminance
0 disabled (default)
-4 (JVT recommendation)
negative values will allso consider the dc coefficient
should be at least -4 or lower for encoding at quant=1
vcelim (-1000-1000) single coefficient elimination threshold for chrominance
0 disabled (default)
7 (JVT recommendation)
negative values will allso consider the dc coefficient
should be at least -4 or lower for encoding at quant=1
vstrict strict standard compliance
only recommended if you want to feed the output into the mpeg4 reference
decoder
vdpart data partitioning
adds 2 byte per video packet
improves error-resistance when transfering over unreliable channels (eg.
streaming over the internet)
vpsize (0-10000) video packet size
0 disabled (default)
500-1000 good choice
improves error-resistance (see vdpart for more info)
gray grayscale only encoding (a bit faster than with color ...)
lavdopts: (decoder options)
---------------------------
ver error resilience
-1 needed for some very broken, encoders which completly ignore the
standards (one M4S2 asf sample know to need this) (default)
0
1 more aggressive error detection, lavc might think that some correct
streams contain errors
bug manual workaround encoder bugs (cant be easily detected automatically)
0 (default)
1 for msmpeg4v3 workaround for some old lavc generated msmpeg4v3 files
1 for mpeg4 workaround some opendivx? files
see http://heroinewarrior.com for some samples
gray grayscale only decoding (a bit faster than with color ...)
Notes: 1. lavc will strictly follow the quantizer limits vqmin, vqmax, vqdiff
even if it violates the bitrate / bitrate tolerance
2. changing some options between pass1 & 2 can reduce the quality
FAQ: Q: Why is the filesize much too small?
A: Try to increase vqmin=2 or 1 (be carefull with 1, it could cause
strange things to happen).
Q: Can I use -pass 1 & -pass 2 with vmax_b_frames>0 ?
A: -pass x uses the divx4 twopass-encoding codem which is incompatible
with the libavcodec encode.
If you want to fix it read DOCS/tech/patches.txt and send a patch.
Q: What provides better error recovery while keeping the filesize low?
Should I use data partitioning or increase the number of video packets?
A: Data partitioning is better in this case.
Glossary:
MB Macroblock (16x16 luminance and 8x8 chrominance samples)
MV Motion vector
ME Motion estimation
MC Motion compensation
RC Rate control
DCT Discrete Cosine Transform
IDCT Inverse Discrete Cosine Transform
JVT Joint Video Team Standard -- http://www.itu.int/ITU-T/news/jvtpro.html
Examples:
mencoder foobar.avi -lavcopts vcodec=mpeg4:vhq:keyint=300:vqscale=2 -o new-foobar.avi
mplayer foobar.avi -lavdopts bug=1
--
Written 2002 by Michael Niedermayer and reviewed by Felix Buenemann.
Check the MPlayer documentation for contact-addresses.
|