ffmpeg Commands

ffmpeg commands cheatsheet.

Convert, extract, trim, resize, compress and screenshot media from the command line. Tap to copy.

Convert & basics
ffmpeg -i in.mov out.mp4Convert a file to another format
ffmpeg -i in.mp4 out.gifTurn a video into a GIF
ffmpeg -i in.wav out.mp3Convert audio to MP3
ffmpeg -i in.mp4 -vn out.mp3Extract the audio from a video
Trim & resize
ffmpeg -i in.mp4 -ss 00:00:10 -t 5 out.mp4Clip 5 seconds starting at 10s
ffmpeg -i in.mp4 -vf scale=1280:-1 out.mp4Resize video to 1280px wide, keep ratio
ffmpeg -i in.mp4 -an out.mp4Remove the audio track
ffmpeg -i in.mp4 -r 30 out.mp4Change the frame rate to 30fps
Compress & encode
ffmpeg -i in.mp4 -crf 23 out.mp4Re-encode with a quality/size tradeoff
ffmpeg -i in.mp4 -b:v 1M out.mp4Encode at a target video bitrate
ffmpeg -i in.mp4 -c copy out.mkvRewrap without re-encoding (fast)
Frames & info
ffmpeg -i in.mp4 -ss 5 -vframes 1 shot.pngGrab a single frame as an image
ffmpeg -i in.mp4 -vf fps=1 frame_%03d.pngExport one frame per second
ffprobe in.mp4Print media info about a file
Replace in/out filenames with your own. ffmpeg infers formats from the file extension you give it.

The Swiss-army knife for media

ffmpeg converts almost anything with ffmpeg -i input output — the extensions decide the formats. Add -ss and -t to trim, -vf scale to resize, -crf to control quality, and -c copy to rewrap without re-encoding (much faster). Use ffprobe to inspect a file.

FAQ

How do I extract audio from a video with ffmpeg?
Run ffmpeg -i input.mp4 -vn output.mp3 — the -vn flag drops the video and keeps only the audio.
How do I trim a clip without re-encoding?
Use ffmpeg -i input.mp4 -ss 00:00:10 -t 5 -c copy output.mp4 to copy 5 seconds from the 10-second mark quickly, without quality loss.

More cheatsheets