\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{thetartankilt} \pdfinfo{ /Title (ffmpeg.pdf) /Creator (Cheatography) /Author (thetartankilt) /Subject (ffmpeg Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{666666} \definecolor{LightBackground}{HTML}{F5F5F5} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{ffmpeg Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{thetartankilt} via \textcolor{DarkBackground}{\uline{cheatography.com/853/cs/344/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}thetartankilt \\ \uline{cheatography.com/thetartankilt} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 25th April, 2017.\\ Updated 22nd March, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{3.6 cm} x{4.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Main options}} \tn % Row 0 \SetRowColor{LightBackground} Command syntax: & ffmpeg {[}global-options{]} {[}{[}infile-options{]}{[}-i infile{]}{]}... \{{[}outfile-options{]} outfile\}... \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Display input stream information: & ffmpeg -i video.avi \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{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.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Global options}} \tn % Row 0 \SetRowColor{LightBackground} -y & Overwrite output files \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -n & Do not overwrite output files \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Main options}} \tn % Row 0 \SetRowColor{LightBackground} -f~{\emph{fmt}} & force input or output file format \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} -i~{\emph{fName}} & input file name. If specified with no output file, a summary of the content streams is shown \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}-c {\emph{codecName}} & specify codec {[}input or output{]} \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} -fs {\emph{Nbytes}} & specify maximum output file size in Nbytes \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{The file extension typically determines the file format, so the '-f' option is not needed in most cases.\{\{nl\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{1.296 cm} p{1.08 cm} x{2.88 cm} x{1.944 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{8.4cm}}{\bf\textcolor{white}{Size specification}} \tn % Row 0 \SetRowColor{LightBackground} K or k & 10\textasciicircum{}3\textasciicircum{} & 1000 bytes & Kilobytes \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} M & 10\textasciicircum{}6\textasciicircum{} & 1000000 bytes & Megabytes \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} G & 10\textasciicircum{}9\textasciicircum{} & 1000000000 & Gigabytes \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{4}{x{8.4cm}}{} \tn % Row Count 3 (+ 0) % Row 4 \SetRowColor{LightBackground} Ki & 2\textasciicircum{}10\textasciicircum{} & 1024 & Kibibyte \tn % Row Count 4 (+ 1) % Row 5 \SetRowColor{white} Mi & 2\textasciicircum{}20\textasciicircum{} & 1048576 & Mebibyte \tn % Row Count 5 (+ 1) % Row 6 \SetRowColor{LightBackground} Gi & 2\textasciicircum{}30\textasciicircum{} & 1073741824 & Gibibyte \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{8.4cm}}{suffices used with most numerical values} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Help options}} \tn % Row 0 \SetRowColor{LightBackground} -h\{\{nl\}\}-?\{\{nl\}\}-help\{\{nl\}\}-{}-help & Show basic help \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} -h long & Show more help \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} -h full & Show all options, including all format and codec specific options \tn % Row Count 7 (+ 4) % Row 3 \SetRowColor{white} -version & Show version \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} -formats & Show available formats \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} -codecs & Show available codecs \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{nobreak\}\}-protocols & Show available protocols \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} -filters & Show available libavfilter filters \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} \{\{nobreak\}\}-sample\_fmts & Show available sample formats \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} -bsfs & Show available bitstream filters \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} -pix\_fmts & Show available pixel formats \tn % Row Count 22 (+ 2) % Row 11 \SetRowColor{white} \{\{nobreak\}\}-v {\emph{value}}\{\{nl\}\}-loglevel {\emph{value}} & Log output verbosity\{\{nl\}\}{\emph{value}} is an integer, or one of: quiet, panic, fatal, error, warning, info, verbose, debug \tn % Row Count 28 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Subtitle options}} \tn % Row 0 \SetRowColor{LightBackground} -slang {\emph{code}} & Set the ISO 639 language code (3 letters) of the current subtitle stream. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} -scodec {\emph{codec}} & Set the subtitle codec. This is an alias for {\emph{-codec:s}}. Use 'copy' to copy stream. \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} -sn & Disable subtitle recording. \tn % Row Count 9 (+ 2) % Row 3 \SetRowColor{white} \{\{nobreak\}\}-newsubtitle & add a new subtitle stream to the current output stream \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Video options}} \tn % Row 0 \SetRowColor{LightBackground} -b {\emph{bRate}} & set video bitrate (in kbit/s) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} -fixaspect & fix aspect ratio \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} -bt {\emph{tolerance}} & set video bitrate tolerance (in kbit/s) \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \{\{nobreak\}\}-maxrate {\emph{bRate}}\{\{nl\}\}-minrate {\emph{bRate}} & set maximum or minimum video bitrate tolerance (in kbit/s) \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} -bufsize size & set ratecontrol buffer size (in kByte) \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} -sameq & use same video quality as source (implies VBR) \tn % Row Count 13 (+ 3) % Row 6 \SetRowColor{LightBackground} -newvideo & add a new video stream to the current output stream \tn % Row Count 16 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Specialist Video filters}} \tn % Row 0 \SetRowColor{LightBackground} -vf vflip & Flip the input video vertically \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} -vf hflip & Flip the input video horizontally \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}-vf transpose={\emph{transSpec}} & Rotates or flips input video \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\emph{transSpec}} is a list of values, colon separated. & dir={\emph{N}}:passthrough={\emph{orientation}}\{\{nl\}\}N = 0...7 ; passthrough is one of: none, portrait, landscape \tn % Row Count 11 (+ 5) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}-vf delogo={\emph{sizeSpec}}:t={\emph{t}}:show:{\emph{N}} & Remove a logo from x,y for w,h pixels, with fuzzy band thickness {\emph{t}} \tn % Row Count 15 (+ 4) % Row 5 \SetRowColor{white} \{\{nobreak\}\}-vf removelogo=imgFile & Use the black pixels in the bitmap image file to remove the logo \tn % Row Count 19 (+ 4) % Row 6 \SetRowColor{LightBackground} -vf drawbox={\emph{sizeSpec}}:color@opacity & draw a box border\{\{nl\}\}colour specification 0x{\emph{hex}} and opacity {[}0...1{]} \tn % Row Count 23 (+ 4) % Row 7 \SetRowColor{white} {\emph{sizeSpec}} is a list of values, colon separated. & x={\emph{x}}:y={\emph{y}}\{\{nl\}\}position from top left corner\{\{nl\}\}w={\emph{width}}:h={\emph{height}}\{\{nl\}\}width and height \tn % Row Count 28 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Audio Options}} \tn % Row 0 \SetRowColor{LightBackground} -ab {\emph{bRate}} & set audio bitrate (in kbit/s) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} -aframes {\emph{N}} & Set the number of audio frames to record. {[}an alias for -frames:a{]} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} -aq q & Set the audio quality (codec-specific, VBR). {[}an alias for -q:a{]} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} -an & Disable audio recording \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}-acodec codec & Set the audio codec. {[}an alias for -codec:a{]}\{\{nl\}\}Use 'copy' to copy stream. \tn % Row Count 13 (+ 4) % Row 5 \SetRowColor{white} -vol & Change the audio volume in multiples of 256 where 256 = 100\% (normal) volume. e.g. 512 = 200\% \tn % Row Count 17 (+ 4) % Row 6 \SetRowColor{LightBackground} -newaudio & add a new audio stream to the current output stream \tn % Row Count 20 (+ 3) % Row 7 \SetRowColor{white} -alang code & set the ISO 639 language code (3 letters) of the current audio stream \tn % Row Count 23 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Useful examples}} \tn % Row 0 \SetRowColor{LightBackground} 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 \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} Convert to grayscale & ffmpeg -y -i inFile -flags gray outFile \tn % Row Count 8 (+ 2) % Row 2 \SetRowColor{LightBackground} Create 1 minute of audio noise & ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm\_s16le -i /dev/urandom -ab 64K -f mp2 -acodec mp2 -y noise.mp2 \tn % Row Count 14 (+ 6) % Row 3 \SetRowColor{white} Extract images from video & ffmpeg -i foo.avi -r 1 -s WxH -f image2 outFile\%03d.png \tn % Row Count 17 (+ 3) % Row 4 \SetRowColor{LightBackground} Convert image file to other formats & ffmpeg -i foo0122.png foo.tiff\{\{nl\}\}pgm, ppm, pam, pgmyuv, jpeg, gif, png, tiff, sgi \tn % Row Count 22 (+ 5) % Row 5 \SetRowColor{white} Convert images to AVI file & ffmpeg -f image2 -i foo-\%03d.jpeg -r 12 -s WxH foo.avi \tn % Row Count 25 (+ 3) % Row 6 \SetRowColor{LightBackground} Convert a WAV file to MP3 & ffmpeg -i source\_song.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 final\_song.mp3 \tn % Row Count 29 (+ 4) % Row 7 \SetRowColor{white} Extract audio from a video, transcoding it to MP3 & ffmpeg -i source.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3 \tn % Row Count 33 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Useful examples (cont)}} \tn % Row 8 \SetRowColor{LightBackground} Convert .avi to .flv & ffmpeg -i source.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output.flv \tn % Row Count 4 (+ 4) % Row 9 \SetRowColor{white} Convert .avi to animated gif & ffmpeg -i video.avi animated.gif \tn % Row Count 6 (+ 2) % Row 10 \SetRowColor{LightBackground} Attach a picture to an mp3 & ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3 \tn % Row Count 12 (+ 6) % Row 11 \SetRowColor{white} Mix a video with a sound file & ffmpeg -i song.wav -i source\_video.avi outvideo.mpg \tn % Row Count 15 (+ 3) % Row 12 \SetRowColor{LightBackground} Write an mp3 with an ID3v2.3 header and an ID3v1 footer & ffmpeg -i inFile -id3v2\_version 3 -write\_id3v1 1 outFile.mp3 \tn % Row Count 18 (+ 3) % Row 13 \SetRowColor{white} Concatenate input files & cat inFile1 inFile2 | ffmpeg -f mpeg -i - -vcodec copy -acodec copy outFile.mpg \tn % Row Count 22 (+ 4) % Row 14 \SetRowColor{LightBackground} Encode a clip with codec with bitrate, and mp3 audio & ffmpeg -i clip.avi -vcodec libxvid -b 800000 -acodec libmp3lame -ab 128 new-clip.avi \tn % Row Count 27 (+ 5) % Row 15 \SetRowColor{white} Merge audio stream with video stream from different files & ffmpeg -i audioS.mp4 -i videoS.mp4 -c copy -map 0:a -map 1:v outFile.mp4 \tn % Row Count 31 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}