Skip to content

ffmpeg cheatsheet

Published:

What is ffmpeg?

ffmpeg is undoubtedly one of the most powerful and versatile software for video and audio manipulation, available on any mainstream platform. The number of options it provides to its users is enormous, to the point of making it very complex to use for beginners.

Basic Commands

Format conversion

ffmpeg -i input.mp4 output.avi

Extracting audio from a video

ffmpeg -i video.mp4 -q:a 0 -map a audio.mp3

Resizing a video

ffmpeg -i input.mp4 -vf "scale=1280:720" output.mp4

Creating a GIF from a video

ffmpeg -i video.mp4 -vf "fps=10,scale=320:-1:flags=lanczos" -c:v gif output.gif

Creating a GIF from a series of images

# -i log/%4d.png: expands the template to files with 4 digits (e.g. log/0014.png)
# -start_number: Number to start from for the input file template
# -r: frame rate of the resulting GIF
# -filter_complex "scale=iw*.5:ih*.5": resizes the GIF
ffmpeg -start_number 0014 -r 33 -i log/%4d.png -filter_complex "scale=iw*.5:ih*.5" output.gif

Merging videos

ffmpeg -f concat -i file_list.txt -c copy output.mp4

Adding subtitles

ffmpeg -i video.mp4 -i subtitles.srt -c copy -c:s mov_text output.mp4

Extracting a frame

ffmpeg -i video.mp4 -ss 00:00:01.000 -vframes 1 output.png

File information

ffmpeg -i input.mp4