Encoders
********

Encoders are configured elements in FFmpeg which allow the encoding of multimedia streams.

When you configure your FFmpeg build, all the supported native encoders are enabled by default. Encoders requiring an external library must be enabled manually via the corresponding --enable-lib option. You can list all available encoders using the configure option --list-encoders.

You can disable all the encoders with the configure option --disable-encoders and selectively enable / disable single encoders with the options --enable-encoder=ENCODER / --disable-encoder=ENCODER.

The option -codecs of the ff* tools will display the list of enabled encoders.

Audio Encoders
**************

A description of some of the currently available audio encoders follows.

ac3 and ac3_fixed
=================

AC-3 audio encoders.

These encoders implement part of ATSC A/52:2010 and ETSI TS 102 366, as well as the undocumented RealAudio 3 (a.k.a. dnet).

The AC3 encoder uses floating-point math, while the AC3_FIXED encoder only uses fixed-point integer math. This does not mean that one is always faster, just that one or the other may be better suited to a particular system. The floating-point encoder will generally produce better quality audio for a given bitrate. The AC3_FIXED encoder is not the default codec for any of the output formats, so it must be specified explicitly using the option -acodec ac3_fixed in order to use it.

AC-3 Metadata
-------------

The AC-3 metadata options are used to set parameters that describe the audio, but in most cases do not affect the audio encoding itself. Some of the options do directly affect or influence the decoding and playback of the resulting bitstream, while others are just for informational purposes. A few of the options will add bits to the output stream that could otherwise be used for audio data, and will thus affect the quality of the output. Those will be indicated accordingly with a note in the option list below.

These parameters are described in detail in several publicly-available documents.

  * A/52:2010 - Digital Audio Compression (AC-3) (E-AC-3) Standard (http://www.atsc.org/cms/standards/a_52-2010.pdf)

  * A/54 - Guide to the Use of the ATSC Digital Television Standard (http://www.atsc.org/cms/standards/a_54a_with_corr_1.pdf)

  * Dolby Metadata Guide (http://www.dolby.com/uploadedFiles/zz-_Shared_Assets/English_PDFs/Professional/18_Metadata.Guide.pdf)

  * Dolby Digital Professional Encoding Guidelines (http://www.dolby.com/uploadedFiles/zz-_Shared_Assets/English_PDFs/Professional/46_DDEncodingGuidelines.pdf)

Metadata Control Options
........................

-per_frame_metadata BOOLEAN
     Allow Per-Frame Metadata. Specifies if the encoder should check for changing metadata for each frame.

     0
          The metadata values set at initialization will be used for every frame in the stream. (default)

     1
          Metadata values can be changed before encoding each frame.

Downmix Levels
..............

-center_mixlev LEVEL
     Center Mix Level. The amount of gain the decoder should apply to the center channel when downmixing to stereo. This field will only be written to the bitstream if a center channel is present. The value is specified as a scale factor. There are 3 valid values:

     0.707
          Apply -3dB gain

     0.595
          Apply -4.5dB gain (default)

     0.500
          Apply -6dB gain

-surround_mixlev LEVEL
     Surround Mix Level. The amount of gain the decoder should apply to the surround channel(s) when downmixing to stereo. This field will only be written to the bitstream if one or more surround channels are present. The value is specified as a scale factor.  There are 3 valid values:

     0.707
          Apply -3dB gain

     0.500
          Apply -6dB gain (default)

     0.000
          Silence Surround Channel(s)

Audio Production Information
............................

Audio Production Information is optional information describing the mixing environment.  Either none or both of the fields are written to the bitstream.

-mixing_level NUMBER
     Mixing Level. Specifies peak sound pressure level (SPL) in the production environment when the mix was mastered. Valid values are 80 to 111, or -1 for unknown or not indicated. The default value is -1, but that value cannot be used if the Audio Production Information is written to the bitstream. Therefore, if the room_type option is not the default value, the mixing_level option must not be -1.

-room_type TYPE
     Room Type. Describes the equalization used during the final mixing session at the studio or on the dubbing stage. A large room is a dubbing stage with the industry standard X-curve equalization; a small room has flat equalization. This field will not be written to the bitstream if both the mixing_level option and the room_type option have the default values.

     0
     notindicated
          Not Indicated (default)

     1
     large
          Large Room

     2
     small
          Small Room

Other Metadata Options
......................

-copyright BOOLEAN
     Copyright Indicator. Specifies whether a copyright exists for this audio.

     0
     off
          No Copyright Exists (default)

     1
     on
          Copyright Exists

-dialnorm VALUE
     Dialogue Normalization. Indicates how far the average dialogue level of the program is below digital 100% full scale (0 dBFS). This parameter determines a level shift during audio reproduction that sets the average volume of the dialogue to a preset level. The goal is to match volume level between program sources. A value of -31dB will result in no volume level change, relative to the source volume, during audio reproduction. Valid values are whole numbers in the range -31 to -1, with -31 being the default.

-dsur_mode MODE
     Dolby Surround Mode. Specifies whether the stereo signal uses Dolby Surround (Pro Logic). This field will only be written to the bitstream if the audio stream is stereo. Using this option does NOT mean the encoder will actually apply Dolby Surround processing.

     0
     notindicated
          Not Indicated (default)

     1
     off
          Not Dolby Surround Encoded

     2
     on
          Dolby Surround Encoded

-original BOOLEAN
     Original Bit Stream Indicator. Specifies whether this audio is from the original source and not a copy.

     0
     off
          Not Original Source

     1
     on
          Original Source (default)

Extended Bitstream Information
------------------------------

The extended bitstream options are part of the Alternate Bit Stream Syntax as specified in Annex D of the A/52:2010 standard. It is grouped into 2 parts. If any one parameter in a group is specified, all values in that group will be written to the bitstream.  Default values are used for those that are written but have not been specified.  If the mixing levels are written, the decoder will use these values instead of the ones specified in the center_mixlev and surround_mixlev options if it supports the Alternate Bit Stream Syntax.

Extended Bitstream Information - Part 1
.......................................

-dmix_mode MODE
     Preferred Stereo Downmix Mode. Allows the user to select either Lt/Rt (Dolby Surround) or Lo/Ro (normal stereo) as the preferred stereo downmix mode.

     0
     notindicated
          Not Indicated (default)

     1
     ltrt
          Lt/Rt Downmix Preferred

     2
     loro
          Lo/Ro Downmix Preferred

-ltrt_cmixlev LEVEL
     Lt/Rt Center Mix Level. The amount of gain the decoder should apply to the center channel when downmixing to stereo in Lt/Rt mode.

     1.414
          Apply +3dB gain

     1.189
          Apply +1.5dB gain

     1.000
          Apply 0dB gain

     0.841
          Apply -1.5dB gain

     0.707
          Apply -3.0dB gain

     0.595
          Apply -4.5dB gain (default)

     0.500
          Apply -6.0dB gain

     0.000
          Silence Center Channel

-ltrt_surmixlev LEVEL
     Lt/Rt Surround Mix Level. The amount of gain the decoder should apply to the surround channel(s) when downmixing to stereo in Lt/Rt mode.

     0.841
          Apply -1.5dB gain

     0.707
          Apply -3.0dB gain

     0.595
          Apply -4.5dB gain

     0.500
          Apply -6.0dB gain (default)

     0.000
          Silence Surround Channel(s)

-loro_cmixlev LEVEL
     Lo/Ro Center Mix Level. The amount of gain the decoder should apply to the center channel when downmixing to stereo in Lo/Ro mode.

     1.414
          Apply +3dB gain

     1.189
          Apply +1.5dB gain

     1.000
          Apply 0dB gain

     0.841
          Apply -1.5dB gain

     0.707
          Apply -3.0dB gain

     0.595
          Apply -4.5dB gain (default)

     0.500
          Apply -6.0dB gain

     0.000
          Silence Center Channel

-loro_surmixlev LEVEL
     Lo/Ro Surround Mix Level. The amount of gain the decoder should apply to the surround channel(s) when downmixing to stereo in Lo/Ro mode.

     0.841
          Apply -1.5dB gain

     0.707
          Apply -3.0dB gain

     0.595
          Apply -4.5dB gain

     0.500
          Apply -6.0dB gain (default)

     0.000
          Silence Surround Channel(s)

Extended Bitstream Information - Part 2
.......................................

-dsurex_mode MODE
     Dolby Surround EX Mode. Indicates whether the stream uses Dolby Surround EX (7.1 matrixed to 5.1). Using this option does NOT mean the encoder will actually apply Dolby Surround EX processing.

     0
     notindicated
          Not Indicated (default)

     1
     on
          Dolby Surround EX Off

     2
     off
          Dolby Surround EX On

-dheadphone_mode MODE
     Dolby Headphone Mode. Indicates whether the stream uses Dolby Headphone encoding (multi-channel matrixed to 2.0 for use with headphones). Using this option does NOT mean the encoder will actually apply Dolby Headphone processing.

     0
     notindicated
          Not Indicated (default)

     1
     on
          Dolby Headphone Off

     2
     off
          Dolby Headphone On

-ad_conv_type TYPE
     A/D Converter Type. Indicates whether the audio has passed through HDCD A/D conversion.

     0
     standard
          Standard A/D Converter (default)

     1
     hdcd
          HDCD A/D Converter

Other AC-3 Encoding Options
---------------------------

-stereo_rematrixing BOOLEAN
     Stereo Rematrixing. Enables/Disables use of rematrixing for stereo input. This is an optional AC-3 feature that increases quality by selectively encoding the left/right channels as mid/side. This option is enabled by default, and it is highly recommended that it be left as enabled except for testing purposes.

Floating-Point-Only AC-3 Encoding Options
-----------------------------------------

These options are only valid for the floating-point encoder and do not exist for the fixed-point encoder due to the corresponding features not being implemented in fixed-point.

-channel_coupling BOOLEAN
     Enables/Disables use of channel coupling, which is an optional AC-3 feature that increases quality by combining high frequency information from multiple channels into a single channel. The per-channel high frequency information is sent with less accuracy in both the frequency and time domains. This allows more bits to be used for lower frequencies while preserving enough information to reconstruct the high frequencies. This option is enabled by default for the floating-point encoder and should generally be left as enabled except for testing purposes or to increase encoding speed.

     -1
     auto
          Selected by Encoder (default)

     0
     off
          Disable Channel Coupling

     1
     on
          Enable Channel Coupling

-cpl_start_band NUMBER
     Coupling Start Band. Sets the channel coupling start band, from 1 to 15. If a value higher than the bandwidth is used, it will be reduced to 1 less than the coupling end band. If AUTO is used, the start band will be determined by the encoder based on the bit rate, sample rate, and channel layout. This option has no effect if channel coupling is disabled.

     -1
     auto
          Selected by Encoder (default)

Video Encoders
**************

A description of some of the currently available video encoders follows.

libtheora
=========

Theora format supported through libtheora.

Requires the presence of the libtheora headers and library during configuration. You need to explicitly configure the build with --enable-libtheora.

Options
-------

The following global options are mapped to internal libtheora options which affect the quality and the bitrate of the encoded stream.

b
     Set the video bitrate, only works if the qscale flag in flags is not enabled.

flags
     Used to enable constant quality mode encoding through the qscale flag, and to enable the pass1 and pass2 modes.

g
     Set the GOP size.

global_quality
     Set the global quality in lambda units, only works if the qscale flag in flags is enabled. The value is clipped in the [0 - 10*FF_QP2LAMBDA] range, and then multiplied for 6.3 to get a value in the native libtheora range [0-63].

     For example, to set maximum constant quality encoding with ffmpeg:

          ffmpeg -i INPUT -flags:v qscale -global_quality:v "10*QP2LAMBDA" -codec:v libtheora OUTPUT.ogg

libvpx
======

VP8 format supported through libvpx.

Requires the presence of the libvpx headers and library during configuration. You need to explicitly configure the build with --enable-libvpx.

Options
-------

Mapping from FFmpeg to libvpx options with conversion notes in parentheses.

threads
     g_threads

profile
     g_profile

vb
     rc_target_bitrate

g
     kf_max_dist

keyint_min
     kf_min_dist

qmin
     rc_min_quantizer

qmax
     rc_max_quantizer

bufsize, vb
     rc_buf_sz (bufsize * 1000 / vb)

     rc_buf_optimal_sz (bufsize * 1000 / vb * 5 / 6)

rc_init_occupancy, vb
     rc_buf_initial_sz (rc_init_occupancy * 1000 / vb)

rc_buffer_aggressivity
     rc_undershoot_pct

skip_threshold
     rc_dropframe_thresh

qcomp
     rc_2pass_vbr_bias_pct

maxrate, vb
     rc_2pass_vbr_maxsection_pct (maxrate * 100 / vb)

minrate, vb
     rc_2pass_vbr_minsection_pct (minrate * 100 / vb)

minrate, maxrate, vb
     VPX_CBR (minrate == maxrate == vb)

crf
     VPX_CQ, VP8E_SET_CQ_LEVEL

quality

     BEST
          VPX_DL_BEST_QUALITY

     GOOD
          VPX_DL_GOOD_QUALITY

     REALTIME
          VPX_DL_REALTIME

speed
     VP8E_SET_CPUUSED

nr
     VP8E_SET_NOISE_SENSITIVITY

mb_threshold
     VP8E_SET_STATIC_THRESHOLD

slices
     VP8E_SET_TOKEN_PARTITIONS

max-intra-rate
     VP8E_SET_MAX_INTRA_BITRATE_PCT

force_key_frames
     VPX_EFLAG_FORCE_KF

Alternate reference frame related

     vp8flags altref
          VP8E_SET_ENABLEAUTOALTREF

     ARNR_MAX_FRAMES
          VP8E_SET_ARNR_MAXFRAMES

     ARNR_TYPE
          VP8E_SET_ARNR_TYPE

     ARNR_STRENGTH
          VP8E_SET_ARNR_STRENGTH

     RC_LOOKAHEAD
          g_lag_in_frames

vp8flags error_resilient
     g_error_resilient

For more information about libvpx see: http://www.webmproject.org/

libx264
=======

H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 format supported through libx264.

Requires the presence of the libx264 headers and library during configuration. You need to explicitly configure the build with --enable-libx264.

Options
-------

preset PRESET_NAME
     Set the encoding preset.

tune TUNE_NAME
     Tune the encoding params.

fastfirstpass BOOL
     Use fast settings when encoding first pass, default value is 1.

profile PROFILE_NAME
     Set profile restrictions.

level LEVEL
     Specify level (as defined by Annex A). Deprecated in favor of X264OPTS.

passlogfile FILENAME
     Specify filename for 2 pass stats. Deprecated in favor of X264OPTS (see STATS libx264 option).

wpredp WPRED_TYPE
     Specify Weighted prediction for P-frames. Deprecated in favor of X264OPTS (see WEIGHTP libx264 option).

x264opts OPTIONS
     Allow to set any x264 option, see x264 --fullhelp for a list.

     OPTIONS is a list of KEY=VALUE couples separated by ":".

For example to specify libx264 encoding options with ffmpeg:

     ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv

For more information about libx264 and the supported options see: http://www.videolan.org/developers/x264.html