4 Encoders are configured elements in FFmpeg which allow the encoding of
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}.
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}}.
17 The option @code{-codecs} of the ff* tools will display the list of
22 @chapter Audio Encoders
23 @c man begin AUDIO ENCODERS
25 A description of some of the currently available audio encoders
28 @section ac3 and ac3_fixed
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).
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.
43 @subsection AC-3 Metadata
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.
53 These parameters are described in detail in several publicly-available
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}
62 @subsubsection Metadata Control Options
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.
71 The metadata values set at initialization will be used for every frame in the
74 Metadata values can be changed before encoding each frame.
79 @subsubsection Downmix Levels
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:
92 Apply -4.5dB gain (default)
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:
106 Apply -6dB gain (default)
108 Silence Surround Channel(s)
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.
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.
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.
136 Not Indicated (default)
147 @subsubsection Other Metadata Options
151 @item -copyright @var{boolean}
152 Copyright Indicator. Specifies whether a copyright exists for this audio.
156 No Copyright Exists (default)
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.
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.
179 Not Indicated (default)
182 Not Dolby Surround Encoded
185 Dolby Surround Encoded
188 @item -original @var{boolean}
189 Original Bit Stream Indicator. Specifies whether this audio is from the
190 original source and not a copy.
197 Original Source (default)
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
212 @subsubsection Extended Bitstream Information - Part 1
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.
222 Not Indicated (default)
225 Lt/Rt Downmix Preferred
228 Lo/Ro Downmix Preferred
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.
246 Apply -4.5dB gain (default)
250 Silence Center Channel
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.
264 Apply -6.0dB gain (default)
266 Silence Surround Channel(s)
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.
284 Apply -4.5dB gain (default)
288 Silence Center Channel
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.
302 Apply -6.0dB gain (default)
304 Silence Surround Channel(s)
309 @subsubsection Extended Bitstream Information - Part 2
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.
320 Not Indicated (default)
323 Dolby Surround EX Off
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
337 Not Indicated (default)
346 @item -ad_conv_type @var{type}
347 A/D Converter Type. Indicates whether the audio has passed through HDCD A/D
352 Standard A/D Converter (default)
360 @subsection Other AC-3 Encoding Options
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.
372 @subsection Floating-Point-Only AC-3 Encoding Options
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.
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.
392 Selected by Encoder (default)
395 Disable Channel Coupling
398 Enable Channel Coupling
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.
410 Selected by Encoder (default)
417 LAME (Lame Ain't an MP3 Encoder) MP3 encoder wrapper
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}.
423 @subsection Option Mapping
425 The following options are supported by the libmp3lame wrapper,
426 the LAME-equivalent options follow the FFmpeg ones.
428 @multitable @columnfractions .2 .2
429 @item FFmpeg @tab LAME
431 FFmpeg @code{b} option is expressed in bits/s, lame @code{bitrate}
434 Quality setting for VBR.
435 @item compression_level @tab q
436 Algorithm quality. Valid options are integers from 0-9.
437 @item reservoir @tab N.A.
438 Enable use of bit reservoir. LAME has this enabled by default.
439 @item joint_stereo @tab -m j
440 Enables the encoder to use (on a frame by frame basis) either L/R
441 stereo or mid/side stereo.
444 @c man end AUDIO ENCODERS
446 @chapter Video Encoders
447 @c man begin VIDEO ENCODERS
449 A description of some of the currently available video encoders
454 Theora format supported through libtheora.
456 Requires the presence of the libtheora headers and library during
457 configuration. You need to explicitly configure the build with
458 @code{--enable-libtheora}.
462 The following global options are mapped to internal libtheora options
463 which affect the quality and the bitrate of the encoded stream.
467 Set the video bitrate, only works if the @code{qscale} flag in
468 @option{flags} is not enabled.
471 Used to enable constant quality mode encoding through the
472 @option{qscale} flag, and to enable the @code{pass1} and @code{pass2}
479 Set the global quality in lambda units, only works if the
480 @code{qscale} flag in @option{flags} is enabled. The value is clipped
481 in the [0 - 10*@code{FF_QP2LAMBDA}] range, and then multiplied for 6.3
482 to get a value in the native libtheora range [0-63]. A higher value
483 corresponds to a higher quality.
485 For example, to set maximum constant quality encoding with
488 ffmpeg -i INPUT -flags:v qscale -global_quality:v "10*QP2LAMBDA" -codec:v libtheora OUTPUT.ogg
494 VP8 format supported through libvpx.
496 Requires the presence of the libvpx headers and library during configuration.
497 You need to explicitly configure the build with @code{--enable-libvpx}.
501 Mapping from FFmpeg to libvpx options with conversion notes in parentheses.
528 @code{(bufsize * 1000 / vb)}
531 @code{(bufsize * 1000 / vb * 5 / 6)}
533 @item rc_init_occupancy, vb
535 @code{(rc_init_occupancy * 1000 / vb)}
537 @item rc_buffer_aggressivity
544 rc_2pass_vbr_bias_pct
547 rc_2pass_vbr_maxsection_pct
548 @code{(maxrate * 100 / vb)}
551 rc_2pass_vbr_minsection_pct
552 @code{(minrate * 100 / vb)}
554 @item minrate, maxrate, vb
556 @code{(minrate == maxrate == vb)}
559 @code{VPX_CQ}, @code{VP8E_SET_CQ_LEVEL}
564 @code{VPX_DL_BEST_QUALITY}
566 @code{VPX_DL_GOOD_QUALITY}
568 @code{VPX_DL_REALTIME}
572 @code{VP8E_SET_CPUUSED}
575 @code{VP8E_SET_NOISE_SENSITIVITY}
578 @code{VP8E_SET_STATIC_THRESHOLD}
581 @code{VP8E_SET_TOKEN_PARTITIONS}
584 @code{VP8E_SET_MAX_INTRA_BITRATE_PCT}
586 @item force_key_frames
587 @code{VPX_EFLAG_FORCE_KF}
589 @item Alternate reference frame related
591 @item vp8flags altref
592 @code{VP8E_SET_ENABLEAUTOALTREF}
593 @item @var{arnr_max_frames}
594 @code{VP8E_SET_ARNR_MAXFRAMES}
595 @item @var{arnr_type}
596 @code{VP8E_SET_ARNR_TYPE}
597 @item @var{arnr_strength}
598 @code{VP8E_SET_ARNR_STRENGTH}
599 @item @var{rc_lookahead}
603 @item vp8flags error_resilient
608 For more information about libvpx see:
609 @url{http://www.webmproject.org/}
613 x264 H.264/MPEG-4 AVC encoder wrapper
615 Requires the presence of the libx264 headers and library during
616 configuration. You need to explicitly configure the build with
617 @code{--enable-libx264}.
619 x264 supports an impressive number of features, including 8x8 and 4x4 adaptive
620 spatial transform, adaptive B-frame placement, CAVLC/CABAC entropy coding,
621 interlacing (MBAFF), lossless mode, psy optimizations for detail retention
622 (adaptive quantization, psy-RD, psy-trellis).
624 The FFmpeg wrapper provides a mapping for most of them using global options
625 that match those of the encoders and provides private options for the unique
626 encoder options. Additionally an expert override is provided to directly pass
627 a list of key=value tuples as accepted by x264_param_parse.
629 @subsection Option Mapping
631 The following options are supported by the x264 wrapper, the x264-equivalent
632 options follow the FFmpeg ones.
634 @multitable @columnfractions .2 .2
636 FFmpeg @code{b} option is expressed in bits/s, x264 @code{bitrate} in kilobits/s.
637 @item bf @tab bframes
638 Maximum number of B-frames.
641 @item qmin @tab qpmin
642 @item qmax @tab qpmax
643 @item qdiff @tab qpstep
644 @item qblur @tab qblur
645 @item qcomp @tab qcomp
647 @item sc_threshold @tab scenecut
648 @item trellis @tab trellis
651 @item me_range @tab merange
652 @item me_method @tab me
653 @item subq @tab subme
654 @item b_strategy @tab b-adapt
655 @item keyint_min @tab keyint-min
656 @item coder @tab cabac
657 Set coder to @code{ac} to use CABAC.
658 @item cmp @tab chroma-me
659 Set to @code{chroma} to use chroma motion estimation.
660 @item threads @tab threads
661 @item thread_type @tab sliced_threads
662 Set to @code{slice} to use sliced threading instead of frame threading.
663 @item flags -cgop @tab open-gop
664 Set @code{-cgop} to use recovery points to close GOPs.
665 @item rc_init_occupancy @tab vbv-init
666 Initial buffer occupancy.
669 @subsection Private Options
671 @item -preset @var{string}
672 Set the encoding preset (cf. x264 --fullhelp).
673 @item -tune @var{string}
674 Tune the encoding params (cf. x264 --fullhelp).
675 @item -profile @var{string}
676 Set profile restrictions (cf. x264 --fullhelp).
677 @item -fastfirstpass @var{integer}
678 Use fast settings when encoding first pass.
679 @item -crf @var{float}
680 Select the quality for constant quality mode.
681 @item -crf_max @var{float}
682 In CRF mode, prevents VBV from lowering quality beyond this point.
683 @item -qp @var{integer}
684 Constant quantization parameter rate control method.
685 @item -aq-mode @var{integer}
693 Variance AQ (complexity mask).
695 Auto-variance AQ (experimental).
697 @item -aq-strength @var{float}
698 AQ strength, reduces blocking and blurring in flat and textured areas.
699 @item -psy @var{integer}
700 Use psychovisual optimizations.
701 @item -psy-rd @var{string}
702 Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.
703 @item -rc-lookahead @var{integer}
704 Number of frames to look ahead for frametype and ratecontrol.
705 @item -weightb @var{integer}
706 Weighted prediction for B-frames.
707 @item -weightp @var{integer}
708 Weighted prediction analysis method.
719 @item -ssim @var{integer}
720 Calculate and print SSIM stats.
721 @item -intra-refresh @var{integer}
722 Use Periodic Intra Refresh instead of IDR frames.
723 @item -b-bias @var{integer}
724 Influences how often B-frames are used.
725 @item -b-pyramid @var{integer}
726 Keep some B-frames as references.
733 Strictly hierarchical pyramid.
735 Non-strict (not Blu-ray compatible).
737 @item -mixed-refs @var{integer}
738 One reference per partition, as opposed to one reference per macroblock.
739 @item -8x8dct @var{integer}
740 High profile 8x8 transform.
741 @item -fast-pskip @var{integer}
742 @item -aud @var{integer}
743 Use access unit delimiters.
744 @item -mbtree @var{integer}
745 Use macroblock tree ratecontrol.
746 @item -deblock @var{string}
747 Loop filter parameters, in <alpha:beta> form.
748 @item -cplxblur @var{float}
749 Reduce fluctuations in QP (before curve compression).
750 @item -partitions @var{string}
751 A comma-separated list of partitions to consider, possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all.
752 @item -direct-pred @var{integer}
753 Direct MV prediction mode
766 @item -slice-max-size @var{integer}
767 Limit the size of each slice in bytes.
768 @item -stats @var{string}
769 Filename for 2 pass stats.
770 @item -nal-hrd @var{integer}
771 Signal HRD information (requires vbv-bufsize; cbr not allowed in .mp4).
783 @item x264opts @var{options}
784 Allow to set any x264 option, see @code{x264 --fullhelp} for a list.
786 @var{options} is a list of @var{key}=@var{value} couples separated by
787 ":". In @var{filter} and @var{psy-rd} options that use ":" as a separator
788 themselves, use "," instead. They accept it as well since long ago but this
789 is kept undocumented for some reason.
791 For example to specify libx264 encoding options with @command{ffmpeg}:
793 ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv
796 For more information about libx264 and the supported options see:
797 @url{http://www.videolan.org/developers/x264.html}
799 @item -x264-params @var{string}
800 Override the x264 configuration using a :-separated list of key=value parameters.
802 -x264-params level=30:bframes=0:weightp=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subq=6:8x8dct=0:trellis=0
806 Encoding avpresets for common usages are provided so they can be used with the
807 general presets system (e.g. passing the @code{-pre} option).
813 @subsection Private options
816 @item dpi @var{integer}
817 Set physical density of pixels, in dots per inch, unset by default
818 @item dpm @var{integer}
819 Set physical density of pixels, in dots per meter, unset by default
824 Apple ProRes encoder.
826 FFmpeg contains 2 ProRes encoders, the prores-aw and prores-ks encoder.
827 The used encoder can be choosen with the @code{-vcodec} option.
829 @subsection Private Options for prores-ks
832 @item profile @var{integer}
833 Select the ProRes profile to encode
841 @item quant_mat @var{integer}
842 Select quantization matrix.
851 If set to @var{auto}, the matrix matching the profile will be picked.
852 If not set, the matrix providing the highest quality, @var{default}, will be
855 @item bits_per_mb @var{integer}
856 How many bits to allot for coding one macroblock. Different profiles use
857 between 200 and 2400 bits per macroblock, the maximum is 8000.
859 @item mbs_per_slice @var{integer}
860 Number of macroblocks in each slice (1-8); the default value (8)
861 should be good in almost all situations.
863 @item vendor @var{string}
864 Override the 4-byte vendor ID.
865 A custom vendor ID like @var{apl0} would claim the stream was produced by
870 @subsection Speed considerations
872 In the default mode of operation the encoder has to honor frame constraints
873 (i.e. not produc frames with size bigger than requested) while still making
874 output picture as good as possible.
875 A frame containing a lot of small details is harder to compress and the encoder
876 would spend more time searching for appropriate quantizers for each slice.
878 Setting a higher @option{bits_per_mb} limit will improve the speed.
880 For the fastest encoding speed set the @option{qscale} parameter (4 is the
881 recommended value) and do not set a size constraint.
883 @c man end VIDEO ENCODERS