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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4Change frame rate
Retime to 30 fps, dropping or duplicating frames as needed.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
ffmpeg -i input.mp4 -vf reverse -af areverse output.mp4Remove the audio track
-an drops audio, the video stream is copied untouched.
Shell
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.
Shell
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.
Shell
ffmpeg -i input.mp4 -vn -acodec copy output.m4aVideo to MP3
Convert the soundtrack to a 192 kbps MP3.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
ffmpeg -i input.mkv -c copy output.mp4MOV / AVI to MP4
Re-encode legacy footage to a widely supported MP4.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
ffmpeg -i input.mp4 -vf fps=1 frame_%04d.pngContact sheet / storyboard
A 4×4 grid of evenly spaced frames.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
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.
Shell
# 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.
Shell
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.
Shell
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.
Shell
ffmpeg -i input.mkv -map 0:s:0 subs.srtInspect streams, codecs and duration
ffprobe prints everything about the file as JSON.
Shell
ffprobe -v error -show_format -show_streams -of json input.mp4Print only the duration in seconds
Handy inside shell scripts.
Shell
ffprobe -v error -show_entries format=duration -of csv=p=0 input.mp4Print resolution and frame rate
Compact output ready to parse.
Shell
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.
Shell
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
Shellffmpeg -i "stream.m3u8" -c copy -bsf:a aac_adtstoasc output.mp4Normalise podcast audio
Search "loudness"Output
Shellffmpeg -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.
.editorconfig Generator
Dev Utilities
Create an .editorconfig file with per-language overrides.
.htaccess Redirect Generator
Dev Utilities
Generate Apache .htaccess redirect and rewrite rules.
AAB (Android App Bundle) Analyzer
Dev Utilities
Open an .aab file and inspect its manifest, modules, ABIs, densities and size breakdown.
Android APK Analyzer & Explorer
Dev Utilities
Open an APK, decode its manifest and browse or download every file inside.
Frequently asked questions
Read more
- How to find and download an m3u8 (HLS) video link
Why streaming sites hide the real video URL, how to spot .m3u8, .mpd and .mp4 requests, and how to turn a playlist into a single MP4.
Comments
No login needed. Comments appear after a quick review.
Loading comments…
Version 1.0.0 · Updated 2026-08-14 · Runs entirely in your browser