Imported Upstream version 1.4
[deb_x265.git] / doc / reST / cli.rst
CommitLineData
72b9787e
JB
1*********************
2Command Line Options
3*********************
4
5.. _string-options-ref:
6
7Note that unless an option is listed as **CLI ONLY** the option is also
8supported by x265_param_parse(). The CLI uses getopt to parse the
9command line options so the short or long versions may be used and the
10long options may be truncated to the shortest unambiguous abbreviation.
11Users of the API must pass x265_param_parse() the full option name.
12
13Preset and tune have special implications. The API user must call
14x265_param_default_preset() with the preset and tune parameters they
15wish to use, prior to calling x265_param_parse() to set any additional
16fields. The CLI does this for the user implicitly, so all CLI options
17are applied after the user's preset and tune choices, regardless of the
18order of the arguments on the command line.
19
20If there is an extra command line argument (not an option or an option
21value) the CLI will treat it as the input filename. This effectively
22makes the :option:`--input` specifier optional for the input file. If
23there are two extra arguments, the second is treated as the output
24bitstream filename, making :option:`--output` also optional if the input
25filename was implied. This makes :command:`x265 in.y4m out.hevc` a valid
26command line. If there are more than two extra arguments, the CLI will
27consider this an error and abort.
28
29Generally, when an option expects a string value from a list of strings
30the user may specify the integer ordinal of the value they desire. ie:
31:option:`--log-level` 3 is equivalent to :option:`--log-level` debug.
32
33Standalone Executable Options
34=============================
35
36.. option:: --help, -h
37
38 Display help text
39
40 **CLI ONLY**
41
42.. option:: --version, -V
43
44 Display version details
45
46 **CLI ONLY**
47
48.. option:: --asm <integer:false:string>, --no-asm
49
50 x265 will use all detected CPU SIMD architectures by default. You can
51 disable all assembly by using :option:`--no-asm` or you can specify
52 a comma separated list of SIMD architectures to use, matching these
53 strings: MMX2, SSE, SSE2, SSE3, SSSE3, SSE4, SSE4.1, SSE4.2, AVX, XOP, FMA4, AVX2, FMA3
54
55 Some higher architectures imply lower ones being present, this is
56 handled implicitly.
57
58 One may also directly supply the CPU capability bitmap as an integer.
59
60.. option:: --threads <integer>
61
62 Number of threads to allocate for the worker thread pool This pool
63 is used for WPP and for distributed analysis and motion search:
64 :option:`--wpp` :option:`--pmode` and :option:`--pme` respectively.
65
66 If :option:`--threads`=1 is specified, then no thread pool is
67 created. When no thread pool is created, all the thread pool
68 features are implicitly disabled. If all the pool features are
69 disabled by the user, then the pool is implicitly disabled.
70
71 Default 0, one thread is allocated per detected hardware thread
72 (logical CPU cores)
73
74.. option:: --pmode, --no-pmode
75
76 Parallel mode decision, or distributed mode analysis. When enabled
77 the encoder will distribute the analysis work of each CU (merge,
78 inter, intra) across multiple worker threads. Only recommended if
79 x265 is not already saturating the CPU cores. In RD levels 3 and 4
80 it will be most effective if --rect was enabled. At RD levels 5 and
81 6 there is generally always enough work to distribute to warrant the
82 overhead, assuming your CPUs are not already saturated.
83
84 --pmode will increase utilization without reducing compression
85 efficiency. In fact, since the modes are all measured in parallel it
86 makes certain early-outs impractical and thus you usually get
87 slightly better compression when it is enabled (at the expense of
88 not skipping improbable modes).
89
90 This feature is implicitly disabled when no thread pool is present.
91
92 Default disabled
93
94.. option:: --pme, --no-pme
95
96 Parallel motion estimation. When enabled the encoder will distribute
97 motion estimation across multiple worker threads when more than two
98 references require motion searches for a given CU. Only recommended
99 if x265 is not already saturating CPU cores. :option:`--pmode` is
100 much more effective than this option, since the amount of work it
101 distributes is substantially higher. With --pme it is not unusual
102 for the overhead of distributing the work to outweigh the
103 parallelism benefits.
104
105 This feature is implicitly disabled when no thread pool is present.
106
107 --pme will increase utilization on many core systems with no effect
108 on the output bitstream.
109
110 Default disabled
111
112.. option:: --preset, -p <integer|string>
113
114 Sets parameters to preselected values, trading off compression efficiency against
115 encoding speed. These parameters are applied before all other input parameters are
116 applied, and so you can override any parameters that these values control.
117
118 0. ultrafast
119 1. superfast
120 2. veryfast
121 3. faster
122 4. fast
123 5. medium **(default)**
124 6. slow
125 7. slower
126 8. veryslow
127 9. placebo
128
129.. option:: --tune, -t <string>
130
131 Tune the settings for a particular type of source or situation. The changes will
132 be applied after :option:`--preset` but before all other parameters. Default none
133
134 **Values:** psnr, ssim, zero-latency, fast-decode.
135
136.. option:: --frame-threads, -F <integer>
137
138 Number of concurrently encoded frames. Using a single frame thread
139 gives a slight improvement in compression, since the entire reference
140 frames are always available for motion compensation, but it has
141 severe performance implications. Default is an autodetected count
142 based on the number of CPU cores and whether WPP is enabled or not.
143
144 Over-allocation of frame threads will not improve performance, it
145 will generally just increase memory use.
146
147.. option:: --log-level <integer|string>
148
149 Logging level. Debug level enables per-frame QP, metric, and bitrate
150 logging. If a CSV file is being generated, debug level makes the log
151 be per-frame rather than per-encode. Full level enables hash and
152 weight logging. -1 disables all logging, except certain fatal
153 errors, and can be specified by the string "none".
154
155 0. error
156 1. warning
157 2. info **(default)**
158 3. debug
159 4. full
160
161.. option:: --csv <filename>
162
163 Writes encoding results to a comma separated value log file. Creates
164 the file if it doesnt already exist, else adds one line per run. if
165 :option:`--log-level` is debug or above, it writes one line per
166 frame. Default none
167
168.. option:: --cu-stats, --no-cu-stats
169
170 Records statistics on how each CU was coded (split depths and other
171 mode decisions) and reports those statistics at the end of the
172 encode. Default disabled
173
174.. option:: --output, -o <filename>
175
176 Bitstream output file name. If there are two extra CLI options, the
177 first is implicitly the input filename and the second is the output
178 filename, making the :option:`--output` option optional.
179
180 The output file will always contain a raw HEVC bitstream, the CLI
181 does not support any container file formats.
182
183 **CLI ONLY**
184
185.. option:: --no-progress
186
187 Disable CLI periodic progress reports
188
189 **CLI ONLY**
190
191Quality reporting metrics
192=========================
193
194.. option:: --ssim, --no-ssim
195
196 Calculate and report Structural Similarity values. It is
197 recommended to use :option:`--tune` ssim if you are measuring ssim,
198 else the results should not be used for comparison purposes.
199 Default disabled
200
201.. option:: --psnr, --no-psnr
202
203 Calculate and report Peak Signal to Noise Ratio. It is recommended
204 to use :option:`--tune` psnr if you are measuring PSNR, else the
205 results should not be used for comparison purposes. Default
206 disabled
207
208Input Options
209=============
210
211.. option:: --input <filename>
212
213 Input filename, only raw YUV or Y4M supported. Use single dash for
214 stdin. This option name will be implied for the first "extra"
215 command line argument.
216
217 **CLI ONLY**
218
219.. option:: --y4m
220
221 Parse input stream as YUV4MPEG2 regardless of file extension,
222 primarily intended for use with stdin (ie: :option:`--input` -
223 :option:`--y4m`). This option is implied if the input filename has
224 a ".y4m" extension
225
226 **CLI ONLY**
227
228.. option:: --input-depth <integer>
229
230 YUV only: Bit-depth of input file or stream
231
232 **Values:** any value between 8 and 16. Default is internal depth.
233
234 **CLI ONLY**
235
236.. option:: --dither
237
238 Enable high quality downscaling. Dithering is based on the diffusion
239 of errors from one row of pixels to the next row of pixels in a
240 picture. Only applicable when the input bit depth is larger than
241 8bits and internal bit depth is 8bits. Default disabled
242
243 **CLI ONLY**
244
245.. option:: --nr <integer>
246
247 Noise reduction - an adaptive deadzone applied after DCT
248 (subtracting from DCT coefficients), before quantization, on inter
249 blocks. It does no pixel-level filtering, doesn't cross DCT block
250 boundaries, has no overlap, doesn't affect intra blocks. The higher
251 the strength value parameter, the more aggressively it will reduce
252 noise.
253
254 Enabling noise reduction will make outputs diverge between different
255 numbers of frame threads. Outputs will be deterministic but the
256 outputs of -F2 will no longer match the outputs of -F3, etc.
257
258 **Values:** any value in range of 100 to 1000. Default disabled.
259
260.. option:: --input-res <wxh>
261
262 YUV only: Source picture size [w x h]
263
264 **CLI ONLY**
265
266.. option:: --input-csp <integer|string>
267
268 YUV only: Source color space. Only i420, i422, and i444 are
269 supported at this time. The internal color space is always the
270 same as the source color space (libx265 does not support any color
271 space conversions).
272
273 0. i400
274 1. i420 **(default)**
275 2. i422
276 3. i444
277 4. nv12
278 5. nv16
279
280.. option:: --fps <integer|float|numerator/denominator>
281
282 YUV only: Source frame rate
283
284 **Range of values:** positive int or float, or num/denom
285
286.. option:: --interlaceMode <false|tff|bff>, --no-interlaceMode
287
288 **EXPERIMENTAL** Specify interlace type of source pictures.
289
290 0. progressive pictures **(default)**
291 1. top field first
292 2. bottom field first
293
294 HEVC encodes interlaced content as fields. Fields must be provided to
295 the encoder in the correct temporal order. The source dimensions
296 must be field dimensions and the FPS must be in units of fields per
297 second. The decoder must re-combine the fields in their correct
298 orientation for display.
299
300.. option:: --seek <integer>
301
302 Number of frames to skip at start of input file. Default 0
303
304 **CLI ONLY**
305
306.. option:: --frames, -f <integer>
307
308 Number of frames to be encoded. Default 0 (all)
309
310 **CLI ONLY**
311
312.. option:: --qpfile <filename>
313
314 Specify a text file which contains frametypes and QPs for some or
315 all frames. The format of each line is:
316
317 framenumber frametype QP
318
319 Frametype can be one of [I,i,P,B,b]. **B** is a referenced B frame,
320 **b** is an unreferenced B frame. **I** is a keyframe (random
321 access point) while **i** is a I frame that is not a keyframe
322 (references are not broken).
323
324 Specifying QP (integer) is optional, and if specified they are
325 clamped within the encoder to qpmin/qpmax.
326
327.. option:: --scaling-list <filename>
328
329 Quantization scaling lists. HEVC supports 6 quantization scaling
330 lists to be defined; one each for Y, Cb, Cr for intra prediction and
331 one each for inter prediction.
332
333 x265 does not use scaling lists by default, but this can also be
334 made explicit by :option:`--scaling-list` *off*.
335
336 HEVC specifies a default set of scaling lists which may be enabled
337 without requiring them to be signaled in the SPS. Those scaling
338 lists can be enabled via :option:`--scaling-list` *default*.
339
340 All other strings indicate a filename containing custom scaling
341 lists in the HM format. The encode will abort if the file is not
342 parsed correctly. Custom lists must be signaled in the SPS
343
344.. option:: --lambda-file <filename>
345
346 Specify a text file containing values for x265_lambda_tab and
347 x265_lambda2_tab. Each table requires MAX_MAX_QP+1 (70) float
348 values.
349
350 The text file syntax is simple. Comma is considered to be
351 white-space. All white-space is ignored. Lines must be less than 2k
352 bytes in length. Content following hash (#) characters are ignored.
353 The values read from the file are logged at :option:`--log-level`
354 debug.
355
356 Note that the lambda tables are process-global and so the new values
357 affect all encoders running in the same process.
358
359 Lambda values affect encoder mode decisions, the lower the lambda
360 the more bits it will try to spend on signaling information (motion
361 vectors and splits) and less on residual. This feature is intended
362 for experimentation.
363
364Profile, Level, Tier
365====================
366
367.. option:: --profile <string>
368
369 Enforce the requirements of the specified profile, ensuring the
370 output stream will be decodable by a decoder which supports that
371 profile. May abort the encode if the specified profile is
372 impossible to be supported by the compile options chosen for the
373 encoder (a high bit depth encoder will be unable to output
374 bitstreams compliant with Main or Mainstillpicture).
375
376 API users must use x265_param_apply_profile() after configuring
377 their param structure. Any changes made to the param structure after
378 this call might make the encode non-compliant.
379
380 **Values:** main, main10, mainstillpicture, main422-8, main422-10, main444-8, main444-10
381
382 **CLI ONLY**
383
384.. option:: --level-idc <integer|float>
385
386 Minimum decoder requirement level. Defaults to 0, which implies
387 auto-detection by the encoder. If specified, the encoder will
388 attempt to bring the encode specifications within that specified
389 level. If the encoder is unable to reach the level it issues a
390 warning and aborts the encode. If the requested requirement level is
391 higher than the actual level, the actual requirement level is
392 signaled.
393
394 Beware, specifying a decoder level will force the encoder to enable
395 VBV for constant rate factor encodes, which may introduce
396 non-determinism.
397
398 The value is specified as a float or as an integer with the level
399 times 10, for example level **5.1** is specified as "5.1" or "51",
400 and level **5.0** is specified as "5.0" or "50".
401
402 Annex A levels: 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2
403
404.. option:: --high-tier, --no-high-tier
405
406 If :option:`--level-idc` has been specified, the option adds the
407 intention to support the High tier of that level. If your specified
408 level does not support a High tier, a warning is issued and this
409 modifier flag is ignored.
410
411.. note::
412 :option:`--profile`, :option:`--level-idc`, and
413 :option:`--high-tier` are only intended for use when you are
414 targeting a particular decoder (or decoders) with fixed resource
415 limitations and must constrain the bitstream within those limits.
416 Specifying a profile or level may lower the encode quality
417 parameters to meet those requirements but it will never raise
418 them.
419
420Quad-Tree analysis
421==================
422
423.. option:: --wpp, --no-wpp
424
425 Enable Wavefront Parallel Processing. The encoder may begin encoding
426 a row as soon as the row above it is at least two CTUs ahead in the
427 encode process. This gives a 3-5x gain in parallelism for about 1%
428 overhead in compression efficiency. Default: Enabled
429
430.. option:: --ctu, -s <64|32|16>
431
432 Maximum CU size (width and height). The larger the maximum CU size,
433 the more efficiently x265 can encode flat areas of the picture,
434 giving large reductions in bitrate. However this comes at a loss of
435 parallelism with fewer rows of CUs that can be encoded in parallel,
436 and less frame parallelism as well. Because of this the faster
437 presets use a CU size of 32. Default: 64
438
439.. option:: --tu-intra-depth <1..4>
440
441 The transform unit (residual) quad-tree begins with the same depth
442 as the coding unit quad-tree, but the encoder may decide to further
443 split the transform unit tree if it improves compression efficiency.
444 This setting limits the number of extra recursion depth which can be
445 attempted for intra coded units. Default: 1, which means the
446 residual quad-tree is always at the same depth as the coded unit
447 quad-tree
448
449 Note that when the CU intra prediction is NxN (only possible with
450 8x8 CUs), a TU split is implied, and thus the residual quad-tree
451 begins at 4x4 and cannot split any futhrer.
452
453.. option:: --tu-inter-depth <1..4>
454
455 The transform unit (residual) quad-tree begins with the same depth
456 as the coding unit quad-tree, but the encoder may decide to further
457 split the transform unit tree if it improves compression efficiency.
458 This setting limits the number of extra recursion depth which can be
459 attempted for inter coded units. Default: 1. which means the
460 residual quad-tree is always at the same depth as the coded unit
461 quad-tree unless the CU was coded with rectangular or AMP
462 partitions, in which case a TU split is implied and thus the
463 residual quad-tree begins one layer below the CU quad-tree.
464
465Temporal / motion search options
466================================
467
468.. option:: --me <integer|string>
469
470 Motion search method. Generally, the higher the number the harder
471 the ME method will try to find an optimal match. Diamond search is
472 the simplest. Hexagon search is a little better. Uneven
473 Multi-Hexegon is an adaption of the search method used by x264 for
474 slower presets. Star is a three step search adapted from the HM
475 encoder: a star-pattern search followed by an optional radix scan
476 followed by an optional star-search refinement. Full is an
477 exhaustive search; an order of magnitude slower than all other
478 searches but not much better than umh or star.
479
480 0. dia
481 1. hex **(default)**
482 2. umh
483 3. star
484 4. full
485
486.. option:: --subme, -m <0..7>
487
488 Amount of subpel refinement to perform. The higher the number the
489 more subpel iterations and steps are performed. Default 2
490
491 +----+------------+-----------+------------+-----------+-----------+
492 | -m | HPEL iters | HPEL dirs | QPEL iters | QPEL dirs | HPEL SATD |
493 +====+============+===========+============+===========+===========+
494 | 0 | 1 | 4 | 0 | 4 | false |
495 +----+------------+-----------+------------+-----------+-----------+
496 | 1 | 1 | 4 | 1 | 4 | false |
497 +----+------------+-----------+------------+-----------+-----------+
498 | 2 | 1 | 4 | 1 | 4 | true |
499 +----+------------+-----------+------------+-----------+-----------+
500 | 3 | 2 | 4 | 1 | 4 | true |
501 +----+------------+-----------+------------+-----------+-----------+
502 | 4 | 2 | 4 | 2 | 4 | true |
503 +----+------------+-----------+------------+-----------+-----------+
504 | 5 | 1 | 8 | 1 | 8 | true |
505 +----+------------+-----------+------------+-----------+-----------+
506 | 6 | 2 | 8 | 1 | 8 | true |
507 +----+------------+-----------+------------+-----------+-----------+
508 | 7 | 2 | 8 | 2 | 8 | true |
509 +----+------------+-----------+------------+-----------+-----------+
510
511.. option:: --merange <integer>
512
513 Motion search range. Default 57
514
515 The default is derived from the default CTU size (64) minus the luma
516 interpolation half-length (4) minus maximum subpel distance (2)
517 minus one extra pixel just in case the hex search method is used. If
518 the search range were any larger than this, another CTU row of
519 latency would be required for reference frames.
520
521 **Range of values:** an integer from 0 to 32768
522
523.. option:: --max-merge <1..5>
524
525 Maximum number of neighbor (spatial and temporal) candidate blocks
526 that the encoder may consider for merging motion predictions. If a
527 merge candidate results in no residual, it is immediately selected
528 as a "skip". Otherwise the merge candidates are tested as part of
529 motion estimation when searching for the least cost inter option.
530 The max candidate number is encoded in the SPS and determines the
531 bit cost of signaling merge CUs. Default 2
532
533.. option:: --temporal-mvp, --no-temporal-mvp
534
535 Enable temporal motion vector predictors in P and B slices.
536 This enables the use of the motion vector from the collocated block
537 in the previous frame to be used as a predictor. Default is enabled
538
539Spatial/intra options
540=====================
541
542.. option:: --rdpenalty <0..2>
543
544 When set to 1, transform units of size 32x32 are given a 4x bit cost
545 penalty compared to smaller transform units, in intra coded CUs in P
546 or B slices.
547
548 When set to 2, transform units of size 32x32 are not even attempted,
549 unless otherwise required by the maximum recursion depth. For this
550 option to be effective with 32x32 intra CUs,
551 :option:`--tu-intra-depth` must be at least 2. For it to be
552 effective with 64x64 intra CUs, :option:`--tu-intra-depth` must be
553 at least 3.
554
555 Note that in HEVC an intra transform unit (a block of the residual
556 quad-tree) is also a prediction unit, meaning that the intra
557 prediction signal is generated for each TU block, the residual
558 subtracted and then coded. The coding unit simply provides the
559 prediction modes that will be used when predicting all of the
560 transform units within the CU. This means that when you prevent
561 32x32 intra transform units, you are preventing 32x32 intra
562 predictions.
563
564 Default 0, disabled.
565
566 **Values:** 0:disabled 1:4x cost penalty 2:force splits
567
568.. option:: --b-intra, --no-b-intra
569
570 Enables the evaluation of intra modes in B slices. Default disabled.
571
572.. option:: --tskip, --no-tskip
573
574 Enable evaluation of transform skip (bypass DCT but still use
575 quantization) coding for 4x4 TU coded blocks.
576
577 Only effective at RD levels 3 and above, which perform RDO mode
578 decisions. Default disabled
579
580.. option:: --tskip-fast, --no-tskip-fast
581
582 Only evaluate transform skip for NxN intra predictions (4x4 blocks).
583 Only applicable if transform skip is enabled. For chroma, only
584 evaluate if luma used tskip. Inter block tskip analysis is
585 unmodified. Default disabled
586
587.. option:: --strong-intra-smoothing, --no-strong-intra-smoothing
588
589 Enable strong intra smoothing for 32x32 intra blocks. Default enabled
590
591.. option:: --constrained-intra, --no-constrained-intra
592
593 Constrained intra prediction. When generating intra predictions for
594 blocks in inter slices, only intra-coded reference pixels are used.
595 Inter-coded reference pixels are replaced with intra-coded neighbor
596 pixels or default values. The general idea is to block the
597 propagation of reference errors that may have resulted from lossy
598 signals. Default disabled
599
600Mode decision / Analysis
601========================
602
603.. option:: --rect, --no-rect
604
605 Enable analysis of rectangular motion partitions Nx2N and 2NxN
606 (50/50 splits, two directions). Default disabled
607
608.. option:: --amp, --no-amp
609
610 Enable analysis of asymmetric motion partitions (75/25 splits, four
611 directions). At RD levels 0 through 4, AMP partitions are only
612 considered at CU sizes 32x32 and below. At RD levels 5 and 6, it
613 will only consider AMP partitions as merge candidates (no motion
614 search) at 64x64, and as merge or inter candidates below 64x64.
615
616 The AMP partitions which are searched are derived from the current
617 best inter partition. If Nx2N (vertical rectangular) is the best
618 current prediction, then left and right asymmetrical splits will be
619 evaluated. If 2NxN (horizontal rectangular) is the best current
620 prediction, then top and bottom asymmetrical splits will be
621 evaluated, If 2Nx2N is the best prediction, and the block is not a
622 merge/skip, then all four AMP partitions are evaluated.
623
624 This setting has no effect if rectangular partitions are disabled.
625 Default disabled
626
627.. option:: --early-skip, --no-early-skip
628
629 Measure full CU size (2Nx2N) merge candidates first; if no residual
630 is found the analysis is short circuited. Default disabled
631
632.. option:: --fast-cbf, --no-fast-cbf
633
634 Short circuit analysis if a prediction is found that does not set
635 the coded block flag (aka: no residual was encoded). It prevents
636 the encoder from perhaps finding other predictions that also have no
637 residual but require less signaling bits or have less distortion.
638 Only applicable for RD levels 5 and 6. Default disabled
639
640.. option:: --fast-intra, --no-fast-intra
641
642 Perform an initial scan of every fifth intra angular mode, then
643 check modes +/- 2 distance from the best mode, then +/- 1 distance
644 from the best mode, effectively performing a gradient descent. When
645 enabled 10 modes in total are checked. When disabled all 33 angular
646 modes are checked. Only applicable for :option:`--rd` levels 3 and
647 below (medium preset and faster).
648
649.. option:: --weightp, -w, --no-weightp
650
651 Enable weighted prediction in P slices. This enables weighting
652 analysis in the lookahead, which influences slice decisions, and
653 enables weighting analysis in the main encoder which allows P
654 reference samples to have a weight function applied to them prior to
655 using them for motion compensation. In video which has lighting
656 changes, it can give a large improvement in compression efficiency.
657 Default is enabled
658
659.. option:: --weightb, --no-weightb
660
661 Enable weighted prediction in B slices. Default disabled
662
663.. option:: --rd <0..6>
664
665 Level of RDO in mode decision. The higher the value, the more
666 exhaustive the analysis and the more rate distortion optimization is
667 used. The lower the value the faster the encode, the higher the
668 value the smaller the bitstream (in general). Default 3
669
670 Note that this table aims for accuracy, but is not necessarily our
671 final target behavior for each mode.
672
673 +-------+---------------------------------------------------------------+
674 | Level | Description |
675 +=======+===============================================================+
676 | 0 | sa8d mode and split decisions, intra w/ source pixels |
677 +-------+---------------------------------------------------------------+
678 | 1 | recon generated (better intra), RDO merge/skip selection |
679 +-------+---------------------------------------------------------------+
680 | 2 | RDO splits and merge/skip selection |
681 +-------+---------------------------------------------------------------+
682 | 3 | RDO mode and split decisions |
683 +-------+---------------------------------------------------------------+
684 | 4 | Adds RDO Quant |
685 +-------+---------------------------------------------------------------+
686 | 5 | Adds RDO prediction decisions |
687 +-------+---------------------------------------------------------------+
688 | 6 | Currently same as 5 |
689 +-------+---------------------------------------------------------------+
690
691 **Range of values:** 0: least .. 6: full RDO analysis
692
693.. option:: --cu-lossless, --no-cu-lossless
694
695 For each CU, evaluate lossless (transform and quant bypass) encode
696 of the best non-lossless mode option as a potential rate distortion
697 optimization. If the global option :option:`--lossless` has been
698 specified, all CUs will be encoded as lossless unconditionally
699 regardless of whether this option was enabled. Default disabled.
700
701 Only effective at RD levels 3 and above, which perform RDO mode
702 decisions.
703
704.. option:: --signhide, --no-signhide
705
706 Hide sign bit of one coeff per TU (rdo). The last sign is implied.
707 This requires analyzing all the coefficients to determine if a sign
708 must be toggled, and then to determine which one can be toggled with
709 the least amount of distortion. Default enabled
710
711Psycho-visual options
712=====================
713
714Left to its own devices, the encoder will make mode decisions based on a
715simple rate distortion formula, trading distortion for bitrate. This is
716generally effective except for the manner in which this distortion is
717measured. It tends to favor blurred reconstructed blocks over blocks
718which have wrong motion. The human eye generally prefers the wrong
719motion over the blur and thus x265 offers psycho-visual adjustments to
720the rate distortion algorithm.
721
722:option:`--psy-rd` will add an extra cost to reconstructed blocks which
723do not match the visual energy of the source block. The higher the
724strength of :option:`--psy-rd` the more strongly it will favor similar
725energy over blur and the more aggressively it will ignore rate
726distortion. If it is too high, it will introduce visal artifacts and
727increase bitrate enough for rate control to increase quantization
728globally, reducing overall quality. psy-rd will tend to reduce the use
729of blurred prediction modes, like DC and planar intra and bi-directional
730inter prediction.
731
732:option:`--psy-rdoq` will adjust the distortion cost used in
733rate-distortion optimized quantization (RDO quant), enabled in
734:option:`--rd` 4 and above, favoring the preservation of energy in the
735reconstructed image. :option:`--psy-rdoq` prevents RDOQ from blurring
736all of the encoding options which psy-rd has to chose from. At low
737strength levels, psy-rdoq will influence the quantization level
738decisions, favoring higher AC energy in the reconstructed image. As
739psy-rdoq strength is increased, more non-zero coefficient levels are
740added and fewer coefficients are zeroed by RDOQ's rate distortion
741analysis. High levels of psy-rdoq can double the bitrate which can have
742a drastic effect on rate control, forcing higher overall QP, and can
743cause ringing artifacts. psy-rdoq is less accurate than psy-rd, it is
744biasing towards energy in general while psy-rd biases towards the energy
745of the source image. But very large psy-rdoq values can sometimes be
746beneficial, preserving film grain for instance.
747
748As a general rule, when both psycho-visual features are disabled, the
749encoder will tend to blur blocks in areas of difficult motion. Turning
750on small amounts of psy-rd and psy-rdoq will improve the perceived
751visual quality. Increasing psycho-visual strength further will improve
752quality and begin introducing artifacts and increase bitrate, which may
753force rate control to increase global QP. Finding the optimal
754psycho-visual parameters for a given video requires experimentation. Our
755recommended defaults (1.0 for both) are generally on the low end of the
756spectrum. And generally the lower the bitrate, the lower the optimal
757psycho-visual settings.
758
759.. option:: --psy-rd <float>
760
761 Influence rate distortion optimizated mode decision to preserve the
762 energy of the source image in the encoded image at the expense of
763 compression efficiency. It only has effect on presets which use
764 RDO-based mode decisions (:option:`--rd` 3 and above). 1.0 is a
765 typical value. Default disabled. Experimental
766
767 **Range of values:** 0 .. 2.0
768
769.. option:: --psy-rdoq <float>
770
771 Influence rate distortion optimized quantization by favoring higher
772 energy in the reconstructed image. This generally improves perceived
773 visual quality at the cost of lower quality metric scores. It only
774 has effect on slower presets which use RDO Quantization
775 (:option:`--rd` 4, 5 and 6). 1.0 is a typical value. Default
776 disabled. High values can be beneficial in preserving high-frequency
777 detail like film grain. Experimental
778
779 **Range of values:** 0 .. 50.0
780
781
782Slice decision options
783======================
784
785.. option:: --open-gop, --no-open-gop
786
787 Enable open GOP, allow I-slices to be non-IDR. Default enabled
788
789.. option:: --keyint, -I <integer>
790
791 Max intra period in frames. A special case of infinite-gop (single
792 keyframe at the beginning of the stream) can be triggered with
793 argument -1. Use 1 to force all-intra. Default 250
794
795.. option:: --min-keyint, -i <integer>
796
797 Minimum GOP size. Scenecuts closer together than this are coded as I
798 or P, not IDR. Minimum keyint is clamped to be at least half of
799 :option:`--keyint`. If you wish to force regular keyframe intervals
800 and disable adaptive I frame placement, you must use
801 :option:`--no-scenecut`.
802
803 **Range of values:** >=0 (0: auto)
804
805.. option:: --scenecut <integer>, --no-scenecut
806
807 How aggressively I-frames need to be inserted. The higher the
808 threshold value, the more aggressive the I-frame placement.
809 :option:`--scenecut` 0 or :option:`--no-scenecut` disables adaptive
810 I frame placement. Default 40
811
812.. option:: --rc-lookahead <integer>
813
814 Number of frames for slice-type decision lookahead (a key
815 determining factor for encoder latency). The longer the lookahead
816 buffer the more accurate scenecut decisions will be, and the more
817 effective cuTree will be at improving adaptive quant. Having a
818 lookahead larger than the max keyframe interval is not helpful.
819 Default 20
820
821 **Range of values:** Between the maximum consecutive bframe count (:option:`--bframes`) and 250
822
823.. option:: --b-adapt <integer>
824
825 Adaptive B frame scheduling. Default 2
826
827 **Values:** 0:none; 1:fast; 2:full(trellis)
828
829.. option:: --bframes, -b <0..16>
830
831 Maximum number of consecutive b-frames. Use :option:`--bframes` 0 to
832 force all P/I low-latency encodes. Default 4. This parameter has a
833 quadratic effect on the amount of memory allocated and the amount of
834 work performed by the full trellis version of :option:`--b-adapt`
835 lookahead.
836
837.. option:: --bframe-bias <integer>
838
839 Bias towards B frames in slicetype decision. The higher the bias the
840 more likely x265 is to use B frames. Can be any value between -90
841 and 100 and is clipped to that range. Default 0
842
843.. option:: --b-pyramid, --no-b-pyramid
844
845 Use B-frames as references, when possible. Default enabled
846
847.. option:: --ref <1..16>
848
849 Max number of L0 references to be allowed. This number has a linear
850 multiplier effect on the amount of work performed in motion search,
851 but will generally have a beneficial affect on compression and
852 distortion. Default 3
853
854Quality, rate control and rate distortion options
855=================================================
856
857.. option:: --bitrate <integer>
858
859 Enables single-pass ABR rate control. Specify the target bitrate in
860 kbps. Default is 0 (CRF)
861
862 **Range of values:** An integer greater than 0
863
864.. option:: --crf <0..51.0>
865
866 Quality-controlled variable bitrate. CRF is the default rate control
867 method; it does not try to reach any particular bitrate target,
868 instead it tries to achieve a given uniform quality and the size of
869 the bitstream is determined by the complexity of the source video.
870 The higher the rate factor the higher the quantization and the lower
871 the quality. Default rate factor is 28.0.
872
873.. option:: --crf-max <0..51.0>
874
875 Specify an upper limit to the rate factor which may be assigned to
876 any given frame (ensuring a max QP). This is dangerous when CRF is
877 used in combination with VBV as it may result in buffer underruns.
878 Default disabled
879
880.. option:: --crf-min <0..51.0>
881
882 Specify an lower limit to the rate factor which may be assigned to
883 any given frame (ensuring a min QP). This is dangerous when CRF is
884 used in combination with VBV as it may result in buffer underruns.
885 Default disabled
886
887.. option:: --vbv-bufsize <integer>
888
889 Specify the size of the VBV buffer (kbits). Enables VBV in ABR
890 mode. In CRF mode, :option:`--vbv-maxrate` must also be specified.
891 Default 0 (vbv disabled)
892
893.. option:: --vbv-maxrate <integer>
894
895 Maximum local bitrate (kbits/sec). Will be used only if vbv-bufsize
896 is also non-zero. Both vbv-bufsize and vbv-maxrate are required to
897 enable VBV in CRF mode. Default 0 (disabled)
898
899.. option:: --vbv-init <float>
900
901 Initial buffer occupancy. The portion of the decode buffer which
902 must be full before the decoder will begin decoding. Determines
903 absolute maximum frame size. May be specified as a fractional value
904 between 0 and 1, or in kbits. In other words these two option pairs
905 are equivalent::
906
907 :option:`--vbv-bufsize` 1000 :option:`--vbv-init` 900
908 :option:`--vbv-bufsize` 1000 :option:`--vbv-init` 0.9
909
910 Default 0.9
911
912 **Range of values:** fractional: 0 - 1.0, or kbits: 2 .. bufsize
913
914.. option:: --qp, -q <integer>
915
916 Specify base quantization parameter for Constant QP rate control.
917 Using this option enables Constant QP rate control. The specified QP
918 is assigned to P slices. I and B slices are given QPs relative to P
919 slices using param->rc.ipFactor and param->rc.pbFactor unless QP 0
920 is specified, in which case QP 0 is used for all slice types. Note
921 that QP 0 does not cause lossless encoding, it only disables
922 quantization. Default disabled (CRF)
923
924 **Range of values:** an integer from 0 to 51
925
926.. option:: --ipratio <float>
927
928 QP ratio factor between I and P slices. This ratio is used in all of
929 the rate control modes. Some :option:`--tune` options may change the
930 default value. It is not typically manually specified. Default 1.4
931
932.. option:: --pbratio <float>
933
934 QP ratio factor between P and B slices. This ratio is used in all of
935 the rate control modes. Some :option:`--tune` options may change the
936 default value. It is not typically manually specified. Default 1.3
937
938.. option:: --lossless, --no-lossless
939
940 Enables true lossless coding by bypassing scaling, transform,
941 quantization and in-loop filter processes. This is used for
942 ultra-high bitrates with zero loss of quality. Reconstructed output
943 pictures are bit-exact to the input pictures. Lossless encodes
944 implicitly have no rate control, all rate control options are
945 ignored. Slower presets will generally achieve better compression
946 efficiency (and generate smaller bitstreams). Default disabled.
947
948.. option:: --aq-mode <0|1|2>
949
950 Adaptive Quantization operating mode. Raise or lower per-block
951 quantization based on complexity analysis of the source image. The
952 more complex the block, the more quantization is used. This offsets
953 the tendency of the encoder to spend too many bits on complex areas
954 and not enough in flat areas.
955
956 0. disabled
957 1. AQ enabled
958 2. AQ enabled with auto-variance **(default)**
959
960.. option:: --aq-strength <float>
961
962 Adjust the strength of the adaptive quantization offsets. Setting
963 :option:`--aq-strength` to 0 disables AQ. Default 1.0.
964
965 **Range of values:** 0.0 to 3.0
966
967.. option:: --cutree, --no-cutree
968
969 Enable the use of lookahead's lowres motion vector fields to
970 determine the amount of reuse of each block to tune adaptive
971 quantization factors. CU blocks which are heavily reused as motion
972 reference for later frames are given a lower QP (more bits) while CU
973 blocks which are quickly changed and are not referenced are given
974 less bits. This tends to improve detail in the backgrounds of video
975 with less detail in areas of high motion. Default enabled
976
977.. option:: --cbqpoffs <integer>
978
979 Offset of Cb chroma QP from the luma QP selected by rate control.
980 This is a general way to spend more or less bits on the chroma
981 channel. Default 0
982
983 **Range of values:** -12 to 12
984
985.. option:: --crqpoffs <integer>
986
987 Offset of Cr chroma QP from the luma QP selected by rate control.
988 This is a general way to spend more or less bits on the chroma
989 channel. Default 0
990
991 **Range of values:** -12 to 12
992
993.. option:: --pass <integer>
994
995 Enable multipass rate control mode. Input is encoded multiple times,
996 storing the encoded information of each pass in a stats file from which
997 the consecutive pass tunes the qp of each frame to improve the quality
998 of the output. Default disabled
999
1000 1. First pass, creates stats file
1001 2. Last pass, does not overwrite stats file
1002 3. Nth pass, overwrites stats file
1003
1004 **Range of values:** 1 to 3
1005
1006.. option:: --slow-firstpass, --no-slow-firstpass
1007
1008 Enable a slow and more detailed first pass encode in Multipass rate
1009 control mode. Speed of the first pass encode is slightly lesser and
1010 quality midly improved when compared to the default settings in a
1011 multipass encode. Default disabled (turbo mode enabled)
1012
1013 When **turbo** first pass is not disabled, these options are
1014 set on the first pass to improve performance:
1015
1016 * :option:`--fast-intra`
1017 * :option:`--no-rect`
1018 * :option:`--no-amp`
1019 * :option:`--early-skip`
1020 * :option:`--ref` = 1
1021 * :option:`--max-merge` = 1
1022 * :option:`--me` = DIA
1023 * :option:`--subme` = MIN(2, :option:`--subme`)
1024 * :option:`--rd` = MIN(2, :option:`--rd`)
1025
1026.. option:: --analysis-mode <string|int>
1027
1028 Specify whether analysis information of each frame is output by encoder
1029 or input for reuse. By reading the analysis data writen by an
1030 earlier encode of the same sequence, substantial redundant work may
1031 be avoided.
1032
1033 The following data may be stored and reused:
1034 I frames - split decisions and luma intra directions of all CUs.
1035 P/B frames - motion vectors are dumped at each depth for all CUs.
1036
1037 **Values:** off(0), save(1): dump analysis data, load(2): read analysis data
1038
1039.. option:: --analysis-file <filename>
1040
1041 Specify a filename for analysis data (see :option:`--analysis-mode`)
1042 If no filename is specified, x265_analysis.dat is used.
1043
1044Loop filters
1045============
1046
1047.. option:: --lft, --no-lft
1048
1049 Toggle deblocking loop filter, default enabled
1050
1051.. option:: --sao, --no-sao
1052
1053 Toggle Sample Adaptive Offset loop filter, default enabled
1054
1055.. option:: --sao-non-deblock, --no-sao-non-deblock
1056
1057 Specify how to handle depencency between SAO and deblocking filter.
1058 When enabled, non-deblocked pixels are used for SAO analysis. When
1059 disabled, SAO analysis skips the right/bottom boundary areas.
1060 Default disabled
1061
1062VUI (Video Usability Information) options
1063=========================================
1064
1065x265 emits a VUI with only the timing info by default. If the SAR is
1066specified (or read from a Y4M header) it is also included. All other
1067VUI fields must be manually specified.
1068
1069.. option:: --sar <integer|w:h>
1070
1071 Sample Aspect Ratio, the ratio of width to height of an individual
1072 sample (pixel). The user may supply the width and height explicitly
1073 or specify an integer from the predefined list of aspect ratios
1074 defined in the HEVC specification. Default undefined (not signaled)
1075
1076 1. 1:1 (square)
1077 2. 12:11
1078 3. 10:11
1079 4. 16:11
1080 5. 40:33
1081 6. 24:11
1082 7. 20:11
1083 8. 32:11
1084 9. 80:33
1085 10. 18:11
1086 11. 15:11
1087 12. 64:33
1088 13. 160:99
1089 14. 4:3
1090 15. 3:2
1091 16. 2:1
1092
1093.. option:: --crop-rect <left,top,right,bottom>
1094
1095 Define the (overscan) region of the image that does not contain
1096 information because it was added to achieve certain resolution or
1097 aspect ratio. The decoder may be directed to crop away this region
1098 before displaying the images via the :option:`--overscan` option.
1099 Default undefined (not signaled)
1100
1101.. option:: --overscan <show|crop>
1102
1103 Specify whether it is appropriate for the decoder to display or crop
1104 the overscan area. Default unspecified (not signaled)
1105
1106.. option:: --videoformat <integer|string>
1107
1108 Specify the source format of the original analog video prior to
1109 digitizing and encoding. Default undefined (not signaled)
1110
1111 0. component
1112 1. pal
1113 2. ntsc
1114 3. secam
1115 4. mac
1116 5. undefined
1117
1118.. option:: --range <full|limited>
1119
1120 Specify output range of black level and range of luma and chroma
1121 signals. Default undefined (not signaled)
1122
1123.. option:: --colorprim <integer|string>
1124
1125 Specify color primitive to use when converting to RGB. Default
1126 undefined (not signaled)
1127
1128 1. bt709
1129 2. undef
1130 3. **reserved**
1131 4. bt470m
1132 5. bt470bg
1133 6. smpte170m
1134 7. smpte240m
1135 8. film
1136 9. bt2020
1137
1138.. option:: --transfer <integer|string>
1139
1140 Specify transfer characteristics. Default undefined (not signaled)
1141
1142 1. bt709
1143 2. undef
1144 3. **reserved**
1145 4. bt470m
1146 5. bt470bg
1147 6. smpte170m
1148 7. smpte240m
1149 8. linear
1150 9. log100
1151 10. log316
1152 11. iec61966-2-4
1153 12. bt1361e
1154 13. iec61966-2-1
1155 14. bt2020-10
1156 15. bt2020-12
1157
1158.. option:: --colormatrix <integer|string>
1159
1160 Specify color matrix setting i.e set the matrix coefficients used in
1161 deriving the luma and chroma. Default undefined (not signaled)
1162
1163 0. GBR
1164 1. bt709
1165 2. undef
1166 3. **reserved**
1167 4. fcc
1168 5. bt470bg
1169 6. smpte170m
1170 7. smpte240m
1171 8. YCgCo
1172 9. bt2020nc
1173 10. bt2020c
1174
1175.. option:: --chromalocs <0..5>
1176
1177 Specify chroma sample location for 4:2:0 inputs. Consult the HEVC
1178 specification for a description of these values. Default undefined
1179 (not signaled)
1180
1181Bitstream options
1182=================
1183
1184.. option:: --repeat-headers, --no-repeat-headers
1185
1186 If enabled, x265 will emit VPS, SPS, and PPS headers with every
1187 keyframe. This is intended for use when you do not have a container
1188 to keep the stream headers for you and you want keyframes to be
1189 random access points. Default disabled
1190
1191.. option:: --info, --no-info
1192
1193 Emit an informational SEI with the stream headers which describes
1194 the encoder version, build info, and encode parameters. This is very
1195 helpful for debugging purposes but encoding version numbers and
1196 build info could make your bitstreams diverge and interfere with
1197 regression testing. Default enabled
1198
1199.. option:: --hrd, --no-hrd
1200
1201 Enable the signalling of HRD parameters to the decoder. The HRD
1202 parameters are carried by the Buffering Period SEI messages and
1203 Picture Timing SEI messages providing timing information to the
1204 decoder. Default disabled
1205
1206.. option:: --aud, --no-aud
1207
1208 Emit an access unit delimiter NAL at the start of each slice access
1209 unit. If option:`--repeat-headers` is not enabled (indicating the
1210 user will be writing headers manually at the start of the stream)
1211 the very first AUD will be skipped since it cannot be placed at the
1212 start of the access unit, where it belongs. Default disabled
1213
1214.. option:: --hash <integer>
1215
1216 Emit decoded picture hash SEI, so the decoder may validate the
1217 reconstructed pictures and detect data loss. Also useful as a
1218 debug feature to validate the encoder state. Default None
1219
1220 1. MD5
1221 2. CRC
1222 3. Checksum
1223
1224Debugging options
1225=================
1226
1227.. option:: --recon, -r <filename>
1228
1229 Output file containing reconstructed images in display order. If the
1230 file extension is ".y4m" the file will contain a YUV4MPEG2 stream
1231 header and frame headers. Otherwise it will be a raw YUV file in the
1232 encoder's internal bit depth.
1233
1234 **CLI ONLY**
1235
1236.. option:: --recon-depth <integer>
1237
1238 Bit-depth of output file. This value defaults to the internal bit
1239 depth and currently cannot to be modified.
1240
1241 **CLI ONLY**
1242
1243.. vim: noet