]> git.sesse.net Git - ffmpeg/blob - doc/encoders.texi
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / doc / encoders.texi
1 @chapter Encoders
2 @c man begin ENCODERS
3
4 Encoders are configured elements in FFmpeg which allow the encoding of
5 multimedia streams.
6
7 When you configure your FFmpeg build, all the supported native encoders
8 are enabled by default. Encoders requiring an external library must be enabled
9 manually via the corresponding @code{--enable-lib} option. You can list all
10 available encoders using the configure option @code{--list-encoders}.
11
12 You can disable all the encoders with the configure option
13 @code{--disable-encoders} and selectively enable / disable single encoders
14 with the options @code{--enable-encoder=@var{ENCODER}} /
15 @code{--disable-encoder=@var{ENCODER}}.
16
17 The option @code{-codecs} of the ff* tools will display the list of
18 enabled encoders.
19
20 @c man end ENCODERS
21
22 @chapter Audio Encoders
23 @c man begin AUDIO ENCODERS
24
25 A description of some of the currently available audio encoders
26 follows.
27
28 @section ac3 and ac3_fixed
29
30 AC-3 audio encoders.
31
32 These encoders implement part of ATSC A/52:2010 and ETSI TS 102 366, as well as
33 the undocumented RealAudio 3 (a.k.a. dnet).
34
35 The @var{ac3} encoder uses floating-point math, while the @var{ac3_fixed}
36 encoder only uses fixed-point integer math. This does not mean that one is
37 always faster, just that one or the other may be better suited to a
38 particular system. The floating-point encoder will generally produce better
39 quality audio for a given bitrate. The @var{ac3_fixed} encoder is not the
40 default codec for any of the output formats, so it must be specified explicitly
41 using the option @code{-acodec ac3_fixed} in order to use it.
42
43 @subsection AC-3 Metadata
44
45 The AC-3 metadata options are used to set parameters that describe the audio,
46 but in most cases do not affect the audio encoding itself. Some of the options
47 do directly affect or influence the decoding and playback of the resulting
48 bitstream, while others are just for informational purposes. A few of the
49 options will add bits to the output stream that could otherwise be used for
50 audio data, and will thus affect the quality of the output. Those will be
51 indicated accordingly with a note in the option list below.
52
53 These parameters are described in detail in several publicly-available
54 documents.
55 @itemize
56 @item @uref{http://www.atsc.org/cms/standards/a_52-2010.pdf,A/52:2010 - Digital Audio Compression (AC-3) (E-AC-3) Standard}
57 @item @uref{http://www.atsc.org/cms/standards/a_54a_with_corr_1.pdf,A/54 - Guide to the Use of the ATSC Digital Television Standard}
58 @item @uref{http://www.dolby.com/uploadedFiles/zz-_Shared_Assets/English_PDFs/Professional/18_Metadata.Guide.pdf,Dolby Metadata Guide}
59 @item @uref{http://www.dolby.com/uploadedFiles/zz-_Shared_Assets/English_PDFs/Professional/46_DDEncodingGuidelines.pdf,Dolby Digital Professional Encoding Guidelines}
60 @end itemize
61
62 @subsubsection Metadata Control Options
63
64 @table @option
65
66 @item -per_frame_metadata @var{boolean}
67 Allow Per-Frame Metadata. Specifies if the encoder should check for changing
68 metadata for each frame.
69 @table @option
70 @item 0
71 The metadata values set at initialization will be used for every frame in the
72 stream. (default)
73 @item 1
74 Metadata values can be changed before encoding each frame.
75 @end table
76
77 @end table
78
79 @subsubsection Downmix Levels
80
81 @table @option
82
83 @item -center_mixlev @var{level}
84 Center Mix Level. The amount of gain the decoder should apply to the center
85 channel when downmixing to stereo. This field will only be written to the
86 bitstream if a center channel is present. The value is specified as a scale
87 factor. There are 3 valid values:
88 @table @option
89 @item 0.707
90 Apply -3dB gain
91 @item 0.595
92 Apply -4.5dB gain (default)
93 @item 0.500
94 Apply -6dB gain
95 @end table
96
97 @item -surround_mixlev @var{level}
98 Surround Mix Level. The amount of gain the decoder should apply to the surround
99 channel(s) when downmixing to stereo. This field will only be written to the
100 bitstream if one or more surround channels are present. The value is specified
101 as a scale factor.  There are 3 valid values:
102 @table @option
103 @item 0.707
104 Apply -3dB gain
105 @item 0.500
106 Apply -6dB gain (default)
107 @item 0.000
108 Silence Surround Channel(s)
109 @end table
110
111 @end table
112
113 @subsubsection Audio Production Information
114 Audio Production Information is optional information describing the mixing
115 environment.  Either none or both of the fields are written to the bitstream.
116
117 @table @option
118
119 @item -mixing_level @var{number}
120 Mixing Level. Specifies peak sound pressure level (SPL) in the production
121 environment when the mix was mastered. Valid values are 80 to 111, or -1 for
122 unknown or not indicated. The default value is -1, but that value cannot be
123 used if the Audio Production Information is written to the bitstream. Therefore,
124 if the @code{room_type} option is not the default value, the @code{mixing_level}
125 option must not be -1.
126
127 @item -room_type @var{type}
128 Room Type. Describes the equalization used during the final mixing session at
129 the studio or on the dubbing stage. A large room is a dubbing stage with the
130 industry standard X-curve equalization; a small room has flat equalization.
131 This field will not be written to the bitstream if both the @code{mixing_level}
132 option and the @code{room_type} option have the default values.
133 @table @option
134 @item 0
135 @itemx notindicated
136 Not Indicated (default)
137 @item 1
138 @itemx large
139 Large Room
140 @item 2
141 @itemx small
142 Small Room
143 @end table
144
145 @end table
146
147 @subsubsection Other Metadata Options
148
149 @table @option
150
151 @item -copyright @var{boolean}
152 Copyright Indicator. Specifies whether a copyright exists for this audio.
153 @table @option
154 @item 0
155 @itemx off
156 No Copyright Exists (default)
157 @item 1
158 @itemx on
159 Copyright Exists
160 @end table
161
162 @item -dialnorm @var{value}
163 Dialogue Normalization. Indicates how far the average dialogue level of the
164 program is below digital 100% full scale (0 dBFS). This parameter determines a
165 level shift during audio reproduction that sets the average volume of the
166 dialogue to a preset level. The goal is to match volume level between program
167 sources. A value of -31dB will result in no volume level change, relative to
168 the source volume, during audio reproduction. Valid values are whole numbers in
169 the range -31 to -1, with -31 being the default.
170
171 @item -dsur_mode @var{mode}
172 Dolby Surround Mode. Specifies whether the stereo signal uses Dolby Surround
173 (Pro Logic). This field will only be written to the bitstream if the audio
174 stream is stereo. Using this option does @b{NOT} mean the encoder will actually
175 apply Dolby Surround processing.
176 @table @option
177 @item 0
178 @itemx notindicated
179 Not Indicated (default)
180 @item 1
181 @itemx off
182 Not Dolby Surround Encoded
183 @item 2
184 @itemx on
185 Dolby Surround Encoded
186 @end table
187
188 @item -original @var{boolean}
189 Original Bit Stream Indicator. Specifies whether this audio is from the
190 original source and not a copy.
191 @table @option
192 @item 0
193 @itemx off
194 Not Original Source
195 @item 1
196 @itemx on
197 Original Source (default)
198 @end table
199
200 @end table
201
202 @subsection Extended Bitstream Information
203 The extended bitstream options are part of the Alternate Bit Stream Syntax as
204 specified in Annex D of the A/52:2010 standard. It is grouped into 2 parts.
205 If any one parameter in a group is specified, all values in that group will be
206 written to the bitstream.  Default values are used for those that are written
207 but have not been specified.  If the mixing levels are written, the decoder
208 will use these values instead of the ones specified in the @code{center_mixlev}
209 and @code{surround_mixlev} options if it supports the Alternate Bit Stream
210 Syntax.
211
212 @subsubsection Extended Bitstream Information - Part 1
213
214 @table @option
215
216 @item -dmix_mode @var{mode}
217 Preferred Stereo Downmix Mode. Allows the user to select either Lt/Rt
218 (Dolby Surround) or Lo/Ro (normal stereo) as the preferred stereo downmix mode.
219 @table @option
220 @item 0
221 @itemx notindicated
222 Not Indicated (default)
223 @item 1
224 @itemx ltrt
225 Lt/Rt Downmix Preferred
226 @item 2
227 @itemx loro
228 Lo/Ro Downmix Preferred
229 @end table
230
231 @item -ltrt_cmixlev @var{level}
232 Lt/Rt Center Mix Level. The amount of gain the decoder should apply to the
233 center channel when downmixing to stereo in Lt/Rt mode.
234 @table @option
235 @item 1.414
236 Apply +3dB gain
237 @item 1.189
238 Apply +1.5dB gain
239 @item 1.000
240 Apply 0dB gain
241 @item 0.841
242 Apply -1.5dB gain
243 @item 0.707
244 Apply -3.0dB gain
245 @item 0.595
246 Apply -4.5dB gain (default)
247 @item 0.500
248 Apply -6.0dB gain
249 @item 0.000
250 Silence Center Channel
251 @end table
252
253 @item -ltrt_surmixlev @var{level}
254 Lt/Rt Surround Mix Level. The amount of gain the decoder should apply to the
255 surround channel(s) when downmixing to stereo in Lt/Rt mode.
256 @table @option
257 @item 0.841
258 Apply -1.5dB gain
259 @item 0.707
260 Apply -3.0dB gain
261 @item 0.595
262 Apply -4.5dB gain
263 @item 0.500
264 Apply -6.0dB gain (default)
265 @item 0.000
266 Silence Surround Channel(s)
267 @end table
268
269 @item -loro_cmixlev @var{level}
270 Lo/Ro Center Mix Level. The amount of gain the decoder should apply to the
271 center channel when downmixing to stereo in Lo/Ro mode.
272 @table @option
273 @item 1.414
274 Apply +3dB gain
275 @item 1.189
276 Apply +1.5dB gain
277 @item 1.000
278 Apply 0dB gain
279 @item 0.841
280 Apply -1.5dB gain
281 @item 0.707
282 Apply -3.0dB gain
283 @item 0.595
284 Apply -4.5dB gain (default)
285 @item 0.500
286 Apply -6.0dB gain
287 @item 0.000
288 Silence Center Channel
289 @end table
290
291 @item -loro_surmixlev @var{level}
292 Lo/Ro Surround Mix Level. The amount of gain the decoder should apply to the
293 surround channel(s) when downmixing to stereo in Lo/Ro mode.
294 @table @option
295 @item 0.841
296 Apply -1.5dB gain
297 @item 0.707
298 Apply -3.0dB gain
299 @item 0.595
300 Apply -4.5dB gain
301 @item 0.500
302 Apply -6.0dB gain (default)
303 @item 0.000
304 Silence Surround Channel(s)
305 @end table
306
307 @end table
308
309 @subsubsection Extended Bitstream Information - Part 2
310
311 @table @option
312
313 @item -dsurex_mode @var{mode}
314 Dolby Surround EX Mode. Indicates whether the stream uses Dolby Surround EX
315 (7.1 matrixed to 5.1). Using this option does @b{NOT} mean the encoder will actually
316 apply Dolby Surround EX processing.
317 @table @option
318 @item 0
319 @itemx notindicated
320 Not Indicated (default)
321 @item 1
322 @itemx on
323 Dolby Surround EX Off
324 @item 2
325 @itemx off
326 Dolby Surround EX On
327 @end table
328
329 @item -dheadphone_mode @var{mode}
330 Dolby Headphone Mode. Indicates whether the stream uses Dolby Headphone
331 encoding (multi-channel matrixed to 2.0 for use with headphones). Using this
332 option does @b{NOT} mean the encoder will actually apply Dolby Headphone
333 processing.
334 @table @option
335 @item 0
336 @itemx notindicated
337 Not Indicated (default)
338 @item 1
339 @itemx on
340 Dolby Headphone Off
341 @item 2
342 @itemx off
343 Dolby Headphone On
344 @end table
345
346 @item -ad_conv_type @var{type}
347 A/D Converter Type. Indicates whether the audio has passed through HDCD A/D
348 conversion.
349 @table @option
350 @item 0
351 @itemx standard
352 Standard A/D Converter (default)
353 @item 1
354 @itemx hdcd
355 HDCD A/D Converter
356 @end table
357
358 @end table
359
360 @subsection Other AC-3 Encoding Options
361
362 @table @option
363
364 @item -stereo_rematrixing @var{boolean}
365 Stereo Rematrixing. Enables/Disables use of rematrixing for stereo input. This
366 is an optional AC-3 feature that increases quality by selectively encoding
367 the left/right channels as mid/side. This option is enabled by default, and it
368 is highly recommended that it be left as enabled except for testing purposes.
369
370 @end table
371
372 @subsection Floating-Point-Only AC-3 Encoding Options
373
374 These options are only valid for the floating-point encoder and do not exist
375 for the fixed-point encoder due to the corresponding features not being
376 implemented in fixed-point.
377
378 @table @option
379
380 @item -channel_coupling @var{boolean}
381 Enables/Disables use of channel coupling, which is an optional AC-3 feature
382 that increases quality by combining high frequency information from multiple
383 channels into a single channel. The per-channel high frequency information is
384 sent with less accuracy in both the frequency and time domains. This allows
385 more bits to be used for lower frequencies while preserving enough information
386 to reconstruct the high frequencies. This option is enabled by default for the
387 floating-point encoder and should generally be left as enabled except for
388 testing purposes or to increase encoding speed.
389 @table @option
390 @item -1
391 @itemx auto
392 Selected by Encoder (default)
393 @item 0
394 @itemx off
395 Disable Channel Coupling
396 @item 1
397 @itemx on
398 Enable Channel Coupling
399 @end table
400
401 @item -cpl_start_band @var{number}
402 Coupling Start Band. Sets the channel coupling start band, from 1 to 15. If a
403 value higher than the bandwidth is used, it will be reduced to 1 less than the
404 coupling end band. If @var{auto} is used, the start band will be determined by
405 the encoder based on the bit rate, sample rate, and channel layout. This option
406 has no effect if channel coupling is disabled.
407 @table @option
408 @item -1
409 @itemx auto
410 Selected by Encoder (default)
411 @end table
412
413 @end table
414
415 @section libmp3lame
416
417 LAME (Lame Ain't an MP3 Encoder) MP3 encoder wrapper.
418
419 Requires the presence of the libmp3lame headers and library during
420 configuration. You need to explicitly configure the build with
421 @code{--enable-libmp3lame}.
422
423 @subsection Options
424
425 The following options are supported by the libmp3lame wrapper. The
426 @command{lame}-equivalent of the options are listed in parentheses.
427
428 @table @option
429 @item b (@emph{-b})
430 Set bitrate expressed in bits/s for CBR. LAME @code{bitrate} is
431 expressed in kilobits/s.
432
433 @item q (@emph{-V})
434 Set constant quality setting for VBR. This option is valid only
435 using the @command{ffmpeg} command-line tool. For library interface
436 users, use @option{global_quality}.
437
438 @item compression_level (@emph{-q})
439 Set algorithm quality. Valid arguments are integers in the 0-9 range,
440 with 0 meaning highest quality but slowest, and 9 meaning fastest
441 while producing the worst quality.
442
443 @item reservoir
444 Enable use of bit reservoir when set to 1. Default value is 1. LAME
445 has this enabled by default, but can be overriden by use
446 @option{--nores} option.
447
448 @item joint_stereo (@emph{-m j})
449 Enable the encoder to use (on a frame by frame basis) either L/R
450 stereo or mid/side stereo. Default value is 1.
451
452 @end table
453
454 @section libopencore-amrnb
455
456 OpenCORE Adaptive Multi-Rate Narrowband encoder.
457
458 Requires the presence of the libopencore-amrnb headers and library during
459 configuration. You need to explicitly configure the build with
460 @code{--enable-libopencore-amrnb --enable-version3}.
461
462 This is a mono-only encoder. Officially it only supports 8000Hz sample rate,
463 but you can override it by setting @option{strict} to @samp{unofficial} or
464 lower.
465
466 @subsection Options
467
468 @table @option
469
470 @item b
471 Set bitrate in bits per second. Only the following bitrates are supported,
472 otherwise libavcodec will round to the nearest valid bitrate.
473
474 @table @option
475 @item 4750
476 @item 5150
477 @item 5900
478 @item 6700
479 @item 7400
480 @item 7950
481 @item 10200
482 @item 12200
483 @end table
484
485 @item dtx
486 Allow discontinuous transmission (generate comfort noise) when set to 1. The
487 default value is 0 (disabled).
488
489 @end table
490
491 @section libtwolame
492
493 TwoLAME MP2 encoder wrapper.
494
495 Requires the presence of the libtwolame headers and library during
496 configuration. You need to explicitly configure the build with
497 @code{--enable-libtwolame}.
498
499 @subsection Options
500
501 The following options are supported by the libtwolame wrapper. The
502 @command{twolame}-equivalent options follow the FFmpeg ones and are in
503 parentheses.
504
505 @table @option
506 @item b (@emph{-b})
507 Set bitrate expressed in bits/s for CBR. @command{twolame} @option{b}
508 option is expressed in kilobits/s. Default value is 128k.
509
510 @item q (@emph{-V})
511 Set quality for experimental VBR support. Maximum value range is
512 from -50 to 50, useful range is from -10 to 10. The higher the
513 value, the better the quality. This option is valid only using the
514 @command{ffmpeg} command-line tool. For library interface users,
515 use @option{global_quality}.
516
517 @item mode (@emph{--mode})
518 Set the mode of the resulting audio. Possible values:
519
520 @table @samp
521 @item auto
522 Choose mode automatically based on the input. This is the default.
523 @item stereo
524 Stereo
525 @item joint_stereo
526 Joint stereo
527 @item dual_channel
528 Dual channel
529 @item mono
530 Mono
531 @end table
532
533 @item psymodel (@emph{--psyc-mode})
534 Set psychoacoustic model to use in encoding. The argument must be
535 an integer between -1 and 4, inclusive. The higher the value, the
536 better the quality. The default value is 3.
537
538 @item energy_levels (@emph{--energy})
539 Enable energy levels extensions when set to 1. The default value is
540 0 (disabled).
541
542 @item error_protection (@emph{--protect})
543 Enable CRC error protection when set to 1. The default value is 0
544 (disabled).
545
546 @item copyright (@emph{--copyright})
547 Set MPEG audio copyright flag when set to 1. The default value is 0
548 (disabled).
549
550 @item original (@emph{--original})
551 Set MPEG audio original flag when set to 1. The default value is 0
552 (disabled).
553
554 @end table
555
556 @section libvo-aacenc
557
558 VisualOn AAC encoder.
559
560 Requires the presence of the libvo-aacenc headers and library during
561 configuration. You need to explicitly configure the build with
562 @code{--enable-libvo-aacenc --enable-version3}.
563
564 @subsection Options
565
566 The VisualOn AAC encoder only support encoding AAC-LC and up to 2
567 channels. It is also CBR-only. It is considered to be worse than the
568 native experimental FFmpeg AAC encoder.
569
570 @table @option
571
572 @item b
573 Bitrate.
574
575 @end table
576
577 @section libvo-amrwbenc
578
579 VisualOn Adaptive Multi-Rate Wideband encoder.
580
581 Requires the presence of the libvo-amrwbenc headers and library during
582 configuration. You need to explicitly configure the build with
583 @code{--enable-libvo-amrwbenc --enable-version3}.
584
585 This is a mono-only encoder. Officially it only supports 16000Hz sample
586 rate, but you can override it by setting @option{strict} to
587 @samp{unofficial} or lower.
588
589 @subsection Options
590
591 @table @option
592
593 @item b
594 Set bitrate in bits/s. Only the following bitrates are supported, otherwise
595 libavcodec will round to the nearest valid bitrate.
596
597 @table @samp
598 @item 6600
599 @item 8850
600 @item 12650
601 @item 14250
602 @item 15850
603 @item 18250
604 @item 19850
605 @item 23050
606 @item 23850
607 @end table
608
609 @item dtx
610 Allow discontinuous transmission (generate comfort noise) when set to 1. The
611 default value is 0 (disabled).
612
613 @end table
614
615 @section libopus
616
617 libopus Opus Interactive Audio Codec encoder wrapper.
618
619 Requires the presence of the libopus headers and library during
620 configuration. You need to explicitly configure the build with
621 @code{--enable-libopus}.
622
623 @subsection Option Mapping
624
625 Most libopus options are modeled after the @command{opusenc} utility from
626 opus-tools. The following is an option mapping chart describing options
627 supported by the libopus wrapper, and their @command{opusenc}-equivalent
628 in parentheses.
629
630 @table @option
631
632 @item b (@emph{bitrate})
633 Set the bit rate in bits/s.  FFmpeg's @option{b} option is
634 expressed in bits/s, while @command{opusenc}'s @option{bitrate} in
635 kilobits/s.
636
637 @item vbr (@emph{vbr}, @emph{hard-cbr}, and @emph{cvbr})
638 Set VBR mode. The FFmpeg @option{vbr} option has the following
639 valid arguments, with the their @command{opusenc} equivalent options
640 in parentheses:
641
642 @table @samp
643 @item off (@emph{hard-cbr})
644 Use constant bit rate encoding.
645
646 @item on (@emph{vbr})
647 Use variable bit rate encoding (the default).
648
649 @item constrained (@emph{cvbr})
650 Use constrained variable bit rate encoding.
651 @end table
652
653 @item compression_level (@emph{comp})
654 Set encoding algorithm complexity. Valid options are integers in
655 the 0-10 range. 0 gives the fastest encodes but lower quality, while 10
656 gives the highest quality but slowest encoding. The default is 10.
657
658 @item frame_duration (@emph{framesize})
659 Set maximum frame size, or duration of a frame in milliseconds. The
660 argument must be exactly the following: 2.5, 5, 10, 20, 40, 60. Smaller
661 frame sizes achieve lower latency but less quality at a given bitrate.
662 Sizes greater than 20ms are only interesting at fairly low bitrates.
663 The default of FFmpeg is 10ms, but is 20ms in @command{opusenc}.
664
665 @item packet_loss (@emph{expect-loss})
666 Set expected packet loss percentage. The default is 0.
667
668 @item application (N.A.)
669 Set intended application type. Valid options are listed below:
670
671 @table @samp
672 @item voip
673 Favor improved speech intelligibility.
674 @item audio
675 Favor faithfulness to the input (the default).
676 @item lowdelay
677 Restrict to only the lowest delay modes.
678 @end table
679
680 @item cutoff (N.A.)
681 Set cutoff bandwidth in Hz. The argument must be exactly one of the
682 following: 4000, 6000, 8000, 12000, or 20000, corresponding to
683 narrowband, mediumband, wideband, super wideband, and fullband
684 respectively. The default is 0 (cutoff disabled).
685
686 @end table
687
688 @section libwavpack
689
690 A wrapper providing WavPack encoding through libwavpack.
691
692 Only lossless mode using 32-bit integer samples is supported currently.
693 The @option{compression_level} option can be used to control speed vs.
694 compression tradeoff, with the values mapped to libwavpack as follows:
695
696 @table @option
697
698 @item 0
699 Fast mode - corresponding to the wavpack @option{-f} option.
700
701 @item 1
702 Normal (default) settings.
703
704 @item 2
705 High quality - corresponding to the wavpack @option{-h} option.
706
707 @item 3
708 Very high quality - corresponding to the wavpack @option{-hh} option.
709
710 @item 4-8
711 Same as 3, but with extra processing enabled - corresponding to the wavpack
712 @option{-x} option. I.e. 4 is the same as @option{-x2} and 8 is the same as
713 @option{-x6}.
714
715 @end table
716
717 @c man end AUDIO ENCODERS
718
719 @chapter Video Encoders
720 @c man begin VIDEO ENCODERS
721
722 A description of some of the currently available video encoders
723 follows.
724
725 @section libtheora
726
727 Theora format supported through libtheora.
728
729 Requires the presence of the libtheora headers and library during
730 configuration. You need to explicitly configure the build with
731 @code{--enable-libtheora}.
732
733 @subsection Options
734
735 The following global options are mapped to internal libtheora options
736 which affect the quality and the bitrate of the encoded stream.
737
738 @table @option
739 @item b
740 Set the video bitrate, only works if the @code{qscale} flag in
741 @option{flags} is not enabled.
742
743 @item flags
744 Used to enable constant quality mode encoding through the
745 @option{qscale} flag, and to enable the @code{pass1} and @code{pass2}
746 modes.
747
748 @item g
749 Set the GOP size.
750
751 @item global_quality
752 Set the global quality in lambda units, only works if the
753 @code{qscale} flag in @option{flags} is enabled. The value is clipped
754 in the [0 - 10*@code{FF_QP2LAMBDA}] range, and then multiplied for 6.3
755 to get a value in the native libtheora range [0-63]. A higher value
756 corresponds to a higher quality.
757
758 For example, to set maximum constant quality encoding with
759 @command{ffmpeg}:
760 @example
761 ffmpeg -i INPUT -flags:v qscale -global_quality:v "10*QP2LAMBDA" -codec:v libtheora OUTPUT.ogg
762 @end example
763 @end table
764
765 @section libvpx
766
767 VP8 format supported through libvpx.
768
769 Requires the presence of the libvpx headers and library during configuration.
770 You need to explicitly configure the build with @code{--enable-libvpx}.
771
772 @subsection Options
773
774 Mapping from FFmpeg to libvpx options with conversion notes in parentheses.
775
776 @table @option
777
778 @item threads
779 g_threads
780
781 @item profile
782 g_profile
783
784 @item vb
785 rc_target_bitrate
786
787 @item g
788 kf_max_dist
789
790 @item keyint_min
791 kf_min_dist
792
793 @item qmin
794 rc_min_quantizer
795
796 @item qmax
797 rc_max_quantizer
798
799 @item bufsize, vb
800 rc_buf_sz
801 @code{(bufsize * 1000 / vb)}
802
803 rc_buf_optimal_sz
804 @code{(bufsize * 1000 / vb * 5 / 6)}
805
806 @item rc_init_occupancy, vb
807 rc_buf_initial_sz
808 @code{(rc_init_occupancy * 1000 / vb)}
809
810 @item rc_buffer_aggressivity
811 rc_undershoot_pct
812
813 @item skip_threshold
814 rc_dropframe_thresh
815
816 @item qcomp
817 rc_2pass_vbr_bias_pct
818
819 @item maxrate, vb
820 rc_2pass_vbr_maxsection_pct
821 @code{(maxrate * 100 / vb)}
822
823 @item minrate, vb
824 rc_2pass_vbr_minsection_pct
825 @code{(minrate * 100 / vb)}
826
827 @item minrate, maxrate, vb
828 @code{VPX_CBR}
829 @code{(minrate == maxrate == vb)}
830
831 @item crf
832 @code{VPX_CQ}, @code{VP8E_SET_CQ_LEVEL}
833
834 @item quality
835 @table @option
836 @item @var{best}
837 @code{VPX_DL_BEST_QUALITY}
838 @item @var{good}
839 @code{VPX_DL_GOOD_QUALITY}
840 @item @var{realtime}
841 @code{VPX_DL_REALTIME}
842 @end table
843
844 @item speed
845 @code{VP8E_SET_CPUUSED}
846
847 @item nr
848 @code{VP8E_SET_NOISE_SENSITIVITY}
849
850 @item mb_threshold
851 @code{VP8E_SET_STATIC_THRESHOLD}
852
853 @item slices
854 @code{VP8E_SET_TOKEN_PARTITIONS}
855
856 @item max-intra-rate
857 @code{VP8E_SET_MAX_INTRA_BITRATE_PCT}
858
859 @item force_key_frames
860 @code{VPX_EFLAG_FORCE_KF}
861
862 @item Alternate reference frame related
863 @table @option
864 @item vp8flags altref
865 @code{VP8E_SET_ENABLEAUTOALTREF}
866 @item @var{arnr_max_frames}
867 @code{VP8E_SET_ARNR_MAXFRAMES}
868 @item @var{arnr_type}
869 @code{VP8E_SET_ARNR_TYPE}
870 @item @var{arnr_strength}
871 @code{VP8E_SET_ARNR_STRENGTH}
872 @item @var{rc_lookahead}
873 g_lag_in_frames
874 @end table
875
876 @item vp8flags error_resilient
877 g_error_resilient
878
879 @end table
880
881 For more information about libvpx see:
882 @url{http://www.webmproject.org/}
883
884 @section libx264
885
886 x264 H.264/MPEG-4 AVC encoder wrapper.
887
888 This encoder requires the presence of the libx264 headers and library
889 during configuration. You need to explicitly configure the build with
890 @code{--enable-libx264}.
891
892 libx264 supports an impressive number of features, including 8x8 and
893 4x4 adaptive spatial transform, adaptive B-frame placement, CAVLC/CABAC
894 entropy coding, interlacing (MBAFF), lossless mode, psy optimizations
895 for detail retention (adaptive quantization, psy-RD, psy-trellis).
896
897 Many libx264 encoder options are mapped to FFmpeg global codec
898 options, while unique encoder options are provided through private
899 options. Additionally the @option{x264opts} and @option{x264-params}
900 private options allows to pass a list of key=value tuples as accepted
901 by the libx264 @code{x264_param_parse} function.
902
903 The x264 project website is at
904 @url{http://www.videolan.org/developers/x264.html}.
905
906 @subsection Options
907
908 The following options are supported by the libx264 wrapper. The
909 @command{x264}-equivalent options or values are listed in parentheses
910 for easy migration.
911
912 To reduce the duplication of documentation, only the private options
913 and some others requiring special attention are documented here. For
914 the documentation of the undocumented generic options, see
915 @ref{codec-options,,the Codec Options chapter}.
916
917 To get a more accurate and extensive documentation of the libx264
918 options, invoke the command @command{x264 --full-help} or consult
919 the libx264 documentation.
920
921 @table @option
922 @item b (@emph{bitrate})
923 Set bitrate in bits/s. Note that FFmpeg's @option{b} option is
924 expressed in bits/s, while @command{x264}'s @option{bitrate} is in
925 kilobits/s.
926
927 @item bf (@emph{bframes})
928
929 @item g (@emph{keyint})
930
931 @item qmax (@emph{qpmax})
932
933 @item qmin (@emph{qpmin})
934
935 @item qdiff (@emph{qpstep})
936
937 @item qblur (@emph{qblur})
938
939 @item qcomp (@emph{qcomp})
940
941 @item refs (@emph{ref})
942
943 @item sc_threshold (@emph{scenecut})
944
945 @item trellis (@emph{trellis})
946
947 @item nr  (@emph{nr})
948
949 @item me_range (@emph{merange})
950
951 @item me_method (@emph{me})
952 Set motion estimation method. Possible values in the decreasing order
953 of speed:
954
955 @table @samp
956 @item dia (@emph{dia})
957 @item epzs (@emph{dia})
958 Diamond search with radius 1 (fastest). @samp{epzs} is an alias for
959 @samp{dia}.
960 @item hex (@emph{hex})
961 Hexagonal search with radius 2.
962 @item umh (@emph{umh})
963 Uneven multi-hexagon search.
964 @item esa (@emph{esa})
965 Exhaustive search.
966 @item tesa (@emph{tesa})
967 Hadamard exhaustive search (slowest).
968 @end table
969
970 @item subq (@emph{subme})
971
972 @item b_strategy (@emph{b-adapt})
973
974 @item keyint_min (@emph{min-keyint})
975
976 @item coder
977 Set entropy encoder. Possible values:
978
979 @table @samp
980 @item ac
981 Enable CABAC.
982
983 @item vlc
984 Enable CAVLC and disable CABAC. It generates the same effect as
985 @command{x264}'s @option{--no-cabac} option.
986 @end table
987
988 @item cmp
989 Set full pixel motion estimation comparation algorithm. Possible values:
990
991 @table @samp
992 @item chroma
993 Enable chroma in motion estimation.
994
995 @item sad
996 Ignore chroma in motion estimation. It generates the same effect as
997 @command{x264}'s @option{--no-chroma-me} option.
998 @end table
999
1000 @item threads (@emph{threads})
1001
1002 @item thread_type
1003 Set multithreading technique. Possible values:
1004
1005 @table @samp
1006 @item slice
1007 Slice-based multithreading. It generates the same effect as
1008 @command{x264}'s @option{--sliced-threads} option.
1009 @item frame
1010 Frame-based multithreading.
1011 @end table
1012
1013 @item flags
1014 Set encoding flags. It can be used to disable closed GOP and enable
1015 open GOP by setting it to @code{-cgop}. The result is similar to
1016 the behavior of @command{x264}'s @option{--open-gop} option.
1017
1018 @item rc_init_occupancy (@emph{vbv-init})
1019
1020 @item preset (@emph{preset})
1021 Set the encoding preset.
1022
1023 @item tune (@emph{tune})
1024 Set tuning of the encoding params.
1025
1026 @item profile (@emph{profile})
1027 Set profile restrictions.
1028
1029 @item fastfirstpass
1030 Enable fast settings when encoding first pass, when set to 1. When set
1031 to 0, it has the same effect of @command{x264}'s
1032 @option{--slow-firstpass} option.
1033
1034 @item crf (@emph{crf})
1035 Set the quality for constant quality mode.
1036
1037 @item crf_max (@emph{crf-max})
1038 In CRF mode, prevents VBV from lowering quality beyond this point.
1039
1040 @item qp (@emph{qp})
1041 Set constant quantization rate control method parameter.
1042
1043 @item aq-mode (@emph{aq-mode})
1044 Set AQ method. Possible values:
1045
1046 @table @samp
1047 @item none (@emph{0})
1048 Disabled.
1049
1050 @item variance (@emph{1})
1051 Variance AQ (complexity mask).
1052
1053 @item autovariance (@emph{2})
1054 Auto-variance AQ (experimental).
1055 @end table
1056
1057 @item aq-strength (@emph{aq-strength})
1058 Set AQ strength, reduce blocking and blurring in flat and textured areas.
1059
1060 @item psy
1061 Use psychovisual optimizations when set to 1. When set to 0, it has the
1062 same effect as @command{x264}'s @option{--no-psy} option.
1063
1064 @item psy-rd  (@emph{psy-rd})
1065 Set strength of psychovisual optimization, in
1066 @var{psy-rd}:@var{psy-trellis} format.
1067
1068 @item rc-lookahead (@emph{rc-lookahead})
1069 Set number of frames to look ahead for frametype and ratecontrol.
1070
1071 @item weightb
1072 Enable weighted prediction for B-frames when set to 1. When set to 0,
1073 it has the same effect as @command{x264}'s @option{--no-weightb} option.
1074
1075 @item weightp (@emph{weightp})
1076 Set weighted prediction method for P-frames. Possible values:
1077
1078 @table @samp
1079 @item none (@emph{0})
1080 Disabled
1081 @item simple (@emph{1})
1082 Enable only weighted refs
1083 @item smart (@emph{2})
1084 Enable both weighted refs and duplicates
1085 @end table
1086
1087 @item ssim (@emph{ssim})
1088 Enable calculation and printing SSIM stats after the encoding.
1089
1090 @item intra-refresh (@emph{intra-refresh})
1091 Enable the use of Periodic Intra Refresh instead of IDR frames when set
1092 to 1.
1093
1094 @item bluray-compat (@emph{bluray-compat})
1095 Configure the encoder to be compatible with the bluray standard.
1096 It is a shorthand for setting "bluray-compat=1 force-cfr=1".
1097
1098 @item b-bias (@emph{b-bias})
1099 Set the influence on how often B-frames are used.
1100
1101 @item b-pyramid (@emph{b-pyramid})
1102 Set method for keeping of some B-frames as references. Possible values:
1103
1104 @table @samp
1105 @item none (@emph{none})
1106 Disabled.
1107 @item strict (@emph{strict})
1108 Strictly hierarchical pyramid.
1109 @item normal (@emph{normal})
1110 Non-strict (not Blu-ray compatible).
1111 @end table
1112
1113 @item mixed-refs
1114 Enable the use of one reference per partition, as opposed to one
1115 reference per macroblock when set to 1. When set to 0, it has the
1116 same effect as @command{x264}'s @option{--no-mixed-refs} option.
1117
1118 @item 8x8dct
1119 Enable adaptive spatial transform (high profile 8x8 transform)
1120 when set to 1. When set to 0, it has the same effect as
1121 @command{x264}'s @option{--no-8x8dct} option.
1122
1123 @item fast-pskip
1124 Enable early SKIP detection on P-frames when set to 1. When set
1125 to 0, it has the same effect as @command{x264}'s
1126 @option{--no-fast-pskip} option.
1127
1128 @item aud (@emph{aud})
1129 Enable use of access unit delimiters when set to 1.
1130
1131 @item mbtree
1132 Enable use macroblock tree ratecontrol when set to 1. When set
1133 to 0, it has the same effect as @command{x264}'s
1134 @option{--no-mbtree} option.
1135
1136 @item deblock (@emph{deblock})
1137 Set loop filter parameters, in @var{alpha}:@var{beta} form.
1138
1139 @item cplxblur (@emph{cplxblur})
1140 Set fluctuations reduction in QP (before curve compression).
1141
1142 @item partitions (@emph{partitions})
1143 Set partitions to consider as a comma-separated list of. Possible
1144 values in the list:
1145
1146 @table @samp
1147 @item p8x8
1148 8x8 P-frame partition.
1149 @item p4x4
1150 4x4 P-frame partition.
1151 @item b8x8
1152 4x4 B-frame partition.
1153 @item i8x8
1154 8x8 I-frame partition.
1155 @item i4x4
1156 4x4 I-frame partition.
1157 (Enabling @samp{p4x4} requires @samp{p8x8} to be enabled. Enabling
1158 @samp{i8x8} requires adaptive spatial transform (@option{8x8dct}
1159 option) to be enabled.)
1160 @item none (@emph{none})
1161 Do not consider any partitions.
1162 @item all (@emph{all})
1163 Consider every partition.
1164 @end table
1165
1166 @item direct-pred (@emph{direct})
1167 Set direct MV prediction mode. Possible values:
1168
1169 @table @samp
1170 @item none (@emph{none})
1171 Disable MV prediction.
1172 @item spatial (@emph{spatial})
1173 Enable spatial predicting.
1174 @item temporal (@emph{temporal})
1175 Enable temporal predicting.
1176 @item auto (@emph{auto})
1177 Automatically decided.
1178 @end table
1179
1180 @item slice-max-size (@emph{slice-max-size})
1181 Set the limit of the size of each slice in bytes. If not specified
1182 but RTP payload size (@option{ps}) is specified, that is used.
1183
1184 @item stats (@emph{stats})
1185 Set the file name for multi-pass stats.
1186
1187 @item nal-hrd (@emph{nal-hrd})
1188 Set signal HRD information (requires @option{vbv-bufsize} to be set).
1189 Possible values:
1190
1191 @table @samp
1192 @item none (@emph{none})
1193 Disable HRD information signaling.
1194 @item vbr (@emph{vbr})
1195 Variable bit rate.
1196 @item cbr (@emph{cbr})
1197 Constant bit rate (not allowed in MP4 container).
1198 @end table
1199
1200 @item x264opts (N.A.)
1201 Set any x264 option, see @command{x264 --fullhelp} for a list.
1202
1203 Argument is a list of @var{key}=@var{value} couples separated by
1204 ":". In @var{filter} and @var{psy-rd} options that use ":" as a separator
1205 themselves, use "," instead. They accept it as well since long ago but this
1206 is kept undocumented for some reason.
1207
1208 For example to specify libx264 encoding options with @command{ffmpeg}:
1209 @example
1210 ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv
1211 @end example
1212
1213 @item x264-params (N.A.)
1214 Override the x264 configuration using a :-separated list of key=value
1215 parameters.
1216
1217 This option is functionally the same as the @option{x264opts}, but is
1218 duplicated for compability with the Libav fork.
1219
1220 For example to specify libx264 encoding options with @command{ffmpeg}:
1221 @example
1222 ffmpeg -i INPUT -c:v libx264 -x264-params level=30:bframes=0:weightp=0:\
1223 cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:\
1224 no-fast-pskip=1:subq=6:8x8dct=0:trellis=0 OUTPUT
1225 @end example
1226 @end table
1227
1228 Encoding ffpresets for common usages are provided so they can be used with the
1229 general presets system (e.g. passing the @option{pre} option).
1230
1231 @section libxvid
1232
1233 Xvid MPEG-4 Part 2 encoder wrapper.
1234
1235 This encoder requires the presence of the libxvidcore headers and library
1236 during configuration. You need to explicitly configure the build with
1237 @code{--enable-libxvid --enable-gpl}.
1238
1239 The native @code{mpeg4} encoder supports the MPEG-4 Part 2 format, so
1240 users can encode to this format without this library.
1241
1242 @subsection Options
1243
1244 The following options are supported by the libxvid wrapper. Some of
1245 the following options are listed but are not documented, and
1246 correspond to shared codec options. See @ref{codec-options,,the Codec
1247 Options chapter} for their documentation. The other shared options
1248 which are not listed have no effect for the libxvid encoder.
1249
1250 @table @option
1251 @item b
1252
1253 @item g
1254
1255 @item qmin
1256
1257 @item qmax
1258
1259 @item mpeg_quant
1260
1261 @item threads
1262
1263 @item bf
1264
1265 @item b_qfactor
1266
1267 @item b_qoffset
1268
1269 @item flags
1270 Set specific encoding flags. Possible values:
1271
1272 @table @samp
1273
1274 @item mv4
1275 Use four motion vector by macroblock.
1276
1277 @item aic
1278 Enable high quality AC prediction.
1279
1280 @item gray
1281 Only encode grayscale.
1282
1283 @item gmc
1284 Enable the use of global motion compensation (GMC).
1285
1286 @item qpel
1287 Enable quarter-pixel motion compensation.
1288
1289 @item cgop
1290 Enable closed GOP.
1291
1292 @item global_header
1293 Place global headers in extradata instead of every keyframe.
1294
1295 @end table
1296
1297 @item trellis
1298
1299 @item me_method
1300 Set motion estimation method. Possible values in decreasing order of
1301 speed and increasing order of quality:
1302
1303 @table @samp
1304 @item zero
1305 Use no motion estimation (default).
1306
1307 @item phods
1308 @item x1
1309 @item log
1310 Enable advanced diamond zonal search for 16x16 blocks and half-pixel
1311 refinement for 16x16 blocks. @samp{x1} and @samp{log} are aliases for
1312 @samp{phods}.
1313
1314 @item epzs
1315 Enable all of the things described above, plus advanced diamond zonal
1316 search for 8x8 blocks, half-pixel refinement for 8x8 blocks, and motion
1317 estimation on chroma planes.
1318
1319 @item full
1320 Enable all of the things described above, plus extended 16x16 and 8x8
1321 blocks search.
1322 @end table
1323
1324 @item mbd
1325 Set macroblock decision algorithm. Possible values in the increasing
1326 order of quality:
1327
1328 @table @samp
1329 @item simple
1330 Use macroblock comparing function algorithm (default).
1331
1332 @item bits
1333 Enable rate distortion-based half pixel and quarter pixel refinement for
1334 16x16 blocks.
1335
1336 @item rd
1337 Enable all of the things described above, plus rate distortion-based
1338 half pixel and quarter pixel refinement for 8x8 blocks, and rate
1339 distortion-based search using square pattern.
1340 @end table
1341
1342 @item lumi_aq
1343 Enable lumi masking adaptive quantization when set to 1. Default is 0
1344 (disabled).
1345
1346 @item variance_aq
1347 Enable variance adaptive quantization when set to 1. Default is 0
1348 (disabled).
1349
1350 When combined with @option{lumi_aq}, the resulting quality will not
1351 be better than any of the two specified individually. In other
1352 words, the resulting quality will be the worse one of the two
1353 effects.
1354
1355 @item ssim
1356 Set structural similarity (SSIM) displaying method. Possible values:
1357
1358 @table @samp
1359 @item off
1360 Disable displaying of SSIM information.
1361
1362 @item avg
1363 Output average SSIM at the end of encoding to stdout. The format of
1364 showing the average SSIM is:
1365
1366 @example
1367 Average SSIM: %f
1368 @end example
1369
1370 For users who are not familiar with C, %f means a float number, or
1371 a decimal (e.g. 0.939232).
1372
1373 @item frame
1374 Output both per-frame SSIM data during encoding and average SSIM at
1375 the end of encoding to stdout. The format of per-frame information
1376 is:
1377
1378 @example
1379        SSIM: avg: %1.3f min: %1.3f max: %1.3f
1380 @end example
1381
1382 For users who are not familiar with C, %1.3f means a float number
1383 rounded to 3 digits after the dot (e.g. 0.932).
1384
1385 @end table
1386
1387 @item ssim_acc
1388 Set SSIM accuracy. Valid options are integers within the range of
1389 0-4, while 0 gives the most accurate result and 4 computes the
1390 fastest.
1391
1392 @end table
1393
1394 @section png
1395
1396 PNG image encoder.
1397
1398 @subsection Private options
1399
1400 @table @option
1401 @item dpi @var{integer}
1402 Set physical density of pixels, in dots per inch, unset by default
1403 @item dpm @var{integer}
1404 Set physical density of pixels, in dots per meter, unset by default
1405 @end table
1406
1407 @section ProRes
1408
1409 Apple ProRes encoder.
1410
1411 FFmpeg contains 2 ProRes encoders, the prores-aw and prores-ks encoder.
1412 The used encoder can be choosen with the @code{-vcodec} option.
1413
1414 @subsection Private Options for prores-ks
1415
1416 @table @option
1417 @item profile @var{integer}
1418 Select the ProRes profile to encode
1419 @table @samp
1420 @item proxy
1421 @item lt
1422 @item standard
1423 @item hq
1424 @item 4444
1425 @end table
1426
1427 @item quant_mat @var{integer}
1428 Select quantization matrix.
1429 @table @samp
1430 @item auto
1431 @item default
1432 @item proxy
1433 @item lt
1434 @item standard
1435 @item hq
1436 @end table
1437 If set to @var{auto}, the matrix matching the profile will be picked.
1438 If not set, the matrix providing the highest quality, @var{default}, will be
1439 picked.
1440
1441 @item bits_per_mb @var{integer}
1442 How many bits to allot for coding one macroblock. Different profiles use
1443 between 200 and 2400 bits per macroblock, the maximum is 8000.
1444
1445 @item mbs_per_slice @var{integer}
1446 Number of macroblocks in each slice (1-8); the default value (8)
1447 should be good in almost all situations.
1448
1449 @item vendor @var{string}
1450 Override the 4-byte vendor ID.
1451 A custom vendor ID like @var{apl0} would claim the stream was produced by
1452 the Apple encoder.
1453
1454 @item alpha_bits @var{integer}
1455 Specify number of bits for alpha component.
1456 Possible values are @var{0}, @var{8} and @var{16}.
1457 Use @var{0} to disable alpha plane coding.
1458
1459 @end table
1460
1461 @subsection Speed considerations
1462
1463 In the default mode of operation the encoder has to honor frame constraints
1464 (i.e. not produc frames with size bigger than requested) while still making
1465 output picture as good as possible.
1466 A frame containing a lot of small details is harder to compress and the encoder
1467 would spend more time searching for appropriate quantizers for each slice.
1468
1469 Setting a higher @option{bits_per_mb} limit will improve the speed.
1470
1471 For the fastest encoding speed set the @option{qscale} parameter (4 is the
1472 recommended value) and do not set a size constraint.
1473
1474 @c man end VIDEO ENCODERS