FFmpeg Cheatsheet
Searchable ffmpeg command examples for video, audio and streaming.
Pick a command
46 ffmpeg and ffprobe recipes — press Run on any of them
Showing 46 of 46 commands. Run loads the recipe into the console below, where you add your own file — nothing is uploaded.
Compress a video (H.264, quality based)
The default way to shrink a file. Lower CRF = better quality, bigger file.
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4CRF 18 is visually lossless, 23 is the default, 28 is small. Slower presets give smaller files at the same quality.
Compress with H.265 / HEVC (smaller files)
Roughly 30–50% smaller than H.264 at the same quality, but slower to encode.
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -preset medium -tag:v hvc1 -c:a aac -b:a 128k output.mp4-tag:v hvc1 keeps the file playable in QuickTime and on Apple devices.
Trim / cut without re-encoding
Instant cut between two timestamps, keeps the original quality.
ffmpeg -ss 00:00:30 -to 00:01:45 -i input.mp4 -c copy output.mp4Cuts land on the nearest keyframe. Drop -c copy to re-encode for frame-accurate cuts.
Frame-accurate trim (re-encode)
Use when the fast copy cut starts a second early or freezes.
ffmpeg -ss 00:00:30 -to 00:01:45 -i input.mp4 -c:v libx264 -crf 20 -c:a aac output.mp4Resize / scale to 1080p
Scale by height and let the width follow the aspect ratio.
ffmpeg -i input.mp4 -vf "scale=-2:1080" -c:v libx264 -crf 22 -c:a copy output.mp4-2 keeps the dimension even, which H.264 requires.
Crop a region
crop=width:height:x:y measured in pixels from the top-left.
ffmpeg -i input.mp4 -vf "crop=1280:720:100:50" -c:a copy output.mp4Rotate 90° or flip
transpose=1 rotates clockwise, 2 counter-clockwise, hflip mirrors.
ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4Change frame rate
Retime to 30 fps, dropping or duplicating frames as needed.
ffmpeg -i input.mp4 -vf "fps=30" -c:v libx264 -crf 22 -c:a copy output.mp4Speed up 2× (video and audio)
setpts halves the timestamps, atempo speeds the audio to match.
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -filter:a "atempo=2.0" output.mp4atempo accepts 0.5–2.0; chain it (atempo=2.0,atempo=2.0) for 4×.
Add an image watermark
Overlay a PNG 20px from the bottom-right corner.
ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=W-w-20:H-h-20" -c:a copy output.mp4Burn text onto a video
drawtext places a caption with a background box.
ffmpeg -i input.mp4 -vf "drawtext=text='Coders Hub':fontsize=48:fontcolor=white:box=1:boxcolor=black@0.5:x=(w-tw)/2:y=h-100" -c:a copy output.mp4Join several videos (same codec)
List the files then concatenate without re-encoding.
printf "file 'a.mp4'\nfile 'b.mp4'\n" > list.txt ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4All inputs must share codec, resolution and frame rate. Otherwise re-encode with the concat filter.
Reverse a clip
Plays video and audio backwards. Needs enough RAM for the clip.
ffmpeg -i input.mp4 -vf reverse -af areverse output.mp4Remove the audio track
-an drops audio, the video stream is copied untouched.
ffmpeg -i input.mp4 -c:v copy -an output.mp4Fade in and out
One-second fade from black at the start and to black at 00:59.
ffmpeg -i input.mp4 -vf "fade=t=in:st=0:d=1,fade=t=out:st=59:d=1" -c:a copy output.mp4Extract audio from a video
Copy the existing audio stream — no quality loss, no re-encode.
ffmpeg -i input.mp4 -vn -acodec copy output.m4aVideo to MP3
Convert the soundtrack to a 192 kbps MP3.
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k output.mp3Convert WAV to MP3 / AAC / Opus
Swap the codec and bitrate for the target format.
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3 ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a ffmpeg -i input.wav -c:a libopus -b:a 96k output.opusTrim an audio file
Cut 30 seconds starting at 1:00 without re-encoding.
ffmpeg -ss 00:01:00 -t 30 -i input.mp3 -c copy output.mp3Normalise loudness (EBU R128)
Bring speech or music to the −16 LUFS podcast target.
ffmpeg -i input.mp3 -af loudnorm=I=-16:TP=-1.5:LRA=11 -c:a libmp3lame -b:a 192k output.mp3Change the volume
1.5 is +50%, 0.5 is half. Use dB with volume=6dB.
ffmpeg -i input.mp4 -filter:a "volume=1.5" -c:v copy output.mp4Downmix to mono 16 kHz (speech / Whisper)
The format most speech-to-text models expect.
ffmpeg -i input.mp4 -vn -ac 1 -ar 16000 -c:a pcm_s16le output.wavReplace a video's audio track
Keep the video stream, take audio from a second file.
ffmpeg -i video.mp4 -i music.mp3 -map 0:v -map 1:a -c:v copy -shortest output.mp4Mix background music under a voice track
Lower the music, then merge both streams.
ffmpeg -i voice.wav -i music.mp3 -filter_complex "[1:a]volume=0.25[m];[0:a][m]amix=inputs=2:duration=first" output.mp3Strip leading and trailing silence
Useful before publishing recordings.
ffmpeg -i input.mp3 -af "silenceremove=start_periods=1:start_threshold=-50dB:start_silence=0.3,areverse,silenceremove=start_periods=1:start_threshold=-50dB:start_silence=0.3,areverse" output.mp3MKV to MP4 (remux, instant)
Change the container only when the codecs are already MP4-friendly.
ffmpeg -i input.mkv -c copy output.mp4MOV / AVI to MP4
Re-encode legacy footage to a widely supported MP4.
ffmpeg -i input.mov -c:v libx264 -crf 22 -preset medium -c:a aac -b:a 160k -movflags +faststart output.mp4MP4 to WebM (VP9 + Opus)
Open format for the web, good compression.
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -c:a libopus -b:a 96k output.webmMake an MP4 stream instantly
Moves the moov atom to the front so playback starts before the download finishes.
ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4Video to high-quality GIF (palette)
Two passes: build an optimal palette, then encode with it.
ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,palettegen" palette.png ffmpeg -i input.mp4 -i palette.png -lavfi "fps=15,scale=480:-1:flags=lanczos [x]; [x][1:v] paletteuse" output.gifGIF to MP4
Far smaller than a GIF and plays everywhere.
ffmpeg -i input.gif -movflags +faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" output.mp4Grab a single frame / thumbnail
One JPEG from the 5-second mark.
ffmpeg -ss 00:00:05 -i input.mp4 -frames:v 1 -q:v 2 thumb.jpgExport every frame (or one per second)
Numbered PNG sequence in the current folder.
ffmpeg -i input.mp4 -vf fps=1 frame_%04d.pngContact sheet / storyboard
A 4×4 grid of evenly spaced frames.
ffmpeg -i input.mp4 -vf "select=not(mod(n\,300)),scale=320:-1,tile=4x4" -frames:v 1 sheet.pngImage sequence to video
Turn numbered stills into a 30 fps clip.
ffmpeg -framerate 30 -i frame_%04d.png -c:v libx264 -pix_fmt yuv420p output.mp4Download an HLS (.m3u8) stream to MP4
Saves the whole playlist and remuxes it into an MP4.
ffmpeg -i "https://example.com/stream.m3u8" -c copy -bsf:a aac_adtstoasc output.mp4Add -headers "Referer: https://example.com\r\n" when the CDN checks the referer.
Package a video as HLS segments
10-second segments plus a playlist for web players.
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -c:a aac -hls_time 10 -hls_playlist_type vod -hls_segment_filename "seg_%03d.ts" playlist.m3u8Stream to YouTube / Twitch (RTMP)
Live push of a local file or capture device.
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k -c:a aac -b:a 128k -f flv rtmp://a.rtmp.youtube.com/live2/STREAM-KEYRecord the screen
Platform-specific capture inputs.
# Linux (X11) ffmpeg -f x11grab -framerate 30 -i :0.0 -c:v libx264 -preset ultrafast out.mp4 # macOS ffmpeg -f avfoundation -framerate 30 -i "1:0" -c:v libx264 -preset ultrafast out.mp4 # Windows ffmpeg -f gdigrab -framerate 30 -i desktop -c:v libx264 -preset ultrafast out.mp4Burn subtitles into the picture
Hard-coded captions that always show.
ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='FontSize=24'" -c:a copy output.mp4Add a soft subtitle track (toggleable)
Embeds the SRT as a stream the player can switch off.
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4Extract subtitles from an MKV
Pull the first subtitle stream out as SRT.
ffmpeg -i input.mkv -map 0:s:0 subs.srtInspect streams, codecs and duration
ffprobe prints everything about the file as JSON.
ffprobe -v error -show_format -show_streams -of json input.mp4Print only the duration in seconds
Handy inside shell scripts.
ffprobe -v error -show_entries format=duration -of csv=p=0 input.mp4Print resolution and frame rate
Compact output ready to parse.
ffprobe -v error -select_streams v:0 -show_entries stream=width,height,r_frame_rate -of csv=p=0 input.mp4Batch convert every file in a folder
Loop over MOV files and write MP4s next to them.
for f in *.mov; do ffmpeg -i "$f" -c:v libx264 -crf 22 -c:a aac "${f%.mov}.mp4"; done
Run the command
Add your video, audio or image, then run the selected recipe right here
Drop a file here
Video, audio or image — up to 512 MB, processed locally with ffmpeg.wasm
Input files this command needs
input.mp4→ add a file above
The first run downloads the ffmpeg WebAssembly core (~32 MB) and then caches it. Encoding in the browser is slower than a native install, so keep clips short for heavy re-encodes.
About the FFmpeg Cheatsheet
A searchable library of proven ffmpeg and ffprobe commands — compress, trim, resize, watermark, concatenate, extract audio, normalise loudness, make GIFs, download m3u8 streams, burn subtitles and inspect files. Copy any recipe with one click.
Examples
Download an HLS stream
Search "m3u8"Output
ffmpeg -i "stream.m3u8" -c copy -bsf:a aac_adtstoasc output.mp4Normalise podcast audio
Search "loudness"Output
ffmpeg -i input.mp3 -af loudnorm=I=-16:TP=-1.5:LRA=11 output.mp3Keyboard shortcuts
- Copy the main outputCtrl / ⌘ + Shift + C
- Download the resultCtrl / ⌘ + S
- Share this toolCtrl / ⌘ + Shift + S
- Reset the inputsAlt + R
- Open the tool search paletteCtrl / ⌘ + K
Related tools
FFmpeg Command Generator
Dev Utilities
Build ffmpeg commands for video and audio with explained flags.
FFmpeg Online — Run Commands in Your Browser
Dev Utilities
Run real ffmpeg commands on your video, audio or image — no install.
.htaccess Redirect Generator
Dev Utilities
Generate Apache .htaccess redirect and rewrite rules.
Bash Alias Generator
Dev Utilities
Create shell aliases for Bash, Zsh or Fish with correct quoting.
Chmod Calculator
Dev Utilities
Unix permission calculator: checkboxes, octal, and symbolic.
Code Comment Stripper
Dev Utilities
Remove comments from JS, HTML, Python, or SQL source.
Frequently asked questions
Version 1.0.0 · Updated 2026-08-14 · Runs entirely in your browser