FFmpeg cheatsheet

FFmpeg: Images, GIFs and streams

7 common FFmpeg tasks.

Save a frame as an image

Grab one frame at 10 seconds.

ffmpeg -ss 00:00:10 -i input.mp4 -frames:v 1 thumbnail.jpg

Save a frame every second

Write one image per second of video.

ffmpeg -i input.mp4 -vf fps=1 frame_%04d.png

Make a video from images

Turn numbered images into a 30 fps video.

ffmpeg -framerate 30 -i frame_%04d.png -c:v libx264 -pix_fmt yuv420p output.mp4

Create a GIF

Make a GIF 480 pixels wide at 12 frames per second.

ffmpeg -i input.mp4 -vf "fps=12,scale=480:-1:flags=lanczos" output.gif

Create an HLS stream

Split a video into segments for streaming over HTTP.

ffmpeg -i input.mp4 -c:v libx264 -c:a aac -hls_time 6 -hls_playlist_type vod stream.m3u8

Record the screen on Linux

Capture an X11 screen at 30 frames per second.

ffmpeg -f x11grab -framerate 30 -i :0.0 -c:v libx264 -preset ultrafast screen.mp4

Use hardware encoding (NVIDIA)

Encode on an NVIDIA GPU for much faster results at some cost in compression.

ffmpeg -i input.mp4 -c:v h264_nvenc -preset p5 -cq 28 output.mp4

Was this page helpful?