Show Menu

ffmpeg Cheat Sheet by

ffmpeg is a very fast video and audio converter that can convert on the fly with a high quality polyphase filter. This cheat sheet will help to explain the many options and show useful examples
command     ffmpeg

Main options

Command syntax:
ffmpeg [globa­l-o­ptions] [[infi­le-­opt­ion­s][-i infile­]]... {[outf­ile­-op­tions] outfil­e}...
Display input stream inform­ation:
ffmpeg -i video.avi
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 audio, video, subtitle text, still images, fonts, etc.

Global options

-y
Overwrite output files
-n
Do not overwrite output files

Main options

-f fmt
force input or output file format
-i ­fName
input file name. If specified with no output file, a summary of the content streams is shown
-c codecName
specify codec [input or output]
-fs Nbytes
specify maximum output file size in Nbytes
The file extension typically determines the file format, so the '-f' option is not needed in most cases.

Size specif­ication

K or k
103
1000 bytes
Kilobytes
M
106
1000000 bytes
Megabytes
G
109
1000000000
Gigabytes
 
Ki
210
1024
Kibibyte
Mi
220
1048576
Mebibyte
Gi
230
1073741824
Gibibyte
suffices used with most numerical values

Help options

-h
-?
-help
--help
Show basic help
-h long
Show more help
-h full
Show all options, including all format and codec specific options
-version
Show version
-formats
Show available formats
-codecs
Show available codecs
-protocols
Show available protocols
-filters
Show available libavf­ilter filters
-sample_fmts
Show available sample formats
-bsfs
Show available bitstream filters
-pix_fmts
Show available pixel formats
-v value
-loglevel value
Log output verbosity
value is an integer, or one of: quiet, panic, fatal, error, warning, info, verbose, debug

Subtitle options

-slang code
Set the ISO 639 language code (3 letters) of the current subtitle stream.
-scodec codec
Set the subtitle codec. This is an alias for -code­c:s. Use 'copy' to copy stream.
-sn
Disable subtitle recording.
-newsubtitle
add a new subtitle stream to the current output stream
 

Video options

-b bRate
set video bitrate (in kbit/s)
-fixaspect
fix aspect ratio
-bt toler­ance
set video bitrate tolerance (in kbit/s)
-maxrate bRate
-minrate bRate
set maximum or minimum video bitrate tolerance (in kbit/s)
-bufsize size
set rateco­ntrol buffer size (in kByte)
-sameq
use same video quality as source (implies VBR)
-newvideo
add a new video stream to the current output stream

Specialist Video filters

-vf vflip
Flip the input video vertically
-vf hflip
Flip the input video horizo­ntally
-vf transpose=transSpec
Rotates or flips input video
trans­Spec is a list of values, colon separated.
dir=N:passthrough=orientation
N = 0...7 ; passth­rough is one of: none, portrait, landscape
-vf delogo=sizeSpec:t=t:show:N
Remove a logo from x,y for w,h pixels, with fuzzy band thickness t
-vf removelogo=imgFile
Use the black pixels in the bitmap image file to remove the logo
-vf drawbo­x=­siz­eSp­ec­:co­lor­@op­acity
draw a box border
colour specif­ication 0xhex and opacity [0...1]
sizeSpec is a list of values, colon separated.
x=x:y=y
position from top left corner
w=width:h=height
width and height

Audio Options

-ab bRate
set audio bitrate (in kbit/s)
-aframes N
Set the number of audio frames to record. [an alias for -frames:a]
-aq q
Set the audio quality (codec­-sp­ecific, VBR). [an alias for -q:a]
-an
Disable audio recording
-acodec codec
Set the audio codec. [an alias for -codec:a]
Use 'copy' to copy stream.
-vol
Change the audio volume in multiples of 256 where 256 = 100% (normal) volume. e.g. 512 = 200%
-newaudio
add a new audio stream to the current output stream
-alang code
set the ISO 639 language code (3 letters) of the current audio stream

Useful examples

Transcode input file to DVD PAL format
ffmpeg -y -threads 8 -i inFile -target pal-dvd -ac 2 -aspect 16:9 -acodec mp2 -ab 224000 -vf pad=0:­0:0:0 outFile
Convert to grayscale
ffmpeg -y -i inFile -flags gray outFile
Create 1 minute of audio noise
ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -i /dev/u­random -ab 64K -f mp2 -acodec mp2 -y noise.mp2
Extract images from video
ffmpeg -i foo.avi -r 1 -s WxH -f image2 outFil­e%0­3d.png
Convert image file to other formats
ffmpeg -i foo012­2.png foo.tiff
pgm, ppm, pam, pgmyuv, jpeg, gif, png, tiff, sgi
Convert images to AVI file
ffmpeg -f image2 -i foo-%0­3d.jpeg -r 12 -s WxH foo.avi
Convert a WAV file to MP3
ffmpeg -i source­_so­ng.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 final_­son­g.mp3
Extract audio from a video, transc­oding it to MP3
ffmpeg -i source.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.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 animated gif
ffmpeg -i video.avi animat­ed.gif
Attach a picture to an mp3
ffmpeg -i input.mp3 -i cover.png -c copy -metad­ata:s:v title=­"­Album cover" -metad­ata:s:v commen­t="Cover (Front­)" out.mp3
Mix a video with a sound file
ffmpeg -i song.wav -i source­_vi­deo.avi outvid­eo.mpg
Write an mp3 with an ID3v2.3 header and an ID3v1 footer
ffmpeg -i inFile -id3v2­_ve­rsion 3 -write­_id3v1 1 outFil­e.mp3
Concat­enate input files
cat inFile1 inFile2 | ffmpeg -f mpeg -i - -vcodec copy -acodec copy outFil­e.mpg
Encode a clip with codec with bitrate, and mp3 audio
ffmpeg -i clip.avi -vcodec libxvid -b 800000 -acodec libmp3lame -ab 128 new-cl­ip.avi
Merge audio stream with video stream from different files
ffmpeg -i audioS.mp4 -i videoS.mp4 -c copy -map 0:a -map 1:v outFil­e.mp4

Download the ffmpeg Cheat Sheet

3 Pages
//media.cheatography.com/storage/thumb/thetartankilt_ffmpeg.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          screen Cheat Sheet
          bash Shortcuts Cheat Sheet
          Android Activity Manager (am) Cheat Sheet