Ahosting Logo
Knowledge Base

FFmpeg Commands Cheat Sheet for Beginners

This cheat sheet covers the most common FFmpeg commands you will use for video and audio processing.

Basic Syntax

ffmpeg -i input.mp4 [options] output.mp4

Video Conversion

# Convert to MP4 (H.264)
ffmpeg -i input.avi -c:v libx264 -c:a aac output.mp4

# Convert to WebM (VP9)
ffmpeg -i input.mp4 -c:v libvpx-vp9 -c:a libopus output.webm

# Convert to H.265/HEVC (smaller file size)
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -c:a aac output.mp4

Resize Video

# Resize to 1280x720
ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4

# Resize keeping aspect ratio (width 1280, auto height)
ffmpeg -i input.mp4 -vf scale=1280:-1 output.mp4

Extract Audio

# Extract to MP3
ffmpeg -i video.mp4 -vn -acodec mp3 audio.mp3

# Extract to AAC
ffmpeg -i video.mp4 -vn -c:a aac audio.m4a

Create Thumbnail

# Single frame at 10 seconds
ffmpeg -i video.mp4 -ss 00:00:10 -frames:v 1 thumb.jpg

# Thumbnail every 60 seconds
ffmpeg -i video.mp4 -vf "fps=1/60" thumb_%03d.jpg

Trim/Cut Video

# Cut from 00:01:00 to 00:02:30
ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:30 -c copy output.mp4

Compress Video

# Lower quality (higher CRF = smaller file)
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -c:a aac output.mp4

Get Video Info

ffprobe -v quiet -print_format json -show_format -show_streams video.mp4

CRF Values: 18 = visually lossless, 23 = default, 28 = smaller file, 51 = worst quality