Codec Options
*************

libavcodec provides some generic global options, which can be set on all the encoders and decoders. In addition each codec may support so-called private options, which are specific for a given codec.

Sometimes, a global option may only affect a specific kind of codec, and may be nonsensical or ignored by another, so you need to be aware of the meaning of the specified options. Also some options are meant only for decoding or encoding.

Options may be set by specifying -OPTION VALUE in the FFmpeg tools, or by setting the value explicitly in the AVCodecContext options or using the libavutil/opt.h API for programmatic use.

The list of supported options follow:

b INTEGER (encoding,audio,video)
     Set bitrate in bits/s. Default value is 200K.

ab INTEGER (encoding,audio)
     Set audio bitrate (in bits/s). Default value is 128K.

bt INTEGER (encoding,video)
     Set video bitrate tolerance (in bits/s). In 1-pass mode, bitrate tolerance specifies how far ratecontrol is willing to deviate from the target average bitrate value. This is not related to min/max bitrate. Lowering tolerance too much has an adverse effect on quality.

flags FLAGS (decoding/encoding,audio,video,subtitles)
     Set generic flags.

     Possible values:

     mv4
          Use four motion vector by macroblock (mpeg4).

     qpel
          Use 1/4 pel motion compensation.

     loop
          Use loop filter.

     qscale
          Use fixed qscale.

     pass1
          Use internal 2pass ratecontrol in first pass mode.

     pass2
          Use internal 2pass ratecontrol in second pass mode.

     gray
          Only decode/encode grayscale.

     psnr
          Set error[?] variables during encoding.

     truncated
          Input bitstream might be randomly truncated.

     drop_changed
          Don't output frames whose parameters differ from first decoded frame in stream. Error AVERROR_INPUT_CHANGED is returned when a frame is dropped.

     ildct
          Use interlaced DCT.

     low_delay
          Force low delay.

     global_header
          Place global headers in extradata instead of every keyframe.

     bitexact
          Only write platform-, build- and time-independent data. (except (I)DCT). This ensures that file and data checksums are reproducible and match between platforms. Its primary use is for regression testing.

     aic
          Apply H263 advanced intra coding / mpeg4 ac prediction.

     ilme
          Apply interlaced motion estimation.

     cgop
          Use closed gop.

     output_corrupt
          Output even potentially corrupted frames.

time_base RATIONAL NUMBER
     Set codec time base.

     It is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented. For fixed-fps content, timebase should be 1 / frame_rate and timestamp increments should be identically 1.

g INTEGER (encoding,video)
     Set the group of picture (GOP) size. Default value is 12.

ar INTEGER (decoding/encoding,audio)
     Set audio sampling rate (in Hz).

ac INTEGER (decoding/encoding,audio)
     Set number of audio channels.

cutoff INTEGER (encoding,audio)
     Set cutoff bandwidth. (Supported only by selected encoders, see their respective documentation sections.)

frame_size INTEGER (encoding,audio)
     Set audio frame size.

     Each submitted frame except the last must contain exactly frame_size samples per channel. May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, in that case the frame size is not restricted. It is set by some decoders to indicate constant frame size.

frame_number INTEGER
     Set the frame number.

delay INTEGER

qcomp FLOAT (encoding,video)
     Set video quantizer scale compression (VBR). It is used as a constant in the ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0.

qblur FLOAT (encoding,video)
     Set video quantizer scale blur (VBR).

qmin INTEGER (encoding,video)
     Set min video quantizer scale (VBR). Must be included between -1 and 69, default value is 2.

qmax INTEGER (encoding,video)
     Set max video quantizer scale (VBR). Must be included between -1 and 1024, default value is 31.

qdiff INTEGER (encoding,video)
     Set max difference between the quantizer scale (VBR).

bf INTEGER (encoding,video)
     Set max number of B frames between non-B-frames.

     Must be an integer between -1 and 16. 0 means that B-frames are disabled. If a value of -1 is used, it will choose an automatic value depending on the encoder.

     Default value is 0.

b_qfactor FLOAT (encoding,video)
     Set qp factor between P and B frames.

codec_tag INTEGER

bug FLAGS (decoding,video)
     Workaround not auto detected encoder bugs.

     Possible values:

     autodetect

     xvid_ilace
          Xvid interlacing bug (autodetected if fourcc==XVIX)

     ump4
          (autodetected if fourcc==UMP4)

     no_padding
          padding bug (autodetected)

     amv

     qpel_chroma

     std_qpel
          old standard qpel (autodetected per fourcc/version)

     qpel_chroma2

     direct_blocksize
          direct-qpel-blocksize bug (autodetected per fourcc/version)

     edge
          edge padding bug (autodetected per fourcc/version)

     hpel_chroma

     dc_clip

     ms
          Workaround various bugs in microsoft broken decoders.

     trunc
          trancated frames

strict INTEGER (decoding/encoding,audio,video)
     Specify how strictly to follow the standards.

     Possible values:

     very
          strictly conform to an older more strict version of the spec or reference software

     strict
          strictly conform to all the things in the spec no matter what consequences

     normal

     unofficial
          allow unofficial extensions

     experimental
          allow non standardized experimental things, experimental (unfinished/work in progress/not well tested) decoders and encoders. Note: experimental decoders can pose a security risk, do not use this for decoding untrusted input.

b_qoffset FLOAT (encoding,video)
     Set QP offset between P and B frames.

err_detect FLAGS (decoding,audio,video)
     Set error detection flags.

     Possible values:

     crccheck
          verify embedded CRCs

     bitstream
          detect bitstream specification deviations

     buffer
          detect improper bitstream length

     explode
          abort decoding on minor error detection

     ignore_err
          ignore decoding errors, and continue decoding. This is useful if you want to analyze the content of a video and thus want everything to be decoded no matter what. This option will not result in a video that is pleasing to watch in case of errors.

     careful
          consider things that violate the spec and have not been seen in the wild as errors

     compliant
          consider all spec non compliancies as errors

     aggressive
          consider things that a sane encoder should not do as an error

has_b_frames INTEGER

block_align INTEGER

rc_override_count INTEGER

maxrate INTEGER (encoding,audio,video)
     Set max bitrate tolerance (in bits/s). Requires bufsize to be set.

minrate INTEGER (encoding,audio,video)
     Set min bitrate tolerance (in bits/s). Most useful in setting up a CBR encode. It is of little use elsewise.

bufsize INTEGER (encoding,audio,video)
     Set ratecontrol buffer size (in bits).

i_qfactor FLOAT (encoding,video)
     Set QP factor between P and I frames.

i_qoffset FLOAT (encoding,video)
     Set QP offset between P and I frames.

dct INTEGER (encoding,video)
     Set DCT algorithm.

     Possible values:

     auto
          autoselect a good one (default)

     fastint
          fast integer

     int
          accurate integer

     mmx

     altivec

     faan
          floating point AAN DCT

lumi_mask FLOAT (encoding,video)
     Compress bright areas stronger than medium ones.

tcplx_mask FLOAT (encoding,video)
     Set temporal complexity masking.

scplx_mask FLOAT (encoding,video)
     Set spatial complexity masking.

p_mask FLOAT (encoding,video)
     Set inter masking.

dark_mask FLOAT (encoding,video)
     Compress dark areas stronger than medium ones.

idct INTEGER (decoding/encoding,video)
     Select IDCT implementation.

     Possible values:

     auto

     int

     simple

     simplemmx

     simpleauto
          Automatically pick a IDCT compatible with the simple one

     arm

     altivec

     sh4

     simplearm

     simplearmv5te

     simplearmv6

     simpleneon

     xvid

     faani
          floating point AAN IDCT

slice_count INTEGER

ec FLAGS (decoding,video)
     Set error concealment strategy.

     Possible values:

     guess_mvs
          iterative motion vector (MV) search (slow)

     deblock
          use strong deblock filter for damaged MBs

     favor_inter
          favor predicting from the previous frame instead of the current

bits_per_coded_sample INTEGER

aspect RATIONAL NUMBER (encoding,video)
     Set sample aspect ratio.

sar RATIONAL NUMBER (encoding,video)
     Set sample aspect ratio. Alias to ASPECT.

debug FLAGS (decoding/encoding,audio,video,subtitles)
     Print specific debug info.

     Possible values:

     pict
          picture info

     rc
          rate control

     bitstream

     mb_type
          macroblock (MB) type

     qp
          per-block quantization parameter (QP)

     dct_coeff

     green_metadata
          display complexity metadata for the upcoming frame, GoP or for a given duration.

     skip

     startcode

     er
          error recognition

     mmco
          memory management control operations (H.264)

     bugs

     buffers
          picture buffer allocations

     thread_ops
          threading operations

     nomc
          skip motion compensation

cmp INTEGER (encoding,video)
     Set full pel me compare function.

     Possible values:

     sad
          sum of absolute differences, fast (default)

     sse
          sum of squared errors

     satd
          sum of absolute Hadamard transformed differences

     dct
          sum of absolute DCT transformed differences

     psnr
          sum of squared quantization errors (avoid, low quality)

     bit
          number of bits needed for the block

     rd
          rate distortion optimal, slow

     zero
          0

     vsad
          sum of absolute vertical differences

     vsse
          sum of squared vertical differences

     nsse
          noise preserving sum of squared differences

     w53
          5/3 wavelet, only used in snow

     w97
          9/7 wavelet, only used in snow

     dctmax

     chroma

subcmp INTEGER (encoding,video)
     Set sub pel me compare function.

     Possible values:

     sad
          sum of absolute differences, fast (default)

     sse
          sum of squared errors

     satd
          sum of absolute Hadamard transformed differences

     dct
          sum of absolute DCT transformed differences

     psnr
          sum of squared quantization errors (avoid, low quality)

     bit
          number of bits needed for the block

     rd
          rate distortion optimal, slow

     zero
          0

     vsad
          sum of absolute vertical differences

     vsse
          sum of squared vertical differences

     nsse
          noise preserving sum of squared differences

     w53
          5/3 wavelet, only used in snow

     w97
          9/7 wavelet, only used in snow

     dctmax

     chroma

mbcmp INTEGER (encoding,video)
     Set macroblock compare function.

     Possible values:

     sad
          sum of absolute differences, fast (default)

     sse
          sum of squared errors

     satd
          sum of absolute Hadamard transformed differences

     dct
          sum of absolute DCT transformed differences

     psnr
          sum of squared quantization errors (avoid, low quality)

     bit
          number of bits needed for the block

     rd
          rate distortion optimal, slow

     zero
          0

     vsad
          sum of absolute vertical differences

     vsse
          sum of squared vertical differences

     nsse
          noise preserving sum of squared differences

     w53
          5/3 wavelet, only used in snow

     w97
          9/7 wavelet, only used in snow

     dctmax

     chroma

ildctcmp INTEGER (encoding,video)
     Set interlaced dct compare function.

     Possible values:

     sad
          sum of absolute differences, fast (default)

     sse
          sum of squared errors

     satd
          sum of absolute Hadamard transformed differences

     dct
          sum of absolute DCT transformed differences

     psnr
          sum of squared quantization errors (avoid, low quality)

     bit
          number of bits needed for the block

     rd
          rate distortion optimal, slow

     zero
          0

     vsad
          sum of absolute vertical differences

     vsse
          sum of squared vertical differences

     nsse
          noise preserving sum of squared differences

     w53
          5/3 wavelet, only used in snow

     w97
          9/7 wavelet, only used in snow

     dctmax

     chroma

dia_size INTEGER (encoding,video)
     Set diamond type & size for motion estimation.

     (1024, INT_MAX)
          full motion estimation(slowest)

     (768, 1024]
          umh motion estimation

     (512, 768]
          hex motion estimation

     (256, 512]
          l2s diamond motion estimation

     [2,256]
          var diamond motion estimation

     (-1,  2)
          small diamond motion estimation

     -1
          funny diamond motion estimation

     (INT_MIN, -1)
          sab diamond motion estimation

last_pred INTEGER (encoding,video)
     Set amount of motion predictors from the previous frame.

precmp INTEGER (encoding,video)
     Set pre motion estimation compare function.

     Possible values:

     sad
          sum of absolute differences, fast (default)

     sse
          sum of squared errors

     satd
          sum of absolute Hadamard transformed differences

     dct
          sum of absolute DCT transformed differences

     psnr
          sum of squared quantization errors (avoid, low quality)

     bit
          number of bits needed for the block

     rd
          rate distortion optimal, slow

     zero
          0

     vsad
          sum of absolute vertical differences

     vsse
          sum of squared vertical differences

     nsse
          noise preserving sum of squared differences

     w53
          5/3 wavelet, only used in snow

     w97
          9/7 wavelet, only used in snow

     dctmax

     chroma

pre_dia_size INTEGER (encoding,video)
     Set diamond type & size for motion estimation pre-pass.

subq INTEGER (encoding,video)
     Set sub pel motion estimation quality.

me_range INTEGER (encoding,video)
     Set limit motion vectors range (1023 for DivX player).

global_quality INTEGER (encoding,audio,video)

slice_flags INTEGER

mbd INTEGER (encoding,video)
     Set macroblock decision algorithm (high quality mode).

     Possible values:

     simple
          use mbcmp (default)

     bits
          use fewest bits

     rd
          use best rate distortion

rc_init_occupancy INTEGER (encoding,video)
     Set number of bits which should be loaded into the rc buffer before decoding starts.

flags2 FLAGS (decoding/encoding,audio,video,subtitles)

     Possible values:

     fast
          Allow non spec compliant speedup tricks.

     noout
          Skip bitstream encoding.

     ignorecrop
          Ignore cropping information from sps.

     local_header
          Place global headers at every keyframe instead of in extradata.

     chunks
          Frame data might be split into multiple chunks.

     showall
          Show all frames before the first keyframe.

     export_mvs
          Export motion vectors into frame side-data (see AV_FRAME_DATA_MOTION_VECTORS) for codecs that support it. See also doc/examples/export_mvs.c.

     skip_manual
          Do not skip samples and export skip information as frame side data.

     ass_ro_flush_noop
          Do not reset ASS ReadOrder field on flush.

export_side_data FLAGS (decoding/encoding,audio,video,subtitles)

     Possible values:

     mvs
          Export motion vectors into frame side-data (see AV_FRAME_DATA_MOTION_VECTORS) for codecs that support it. See also doc/examples/export_mvs.c.

     prft
          Export encoder Producer Reference Time into packet side-data (see AV_PKT_DATA_PRFT) for codecs that support it.

     venc_params
          Export video encoding parameters through frame side data (see AV_FRAME_DATA_VIDEO_ENC_PARAMS) for codecs that support it. At present, those are H.264 and VP9.

     film_grain
          Export film grain parameters through frame side data (see AV_FRAME_DATA_FILM_GRAIN_PARAMS). Supported at present by AV1 decoders.

threads INTEGER (decoding/encoding,video)
     Set the number of threads to be used, in case the selected codec implementation supports multi-threading.

     Possible values:

     auto, 0
          automatically select the number of threads to set

     Default value is auto.

dc INTEGER (encoding,video)
     Set intra_dc_precision.

nssew INTEGER (encoding,video)
     Set nsse weight.

skip_top INTEGER (decoding,video)
     Set number of macroblock rows at the top which are skipped.

skip_bottom INTEGER (decoding,video)
     Set number of macroblock rows at the bottom which are skipped.

profile INTEGER (encoding,audio,video)

     Set encoder codec profile. Default value is unknown. Encoder specific profiles are documented in the relevant encoder documentation.

level INTEGER (encoding,audio,video)

     Possible values:

     unknown

lowres INTEGER (decoding,audio,video)
     Decode at 1= 1/2, 2=1/4, 3=1/8 resolutions.

mblmin INTEGER (encoding,video)
     Set min macroblock lagrange factor (VBR).

mblmax INTEGER (encoding,video)
     Set max macroblock lagrange factor (VBR).

skip_loop_filter INTEGER (decoding,video)

skip_idct        INTEGER (decoding,video)

skip_frame       INTEGER (decoding,video)

     Make decoder discard processing depending on the frame type selected by the option value.

     skip_loop_filter skips frame loop filtering, skip_idct skips frame IDCT/dequantization, skip_frame skips decoding.

     Possible values:

     none
          Discard no frame.

     default
          Discard useless frames like 0-sized frames.

     noref
          Discard all non-reference frames.

     bidir
          Discard all bidirectional frames.

     nokey
          Discard all frames excepts keyframes.

     nointra
          Discard all frames except I frames.

     all
          Discard all frames.

     Default value is default.

bidir_refine INTEGER (encoding,video)
     Refine the two motion vectors used in bidirectional macroblocks.

keyint_min INTEGER (encoding,video)
     Set minimum interval between IDR-frames.

refs INTEGER (encoding,video)
     Set reference frames to consider for motion compensation.

trellis INTEGER (encoding,audio,video)
     Set rate-distortion optimal quantization.

mv0_threshold INTEGER (encoding,video)

compression_level INTEGER (encoding,audio,video)

bits_per_raw_sample INTEGER

channel_layout INTEGER (decoding/encoding,audio)

     Possible values:

request_channel_layout INTEGER (decoding,audio)

     Possible values:

rc_max_vbv_use FLOAT (encoding,video)

rc_min_vbv_use FLOAT (encoding,video)

ticks_per_frame INTEGER (decoding/encoding,audio,video)

color_primaries INTEGER (decoding/encoding,video)
     Possible values:

     bt709
          BT.709

     bt470m
          BT.470 M

     bt470bg
          BT.470 BG

     smpte170m
          SMPTE 170 M

     smpte240m
          SMPTE 240 M

     film
          Film

     bt2020
          BT.2020

     smpte428

     smpte428_1
          SMPTE ST 428-1

     smpte431
          SMPTE 431-2

     smpte432
          SMPTE 432-1

     jedec-p22
          JEDEC P22

color_trc INTEGER (decoding/encoding,video)
     Possible values:

     bt709
          BT.709

     gamma22
          BT.470 M

     gamma28
          BT.470 BG

     smpte170m
          SMPTE 170 M

     smpte240m
          SMPTE 240 M

     linear
          Linear

     log

     log100
          Log

     log_sqrt

     log316
          Log square root

     iec61966_2_4

     iec61966-2-4
          IEC 61966-2-4

     bt1361

     bt1361e
          BT.1361

     iec61966_2_1

     iec61966-2-1
          IEC 61966-2-1

     bt2020_10

     bt2020_10bit
          BT.2020 - 10 bit

     bt2020_12

     bt2020_12bit
          BT.2020 - 12 bit

     smpte2084
          SMPTE ST 2084

     smpte428

     smpte428_1
          SMPTE ST 428-1

     arib-std-b67
          ARIB STD-B67

colorspace INTEGER (decoding/encoding,video)
     Possible values:

     rgb
          RGB

     bt709
          BT.709

     fcc
          FCC

     bt470bg
          BT.470 BG

     smpte170m
          SMPTE 170 M

     smpte240m
          SMPTE 240 M

     ycocg
          YCOCG

     bt2020nc

     bt2020_ncl
          BT.2020 NCL

     bt2020c

     bt2020_cl
          BT.2020 CL

     smpte2085
          SMPTE 2085

     chroma-derived-nc
          Chroma-derived NCL

     chroma-derived-c
          Chroma-derived CL

     ictcp
          ICtCp

color_range INTEGER (decoding/encoding,video)
     If used as input parameter, it serves as a hint to the decoder, which color_range the input has. Possible values:

     tv

     mpeg
          MPEG (219*2^(n-8))

     pc

     jpeg
          JPEG (2^n-1)

chroma_sample_location INTEGER (decoding/encoding,video)
     Possible values:

     left

     center

     topleft

     top

     bottomleft

     bottom

log_level_offset INTEGER
     Set the log level offset.

slices INTEGER (encoding,video)
     Number of slices, used in parallelized encoding.

thread_type FLAGS (decoding/encoding,video)
     Select which multithreading methods to use.

     Use of frame will increase decoding delay by one frame per thread, so clients which cannot provide future frames should not use it.

     Possible values:

     slice
          Decode more than one part of a single frame at once.

          Multithreading using slices works only when the video was encoded with slices.

     frame
          Decode more than one frame at once.

     Default value is slice+frame.

audio_service_type INTEGER (encoding,audio)
     Set audio service type.

     Possible values:

     ma
          Main Audio Service

     ef
          Effects

     vi
          Visually Impaired

     hi
          Hearing Impaired

     di
          Dialogue

     co
          Commentary

     em
          Emergency

     vo
          Voice Over

     ka
          Karaoke

request_sample_fmt SAMPLE_FMT (decoding,audio)
     Set sample format audio decoders should prefer. Default value is none.

pkt_timebase RATIONAL NUMBER

sub_charenc ENCODING (decoding,subtitles)
     Set the input subtitles character encoding.

field_order  FIELD_ORDER (video)
     Set/override the field order of the video. Possible values:

     progressive
          Progressive video

     tt
          Interlaced video, top field coded and displayed first

     bb
          Interlaced video, bottom field coded and displayed first

     tb
          Interlaced video, top coded first, bottom displayed first

     bt
          Interlaced video, bottom coded first, top displayed first

skip_alpha BOOL (decoding,video)
     Set to 1 to disable processing alpha (transparency). This works like the gray flag in the flags option which skips chroma information instead of alpha. Default is 0.

codec_whitelist LIST (input)
     "," separated list of allowed decoders. By default all are allowed.

dump_separator STRING (input)
     Separator used to separate the fields printed on the command line about the Stream parameters. For example, to separate the fields with newlines and indentation:

          ffprobe -dump_separator "
                                    "  -i ~/videos/matrixbench_mpeg2.mpg

max_pixels INTEGER (decoding/encoding,video)
     Maximum number of pixels per image. This value can be used to avoid out of memory failures due to large images.

apply_cropping BOOL (decoding,video)
     Enable cropping if cropping parameters are multiples of the required alignment for the left and top parameters. If the alignment is not met the cropping will be partially applied to maintain alignment. Default is 1 (enabled). Note: The required alignment depends on if AV_CODEC_FLAG_UNALIGNED is set and the CPU. AV_CODEC_FLAG_UNALIGNED cannot be changed from the command line. Also hardware decoders will not apply left/top Cropping.

     [file decoders.texi not included]
     [file encoders.texi not included]