FFMPEG(1)

NAME
ffmpeg - FFmpeg video converter

SYNOPSIS
ffmpeg [[infile options][-i infile]]... {[outfile options] outfile}...

DESCRIPTION
If no input file is given, audio/video grabbing is done.

As a general rule, options are applied to the next specified file. For example, if you give the -b 64 option, it sets the video bitrate of the next file. Format option may be needed for raw input files.

By default, ffmpeg tries to convert as losslessly as possible: it uses the same audio and video parameter for the outputs as the one specified for the inputs.

OPTIONS

  Main options

-L  show license

-h  show help

-formats
    show available formats, codecs, protocols, ...

-f fmt
    force format

-i filename
    input file name

-y  overwrite output files

-t duration
    set the recording time in seconds. "hh:mm:ss[.xxx]" syntax is also supported.

-ss position
    seek to given time position. "hh:mm:ss[.xxx]" syntax is also supported.

-title string
    set the title

-author string
    set the author

-copyright string
    set the copyright

-comment string
    set the comment

-target type
    specify target file type ("vcd", "svcd", "dvd", "dv", "pal-vcd", "ntsc-svcd", ... ). All the format options (bitrate, codecs, buffer sizes) are automatically set by this option. You can just type:

            ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg

    Nevertheless you can specify additional options as long as you know they do not compromise the standard, as in:

            ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg

-hq activate high quality settings

-itsoffset offset
    set the input time offset in seconds. "[-]hh:mm:ss[.xxx]" syntax is also supported. This option affects all the input files that follow it. The offset is added to the input files' timestamps; specifying a positive offset means that the corresponding streams are delayed by 'offset' seconds.

  Video Options

-b bitrate
    set the video bitrate in kbit/s (default = 200 kb/s)

-r fps
    set frame rate (default = 25)

-s size
    set frame size. The format is WxH (default 160x128). The following abbreviations are recognized:

    sqcif
        128x96

    qcif
        176x144

    cif 352x288

    4cif
        704x576

-aspect aspect
    set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)

-croptop size
    set top crop band size (in pixels)

-cropbottom size
    set bottom crop band size (in pixels)

-cropleft size
    set left crop band size (in pixels)

-cropright size
    set right crop band size (in pixels)

-padtop size
    set top pad band size (in pixels)

-padbottom size
    set bottom pad band size (in pixels)

-padleft size
    set left pad band size (in pixels)

-padright size
    set right pad band size (in pixels)

-padcolor (hex color)
    set color of padded bands. The value for pad color is expressed as a six digit hexidecimal number where the first two digits represent red, middle two digits green and last two digits blue. Defaults to 000000 (black)

-vn disable video recording

-bt tolerance
    set video bitrate tolerance (in kbit/s)

-maxrate bitrate
    set max video bitrate tolerance (in kbit/s)

-minrate bitrate
    set min video bitrate tolerance (in kbit/s)

-bufsize size
    set ratecontrol buffere size (in kbit)

-vcodec codec
    force video codec to codec. Use the "copy" special value to tell that the raw codec data must be copied as is.

-sameq
    use same video quality as source (implies VBR)

-pass n
    select the pass number (1 or 2). It is useful to do two pass encoding. The statistics of the video are recorded in the first pass and the video at the exact requested bit rate is generated in the second pass.

-passlogfile file
    select two pass log file name to file.

  Advanced Video Options

-g gop_size
    set the group of picture size

-intra
    use only intra frames

-qscale q
    use fixed video quantiser scale (VBR)

-qmin q
    min video quantiser scale (VBR)

-qmax q
    max video quantiser scale (VBR)

-qdiff q
    max difference between the quantiser scale (VBR)

-qblur blur
    video quantiser scale blur (VBR)

-qcomp compression
    video quantiser scale compression (VBR)

-rc_init_cplx complexity
    initial complexity for 1-pass encoding

-b_qfactor factor
    qp factor between p and b frames

-i_qfactor factor
    qp factor between p and i frames

-b_qoffset offset
    qp offset between p and b frames

-i_qoffset offset
    qp offset between p and i frames

-rc_eq equation
    set rate control equation. Default is "tex^qComp".

-rc_override override
    rate control override for specific intervals

-me method
    set motion estimation method to method. Available methods are (from lower to best quality):

    zero
        Try just the (0, 0) vector.

    phods
    log
    x1
    epzs
        (default method)

    full
        exhaustive search (slow and marginally better than epzs)

-dct_algo algo
    set dct algorithm to algo. Available values are:

    0   FF_DCT_AUTO (default)

    1   FF_DCT_FASTINT

    2   FF_DCT_INT

    3   FF_DCT_MMX

    4   FF_DCT_MLIB

    5   FF_DCT_ALTIVEC

-idct_algo algo
    set idct algorithm to algo. Available values are:

    0   FF_IDCT_AUTO (default)

    1   FF_IDCT_INT

    2   FF_IDCT_SIMPLE

    3   FF_IDCT_SIMPLEMMX

    4   FF_IDCT_LIBMPEG2MMX

    5   FF_IDCT_PS2

    6   FF_IDCT_MLIB

    7   FF_IDCT_ARM

    8   FF_IDCT_ALTIVEC

    9   FF_IDCT_SH4

    10  FF_IDCT_SIMPLEARM

-er n
    set error resilience to n.

    1   FF_ER_CAREFULL (default)

    2   FF_ER_COMPLIANT

    3   FF_ER_AGGRESSIVE

    4   FF_ER_VERY_AGGRESSIVE

-ec bit_mask
    set error concealment to bit_mask. bit_mask is a bit mask of the following values:

    1   FF_EC_GUESS_MVS (default=enabled)

    2   FF_EC_DEBLOCK (default=enabled)

-bf frames
    use 'frames' B frames (supported for MPEG-1, MPEG-2 and MPEG-4)

-mbd mode
    macroblock decision

    0   FF_MB_DECISION_SIMPLE: use mb_cmp (cannot change it yet in ffmpeg)

    1   FF_MB_DECISION_BITS: chooses the one which needs the fewest bits

    2   FF_MB_DECISION_RD: rate distoration

-4mv
    use four motion vector by macroblock (only MPEG-4)

-part
    use data partitioning (only MPEG-4)

-bug param
    workaround not auto detected encoder bugs

-strict strictness
    how strictly to follow the standarts

-aic
    enable Advanced intra coding (h263+)

-umv
    enable Unlimited Motion Vector (h263+)

-deinterlace
    deinterlace pictures

-interlace
    force interlacing support in encoder (only MPEG-2 and MPEG-4). Use this option if your input file is interlaced and if you want to keep the interlaced format for minimum losses. The alternative is to deinterlace the input stream with -deinterlace, but deinterlacing introduces more losses.

-psnr
    calculate PSNR of compressed frames

-vstats
    dump video coding statistics to vstats_HHMMSS.log.

-vhook module
    insert video processing module. module contains the module name and its parameters separated by spaces.

  Audio Options

-ar freq
    set the audio sampling freq (default = 44100 Hz)

-ab bitrate
    set the audio bitrate in kbit/s (default = 64)

-ac channels
    set the number of audio channels (default = 1)

-an disable audio recording

-acodec codec
    force audio codec to codec. Use the "copy" special value to tell that the raw codec data must be copied as is.

  Audio/Video grab options

-vd device
    set video grab device (e.g. /dev/video0)

-vc channel
    set video grab channel (DV1394 only)

-tvstd standard
    set television standard (NTSC, PAL (SECAM))

-dv1394
    set DV1394 grab

-ad device
    set audio device (e.g. /dev/dsp)

  Advanced options

-map file:stream
    set input stream mapping

-debug
    print specific debug info

-benchmark
    add timings for benchmarking

-hex
    dump each input packet

-bitexact
    only use bit exact algorithms (for codec testing)

-ps size
    set packet size in bits

-re read input at native frame rate. Mainly used to simulate a grab device.

-loop
    loop over the input stream. Currently it works only for image streams. This option is used for ffserver automatic testing.

-loop_output number_of_times
    Repeatedly loop output for formats that support looping such as animated gif (Zero will loop the output infinitely)

  FFmpeg formula evaluator
When evaluating a rate control string, FFmpeg uses an internal formula evaluator.

The following binary operators are available: "+", "-", "*", "/", "^".

The following unary operators are available: "+", "-", "(...)".

The following functions are available:

sinh(x)
cosh(x)
tanh(x)
sin(x)
cos(x)
tan(x)
exp(x)
log(x)
squish(x)
gauss(x)
abs(x)
max(x, y)
min(x, y)
gt(x, y)
lt(x, y)
eq(x, y)
bits2qp(bits)
qp2bits(qp)

The following constants are available:

PI
E
iTex
pTex
tex
mv
fCode
iCount
mcVar
var
isI
isP
isB
avgQP
qComp
avgIITex
avgPITex
avgPPTex
avgBPTex
avgTex

EXAMPLES

  Video and Audio grabbing
FFmpeg can use a video4linux compatible video source and any Open Sound System audio source:

        ffmpeg /tmp/out.mpg

Note that you must activate the right video source and channel before launching ffmpeg. You can use any TV viewer such as xawtv (<http://bytesex.org/xawtv/>) by Gerd Knorr which I find very good. You must also set correctly the audio recording levels with a standard mixer.

  Video and Audio file format conversion
* ffmpeg can use any supported file format and protocol as input:

Examples:

* You can input from YUV files:

        ffmpeg -i /tmp/test%d.Y /tmp/out.mpg

It will use the files:

        /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
        /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...

The Y files use twice the resolution of the U and V files. They are raw files, without header. They can be generated by all decent video decoders. You must specify the size of the image with the -s option if ffmpeg cannot guess it.

* You can input from a RAW YUV420P file:

        ffmpeg -i /tmp/test.yuv /tmp/out.avi

The RAW YUV420P is a file containing RAW YUV planar, for each frame first come the Y plane followed by U and V planes, which are half vertical and horizontal resolution.

* You can output to a RAW YUV420P file:

        ffmpeg -i mydivx.avi -o hugefile.yuv

* You can set several input files and output files:

        ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg

Convert the audio file a.wav and the raw yuv video file a.yuv to mpeg file a.mpg

* You can also do audio and video conversions at the same time:

        ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2

Convert the sample rate of a.wav to 22050 Hz and encode it to MPEG audio.

* You can encode to several formats at the same time and define a mapping from input stream to output streams:

        ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0

Convert a.wav to a.mp2 at 64 kbits and b.mp2 at 128 kbits. '-map file:index' specify which input stream is used for each output stream, in the order of the definition of output streams.

* You can transcode decrypted VOBs

        ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi

This is a typical DVD ripper example, input from a VOB file, output to an AVI file with MPEG-4 video and MP3 audio, note that in this command we use B frames so the MPEG-4 stream is DivX5 compatible, GOP size is 300 that means an INTRA frame every 10 seconds for 29.97 fps input video. Also the audio stream is MP3 encoded so you need LAME support which is enabled using "--enable-mp3lame" when configuring. The mapping is particularly useful for DVD transcoding to get the desired audio language.

NOTE: to see the supported input formats, use "ffmpeg -formats".

SEE ALSO
ffserver(1), ffplay(1) and the html documentation of ffmpeg.

AUTHOR
Fabrice Bellard