ffmpeg - FFmpeg video converter ffmpeg [[infile options][-i infile]]... {[outfile options] outfile}... 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.

Main options
show license show help show available formats, codecs, protocols, ... force format input file name overwrite output files set the recording time in seconds. "hh:mm:ss[.xxx]" syntax is also supported. seek to given time position. "hh:mm:ss[.xxx]" syntax is also supported. set the title set the author set the copyright set the comment 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 activate high quality settings 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
set the video bitrate in kbit/s (default = 200 kb/s) set frame rate (default = 25) set frame size. The format is WxH (default 160x128). The following abbreviations are recognized: 128x96 176x144 352x288 704x576 set aspect ratio (4:3, 16:9 or 1.3333, 1.7777) set top crop band size (in pixels) set bottom crop band size (in pixels) set left crop band size (in pixels) set right crop band size (in pixels) set top pad band size (in pixels) set bottom pad band size (in pixels) set left pad band size (in pixels) set right pad band size (in pixels) 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) disable video recording set video bitrate tolerance (in kbit/s) set max video bitrate tolerance (in kbit/s) set min video bitrate tolerance (in kbit/s) set ratecontrol buffere size (in kbit) force video codec to codec. Use the "copy" special value to tell that the raw codec data must be copied as is. use same video quality as source (implies VBR) 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. select two pass log file name to file.

Advanced Video Options
set the group of picture size use only intra frames use fixed video quantiser scale (VBR) min video quantiser scale (VBR) max video quantiser scale (VBR) max difference between the quantiser scale (VBR) video quantiser scale blur (VBR) video quantiser scale compression (VBR) initial complexity for 1-pass encoding qp factor between p and b frames qp factor between p and i frames qp offset between p and b frames qp offset between p and i frames set rate control equation. Default is "tex^qComp". rate control override for specific intervals set motion estimation method to method. Available methods are (from lower to best quality): Try just the (0, 0) vector. (default method) exhaustive search (slow and marginally better than epzs) set dct algorithm to algo. Available values are: FF_DCT_AUTO (default) FF_DCT_FASTINT FF_DCT_INT FF_DCT_MMX FF_DCT_MLIB FF_DCT_ALTIVEC set idct algorithm to algo. Available values are: FF_IDCT_AUTO (default) FF_IDCT_INT FF_IDCT_SIMPLE FF_IDCT_SIMPLEMMX FF_IDCT_LIBMPEG2MMX FF_IDCT_PS2 FF_IDCT_MLIB FF_IDCT_ARM FF_IDCT_ALTIVEC FF_IDCT_SH4 FF_IDCT_SIMPLEARM set error resilience to n. FF_ER_CAREFULL (default) FF_ER_COMPLIANT FF_ER_AGGRESSIVE FF_ER_VERY_AGGRESSIVE set error concealment to bit_mask. bit_mask is a bit mask of the following values: FF_EC_GUESS_MVS (default=enabled) FF_EC_DEBLOCK (default=enabled) use 'frames' B frames (supported for MPEG-1, MPEG-2 and MPEG-4) macroblock decision FF_MB_DECISION_SIMPLE: use mb_cmp (cannot change it yet in ffmpeg) FF_MB_DECISION_BITS: chooses the one which needs the fewest bits FF_MB_DECISION_RD: rate distoration use four motion vector by macroblock (only MPEG-4) use data partitioning (only MPEG-4) workaround not auto detected encoder bugs how strictly to follow the standarts enable Advanced intra coding (h263+) enable Unlimited Motion Vector (h263+) deinterlace pictures 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. calculate PSNR of compressed frames dump video coding statistics to vstats_HHMMSS.log. insert video processing module. module contains the module name and its parameters separated by spaces.

Audio Options
set the audio sampling freq (default = 44100 Hz) set the audio bitrate in kbit/s (default = 64) set the number of audio channels (default = 1) disable audio recording 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
set video grab device (e.g. /dev/video0) set video grab channel (DV1394 only) set television standard (NTSC, PAL (SECAM)) set DV1394 grab set audio device (e.g. /dev/dsp)

Advanced options
set input stream mapping print specific debug info add timings for benchmarking dump each input packet only use bit exact algorithms (for codec testing) set packet size in bits read input at native frame rate. Mainly used to simulate a grab device. loop over the input stream. Currently it works only for image streams. This option is used for ffserver automatic testing. 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: The following constants are available:

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". ffserver(1), ffplay(1) and the html documentation of ffmpeg. Fabrice Bellard