ffmpeg Cheat Sheet
by thetartankilt via cheatography.com/853/cs/344/
Main options Help options
Command syntax: ffmpeg [global-options] [[infile-options][-i infile]]... -h Show basic help
{[outfile-options] outfile}... -?
-help
Display input stream ffmpeg -i video.avi
--help
information:
-h long Show more help
Many of the audio/video file formats [such as WAV, AIFF, MP4, MKV, AVI,
etc.] are envelope containers for multiple streams of data content such as -h full Show all options, including all format and codec specific
audio, video, subtitle text, still images, fonts, etc. options
-version Show version
Global options -formats Show available formats
-y Overwrite output files -codecs Show available codecs
-n Do not overwrite output files -protocols Show available protocols
-filters Show available libavfilter filters
Main options
-sample_fmts Show available sample formats
-f fmt force input or output file format
-bsfs Show available bitstream filters
-i fName input file name. If specified with no output file, a
-pix_fmts Show available pixel formats
summary of the content streams is shown
-v value Log output verbosity
-c codecName specify codec [input or output]
-loglevel value value is an integer, or one of: quiet, panic, fatal, error,
-fs Nbytes specify maximum output file size in Nbytes warning, info, verbose, debug
The file extension typically determines the file format, so the '-f' option is
not needed in most cases. Subtitle options
-slang code Set the ISO 639 language code (3 letters) of the current
Size specification subtitle stream.
K or k 103 1000 bytes Kilobytes -scodec Set the subtitle codec. This is an alias for-codec:s. Use
codec 'copy' to copy stream.
M 106 1000000 bytes Megabytes
-sn Disable subtitle recording.
G 109 1000000000 Gigabytes
-newsubtitle add a new subtitle stream to the current output stream
Ki 210 1024 Kibibyte
Mi 220 1048576 Mebibyte
Gi 230 1073741824 Gibibyte
suffices used with most numerical values
By thetartankilt Published 25th April, 2017. Sponsored by CrosswordCheats.com
cheatography.com/thetartankilt/ Last updated 22nd March, 2018. Learn to solve cryptic crosswords!
Page 1 of 3. http://crosswordcheats.com
ffmpeg Cheat Sheet
by thetartankilt via cheatography.com/853/cs/344/
Video options Specialist Video filters (cont)
-b bRate set video bitrate (in kbit/s) -vf draw a box border
-fixaspect fix aspect ratio drawbox=size
Spec:color@opacity colour specification 0xhex and
opacity [0...1]
-bt tolerance set video bitrate tolerance (in kbit/s)
sizeSpec is a list of values, colon x=x:y=y
-maxrate bRate set maximum or minimum video bitrate tolerance (in
separated. position from top left corner
-minrate bRate kbit/s)
w=width:h=height
-bufsize size set ratecontrol buffer size (in kByte) width and height
-sameq use same video quality as source (implies VBR)
Audio Options
-newvideo add a new video stream to the current output stream
-ab bRate set audio bitrate (in kbit/s)
Specialist Video filters
-aframes N Set the number of audio frames to record. [an alias for -
-vf vflip Flip the input video vertically frames:a]
-vf hflip Flip the input video horizontally -aq q Set the audio quality (codec-specific, VBR). [an alias for
-q:a]
-vf transpose=transSpec Rotates or flips input video
-an Disable audio recording
transSpec is a list of values, dir=N:passthrough=orientation
colon separated. N = 0...7 ; passthrough is one of: none, -acodec codec Set the audio codec. [an alias for -codec:a]
portrait, landscape Use 'copy' to copy stream.
-vf delogo=sizeSpec:t=t:show:N Remove a logo from x,y for w,h pixels, -vol Change the audio volume in multiples of 256 where 256
with fuzzy band thickness t = 100% (normal) volume. e.g. 512 = 200%
-vf removelogo=imgFile Use the black pixels in the bitmap -newaudio add a new audio stream to the current output stream
image file to remove the logo -alang code set the ISO 639 language code (3 letters) of the current
audio stream
By thetartankilt Published 25th April, 2017. Sponsored by CrosswordCheats.com
cheatography.com/thetartankilt/ Last updated 22nd March, 2018. Learn to solve cryptic crosswords!
Page 2 of 3. http://crosswordcheats.com
ffmpeg Cheat Sheet
by thetartankilt via cheatography.com/853/cs/344/
Useful examples Useful examples (cont)
Transcode input file ffmpeg -y -threads 8 -i inFile -target pal-dvd -ac 2 - Attach a picture to an ffmpeg -i input.mp3 -i cover.png -c copy -
to DVD PAL format aspect 16:9 -acodec mp2 -ab 224000 -vf mp3 metadata:s:v title="Album cover" -metadata:s:v
pad=0:0:0:0 outFile comment="Cover (Front)" out.mp3
Convert to grayscale ffmpeg -y -i inFile -flags gray outFile Mix a video with a ffmpeg -i song.wav -i source_video.avi
Create 1 minute of ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le sound file outvideo.mpg
audio noise -i /dev/urandom -ab 64K -f mp2 -acodec mp2 -y Write an mp3 with an ffmpeg -i inFile -id3v2_version 3 -write_id3v1 1
noise.mp2 ID3v2.3 header and outFile.mp3
Extract images from ffmpeg -i foo.avi -r 1 -s WxH -f image2 an ID3v1 footer
video outFile%03d.png Concatenate input cat inFile1 inFile2 | ffmpeg -f mpeg -i - -vcodec
Convert image file to ffmpeg -i foo0122.png foo.tiff files copy -acodec copy outFile.mpg
other formats pgm, ppm, pam, pgmyuv, jpeg, gif, png, tiff, sgi Encode a clip with ffmpeg -i clip.avi -vcodec libxvid -b 800000 -
codec with bitrate, acodec libmp3lame -ab 128 new-clip.avi
Convert images to ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH
and mp3 audio
AVI file foo.avi
Convert a WAV file ffmpeg -i source_song.wav -vn -ar 44100 -ac 2 -ab Merge audio stream ffmpeg -i audioS.mp4 -i videoS.mp4 -c copy -
with video stream map 0:a -map 1:v outFile.mp4
to MP3 192 -f mp3 final_song.mp3
from different files
Extract audio from a ffmpeg -i source.avi -vn -ar 44100 -ac 2 -ab 192 -f
video, transcoding it mp3 sound.mp3
to MP3
Convert .avi to .flv ffmpeg -i source.avi -ab 56 -ar 44100 -b 200 -r 15
-s 320x240 -f flv output.flv
Convert .avi to ffmpeg -i video.avi animated.gif
animated gif
By thetartankilt Published 25th April, 2017. Sponsored by CrosswordCheats.com
cheatography.com/thetartankilt/ Last updated 22nd March, 2018. Learn to solve cryptic crosswords!
Page 3 of 3. http://crosswordcheats.com