Template Options

The templates allow you to unlock AVCodec potentials, since all internal options are available for tweaking. Please note that FreeEnc does not give default value for any parameter, so ommiting it from your template will cause avcodec to fail loading, causing a "Could not open AVCodec MPEG2" error. So make sure your template contains valid values for all options.
Also note that most explanation here were taken from Mencoder manpage, since it contains the best explanation for avcodec parameters (much better than FFMPEG manpage itself). But for some reason mencoder changed avcodec parameter names.
So here we go:

gop_size - maximum interval between keyframes in frames. Keyframes are needed for seeking as seeking is only possible to a keyframe but keyframes need more space than other frames so larger numbers here mean slightly smaller files, but less precise seeking


max_qdiff - maximum quantizer difference between I or P frames (pass 1/:2)

max_b_frames - maximum number of B frames to put between I/P frames

qcompress - quantizer compression, depends upon vrc_eq (pass 1/:2)

mb_qmin - minimum macroblock quantizer (pass 1/:2)

mb_qmax - maximum macroblock quantizer (pass 1/:2)

pre_me -motion estimation pre-pass: 0-disabled, 1-only after I frames, 2-always

rc_eq -     main ratecontrol equation (pass 1/:2). Some equations:
    1         constant bitrate
    tex       constant quality
    1+(tex/:avgTex-1)*qComp       approximately the equation of the old ratecontrol code
    tex^qComp        with qcomp 0.5 or something like that (default)

This is the terms that can be used to form the mathematical expression:
    infix operators: +,-,*,/,^
    variables:
    tex        texture complexity
    iTex,pTex      intra, non intra texture complexity
    avgTex         average texture complexity
    avgIITex         average intra texture complexity in I frames
    avgPITex         average intra texture complexity in P frames
    avgPPTex        average non intra texture complexity in P frames
    avgBPTex        average non intra texture complexity in B frames
    mv        Bits used for motion vectors
    fCode         maximum length of motion vector in log2 scale
    iCount        number of intra macro blocks / number of macro blocks
    var        spatial complexity
    mcVar         temporal complexity
    qComp         qcomp from the command line
    isI, isP, isB         is 1 if picture type is I/:P/:B else 0
    Pi,E     see your favorite math book

    functions:
    max(a,b),min(a,b)         maximum / minimum
    gt(a,b)         is 1 if a>b, 0 otherwise
    lt(a,b)         is 1 if a<b, 0 otherwise
    eq(a,b)         is 1 if a==b, 0 otherwise
    sin, cos, tan, sinh, cosh, tanh, exp, log, abs

lmin - Minimum lagrange multiplier for ratecontrol, you probably want it to be equal to or lower than qmin

lmax - Maximum lagrange multiplier for ratecontrol

qmin - minimum quantizer (pass 1/:2)

qmax - maximum quantizer (pass 1/:2) 10-31 should be a sane range

qblur - Quantizer blur, larger values will average the quantizer more over time (slower change).
0.0 qblur disabled
0.5 (default)
1.0 average the quantizer over all previous frames
spatial_cplx_masking -spatial complexity masking. Larger values help against blockiness, if no deblocking filter is used for decoding. 
0.0 disabled (default)
0.0-0.5  sane range
strict_std_compliance - strict standard compliance. Since FreeEnc does not allow Huffyuv or MPEG4 output, this should be zero always.
<>0 disabled (default)
1 only recommended if you want to feed the output into the mpeg4 reference decoder
-1  allows non-standard YV12 huffyuv encoding (20% smaller files, but cannot be played by the official huffyuv codec
me_pre_cmp - comparison function for motion estimation pre pass

rc_qsquish - specify how to keep the quantizer between qmin and qmax (pass 1/:2):
  0- use clipping
  1 - use a nice differentiable function (default)

rc_buffer_aggressivity - currently useless

bit_rate_tolerance - approximated filesize tolerance in kBit. 1000-100000 is a sane range. (warning: 1kBit = 1000 Bits)

mb_decision - Macroblock decision algorithm (high quality mode), encode each macro block in all modes and choose the best. This is slow but results in better quality and file size.

    0         use mbcmp (default)
    1         select the MB mode which needs the fewest bits (=vhq)
    2         select the MB mode which has the best rate distortion


b_quant_factor - quantizer factor between B and non B frames (pass 1/:2)

b_quant_offset - quantizer offset between B and non B frames (pass 1/:2)

i_quant_factor - quantizer factor between I and non I frames(pass 1/:2)

i_quant_offset - quantizer offset between I and non I frames(pass 1/:2)
if v{b|i}_qfactor > 0
I/:B-Frame quantizer = P-Frame quantizer * v{b|i}_qfactor + v{b|i}_qoffset
else do normal ratecontrol (dont lock to next P frame quantizer) and set q= -q * v{b|i}_qfactor + v{b|i}_qoffset
  Tip: To do constant quantizer encoding with different quantizers for I/P and B frames you can use: lmin= <ip_quant>:lmax= <ip_quant>:vb_qfactor= <b_quant/ip_quant>
rc_strategy - Dummy, reserved for future use.

b_frame_strategy - strategy to choose between I/:P/:B frames (pass 2):
0 always use the maximum number of B frames (default)
1 avoid B frames in high motion scenes (will cause bitrate misprediction)
luma_elim_threshold - single coefficient elimination threshold for luminance. Negative values will also consider the dc coefficient (should be at least -4 or lower for encoding at quant=1):
0 disabled (default)
-4         (JVT recommendation)

chroma_elim_threshold - single coefficient elimination threshold for chrominance. Negative values will also consider the dc coefficient (should be at least -4 or lower for encoding at quant=1):
  • 0 disabled (default)
    7 (JVT recommendation)

  • rc_qmod_amp - experimental quantizer modulation

    rc_qmod_freq  - experimental quantizer modulation

    dct_algo -dct algorithm:
    0 automatically select a good one (default)
    1 fast integer
    2 accurate integer
    3 mmx
    4 mlib
    5 altivec
    6 floating point AAN
    lumi_masking - luminance masking. Warning: Be careful, too large values can cause disastrous things. Warning2: Large values might look good on some monitors but may look horrible on other monitors:

            0.0             disabled (default)
            0.0-0.3  sane range

    dark_masking -darkness masking. Warning: be careful, too large values can cause disasterous things. Warning2: large values might look good on some monitors but may look horrible on other monitors / TV / TFT:
    0.0 disabled (default)
    0.0-0.3 sane range
    temporal_cplx_masking - temporal complexity masking
    naq - Normalize adaptive quantization (experimental). When using adaptive quantization (*_mask), the average per-MB quantizer may no longer match the requested frame-level quantizer. Naq will attempt to adjust the per-MB quantizers to maintain the proper average.

    prediction_method - not used in FreeEnc

    me_cmp - comparison function for full pel motion estimation

    pre_dia_size  - <-99-6> Diamond type and size for motion estimation pre pass


    dia_size - <-99-6> - Diamond type & size for motion estimation. NOTE: The sizes of the normal diamonds and shape adaptive ones don't have the same meaning.
    -3 shape adaptive (fast) diamond with size 3
    -2 shape adaptive (fast) diamond with size 2
    -1 experimental
    normal size=1 diamond (default) =EPZS type diamond

          0 
    000
    0

    normal size=2 diamond
          0  
    000
    00000
    000
    0
    trell -Trellis searched quantization. This will find the optimal encoding for each 8x8 block. Trellis searched quantization is quite simple a optimal quantization in the PSNR vs bitrate sense (assuming that there would be no rounding errors introduced by the IDCT, which is obviously not the case) it simply finds a block for the minimum of error and lambda*bits.
    lambda - qp dependant constant
    bits - amount of bits needed to encode the block
    error - sum of squared errors of the quantization
    me_range - motion estimation search range, 0 (default) means unlimited

    intra_quant_bias - intra quantizer bias (256 == 1.0) mpeg style quantizer default: 96

    inter_quant_bias - inter quantizer bias (256 == 1.0)
    mpeg style quantizer default: 0
    Tip: a more positive bias (-32 - -16 instead of -64) seems to improve the PSNR
    context_model - not used

    cbp  - Rate distorted optimal coded block pattern will select the coded block pattern which minimizes distortion + lambda*rate this can only be used together with trellis quantization

    mv0 - Try to encode each MB with MV=<0,0> and choose the better one this has no effect if mbd=0

    inter_threshold - Does absolutely nothing at the moment.

    scenechange_threshold - Threshold for scene change detection. Libavcodec inserts a keyframe when it detects a scene change. You can specify the sensitivity of the detection with this option. -1000000 means there is a scene change detected at every frame, 1000000 means no scene changes are detected.

    intra_matrix - Use custom intra matrix. It needs a comma separated string of 64 integers.

    inter_matrix - Use custom inter matrix. It needs a comma separated string of 64 integers.

    vbv - Sets VBV buffer size

    mpeg_quant - use MPEG quantizers instead of H.263.

    idct_algo - idct algorithm. NOTE: To the best of our knowledge all these IDCTs do pass the IEEE1180 tests.

            0             automatically select a good one (default)
            1            jpeg reference integer
            2            simple
            3            simplemmx
            4            libmpeg2mmx (inaccurate, DON'T USE for encoding with keyint >100)
            5            ps2
            6            mlib
            7            arm
            8            altivec
            9            sh4

    dct_algo -     dct algorithm:

            0             automatically select a good one (default)
            1            fast integer
            2            accurate integer
            3            mmx
            4            mlib
            5            altivec
            6            floating point AAN

    p_masking - inter MB masking

    me_method - motion estimation method. NOTE: 0-3 currently ignores the amount of Bits spent, so quality may be low. Available methods are:

        0        none (very low quality)
        1        full (slow)
        2        log (low quality)
        3        phods (low quality)
        4        EPZS (default)
        5        X1 (experimental)

    rc_override_count - User specified quality for specific parts (ending, credits, ..) (pass 1/:2). The options are <start-frame>, <end-frame>, <quality>[/:<start-frame>, <end-frame>, <quality>[/...]]:

        quality (2-31)         quantizer
        quality (-500-0)      quality correction in %

    mb_cmp -    comparison function for the macroblock decision, only used if mbd=0
            0 (SAD)           sum of absolute differences, fast (default)
            1 (SSE)            sum of squared errors
            2 (SATD)          sum of absolute hadamard transformed differences
            3 (DCT)            sum of absolute dct transformed differences
            4 (PSNR)           sum of the squared quantization errors (don't use, low quality)
            5 (BIT)            number of bits needed for the block
            6 (RD)            rate distortion optimal, slow
            7 (ZERO)            0
            8 (VSAD)             sum of absolute vertical differences
            9 (VSSE)            sum of squared vertical differences
            +256            use chroma too, doesn't work (correctly) with B frames currently

    me_sub_cmp - comparison function for full pel motion estimation

    mb_decision -     comparison function for the macroblock decision, only used if mbd=0

            0 (SAD)             sum of absolute differences, fast (default)
            1 (SSE)            sum of squared errors
            2 (SATD)            sum of absolute hadamard transformed differences
            3 (DCT)            sum of absolute dct transformed differences
            4 (PSNR)            sum of the squared quantization errors (don't use, low quality)
            5 (BIT)            number of bits needed for the block
            6 (RD)            rate distortion optimal, slow
            7 (ZERO)            0
            8 (VSAD)            sum of absolute vertical differences
            9 (VSSE)            sum of squared vertical differences
            +256            use chroma too, doesn't work (correctly)  with B frames currently

    me_subpel_quality - subpel refinement quality (for qpel) (default: 8). NOTE: This has a significant effect on speed.

    top_field_first - Used for interlaced encodings. Use TFF  for most DVDs and captures, BFF for DV captures.