FFmpeg Command Generator and Cheat Sheet

FFmpeg is powerful, but the commands are hard to remember. This free FFmpeg command generator builds the exact command for you, and the cheat sheet below has 60+ ready-to-use FFmpeg examples with a short explanation for each. Everything runs in your browser, and nothing is uploaded.

What is FFmpeg?

FFmpeg is a free command-line tool for converting and editing audio and video. It can change formats, compress files, resize, trim, extract audio, make GIFs, add subtitles, and much more. The hard part is the syntax, which is easy to forget, so this page writes the commands for you.

How to use this FFmpeg command generator

Type your input file name, pick a task like convert or compress, adjust the options, then copy the command and run it in the terminal where your file lives. You need FFmpeg installed first, which you can get free from ffmpeg.org.

FFmpeg examples and cheat sheet

A practical list of common FFmpeg commands. Replace input.mp4 and output.mp4 with your own file names.

Convert between formats

ffmpeg -i input.mkv output.mp4 Convert MKV to MP4. FFmpeg picks codecs from the extension.
ffmpeg -i input.mp4 output.webm Convert to WebM for the web (VP9 and Opus).
ffmpeg -i input.mov output.mp4 Convert a QuickTime MOV to MP4.
ffmpeg -i input.mkv -c copy output.mp4 Change the container only, no re-encoding, so it is instant.
ffmpeg -i input.avi -c:v libx264 -c:a aac output.mp4 Convert an old AVI to modern H.264 and AAC.
ffmpeg -i input.webm output.gif Quick and simple video to GIF.

Compress and control quality

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium output.mp4 H.264 compression. Lower CRF means better quality, 18 to 28 is normal.
ffmpeg -i input.mp4 -c:v libx265 -crf 28 output.mp4 H.265, smaller files than H.264 at the same quality.
ffmpeg -i input.mp4 -b:v 1M output.mp4 Target a video bitrate of 1 Mbps.
ffmpeg -i input.mp4 -vf scale=-2:720 -crf 26 output.mp4 Shrink to 720p and compress in one go.
ffmpeg -i input.mp3 -b:a 128k output.mp3 Re-encode audio at a 128k bitrate.
ffmpeg -i input.mp4 -c:v libx264 -movflags +faststart output.mp4 Optimise MP4 for streaming so it plays before fully downloaded.

Resize and scale

ffmpeg -i input.mp4 -vf scale=-2:720 output.mp4 Scale to 720p tall, keeping the aspect ratio.
ffmpeg -i input.mp4 -vf scale=1920:-2 output.mp4 Scale to 1920px wide, keeping the aspect ratio.
ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4 Force an exact 1280×720 size.
ffmpeg -i input.mp4 -vf "scale=iw/2:ih/2" output.mp4 Make the video half its current size.

Trim and cut

ffmpeg -ss 00:00:10 -i input.mp4 -t 00:00:30 -c copy output.mp4 Cut 30 seconds starting at 10s, no re-encoding (instant).
ffmpeg -ss 00:00:10 -to 00:00:40 -i input.mp4 -c copy output.mp4 Cut between two timestamps.
ffmpeg -ss 00:00:10 -i input.mp4 -t 00:00:30 output.mp4 Same cut but re-encoded, for a frame-accurate result.
ffmpeg -i input.mp4 -c copy -f segment -segment_time 600 out%03d.mp4 Split into 10-minute parts.

Audio

ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3 Extract the audio as a high-quality MP3.
ffmpeg -i input.mp4 -vn -c:a aac -b:a 192k output.m4a Extract the audio as AAC.
ffmpeg -i input.mp4 -c copy -an output.mp4 Remove the audio track, keep the video untouched.
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -map 0:v:0 -map 1:a:0 -shortest output.mp4 Replace the video’s audio with a new track.
ffmpeg -i input.mp4 -filter:a "volume=1.5" output.mp4 Make the audio 1.5 times louder.
ffmpeg -i input.mp4 -af loudnorm output.mp4 Normalise loudness to a standard level.
ffmpeg -i input.wav -ar 44100 output.wav Change the audio sample rate to 44.1 kHz.
ffmpeg -i input.mp3 -af "afade=t=in:d=3" output.mp3 Fade the audio in over 3 seconds.

GIFs and images

ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos" output.gif Turn a video into a GIF at 15 fps, 480px wide.
ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,palettegen" palette.png Step 1 for a high-quality GIF: build a colour palette.
ffmpeg -i input.mp4 -i palette.png -filter_complex "fps=15,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif Step 2: use the palette for a sharper GIF.
ffmpeg -ss 00:00:05 -i input.mp4 -frames:v 1 -q:v 2 thumb.jpg Grab a single thumbnail at 5 seconds.
ffmpeg -i input.mp4 -vf fps=1 frame_%04d.png Save one frame every second as PNG images.
ffmpeg -framerate 24 -i img%04d.png -c:v libx264 -pix_fmt yuv420p output.mp4 Build a video from a sequence of images.

Rotate, flip, and crop

ffmpeg -i input.mp4 -vf "transpose=1" output.mp4 Rotate 90 degrees clockwise.
ffmpeg -i input.mp4 -vf "transpose=2" output.mp4 Rotate 90 degrees counter-clockwise.
ffmpeg -i input.mp4 -vf "transpose=1,transpose=1" output.mp4 Rotate 180 degrees.
ffmpeg -i input.mp4 -vf "hflip" output.mp4 Mirror the video horizontally.
ffmpeg -i input.mp4 -vf "vflip" output.mp4 Flip the video vertically.
ffmpeg -i input.mp4 -vf "crop=1280:720:0:0" output.mp4 Crop a 1280×720 region from the top-left.
ffmpeg -i input.mp4 -vf "crop=in_w/2:in_h/2" output.mp4 Crop the centre quarter of the frame.

Speed and frame rate

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4 Play at 2x speed, video and audio together.
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]" -map "[v]" -map "[a]" output.mp4 Play at half speed.
ffmpeg -i input.mp4 -vf fps=30 output.mp4 Change the frame rate to 30 fps.
ffmpeg -i input.mp4 -vf reverse -af areverse output.mp4 Reverse the video and audio (best for short clips).

Merge, subtitles, and overlays

ffmpeg -i a.mp4 -i b.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4 Join two clips that may differ slightly.
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4 Fast join of files with identical codecs, listed in list.txt.
ffmpeg -i input.mp4 -vf "subtitles=subs.srt" output.mp4 Burn subtitles permanently into the video.
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s mov_text output.mp4 Add soft subtitles you can turn on or off.
ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=10:10" output.mp4 Add a watermark image in the top-left corner.
ffmpeg -i input.mp4 -vf "drawtext=text='Hello':x=10:y=10:fontsize=24:fontcolor=white" output.mp4 Overlay text on the video.

Handy extras

ffprobe input.mp4 Show details about a file (codecs, duration, resolution).
ffmpeg -stream_loop 3 -i input.mp4 -c copy output.mp4 Loop the video 3 extra times.
ffmpeg -i input.mp4 -frames:v 1 poster.jpg Save the first frame as a poster image.
ffmpeg -i input.mp4 -vf "scale=iw:ih,setsar=1" output.mp4 Fix a stretched video by resetting the pixel aspect ratio.
ffmpeg -i input.mp4 -pix_fmt yuv420p output.mp4 Fix a video that will not play in some players or browsers.

Do I need FFmpeg installed?

Yes. This tool writes the command, it does not process your files. Install FFmpeg from ffmpeg.org, then run the generated command in the folder where your file is.

Frequently asked questions

What is the FFmpeg command to convert a video to MP4?

Run ffmpeg -i input.mkv output.mp4. FFmpeg picks the codecs from the .mp4 extension. Use the Convert task above to change the input or output format.

How do I compress a video with FFmpeg?

Use H.264 with a CRF value, for example ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4. A higher CRF means a smaller file with lower quality, and 18 to 28 is the usual range.

How do I convert a video to a GIF with FFmpeg?

Run ffmpeg -i input.mp4 -vf “fps=15,scale=480:-1:flags=lanczos” output.gif. Lower the fps or the width for a smaller GIF, or use the palette method for sharper colours.

How do I extract audio from a video with FFmpeg?

Run ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3. The -vn flag drops the video and keeps only the audio.

How do I trim or cut a video with FFmpeg?

Run ffmpeg -ss 00:00:10 -i input.mp4 -t 00:00:30 -c copy output.mp4 to take 30 seconds from the 10 second mark without re-encoding.

How do I resize a video with FFmpeg?

Run ffmpeg -i input.mp4 -vf scale=-2:720 output.mp4 to scale to 720p while keeping the aspect ratio. The -2 keeps the width even, which H.264 needs.

How do I merge two videos with FFmpeg?

If the files share the same codecs, list them in a text file and run ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4. Otherwise use the concat filter shown in the cheat sheet.

Does this tool upload my files?

No. It only builds the command text in your browser, so your files never leave your computer. You run the command yourself.

Is FFmpeg free?

Yes, FFmpeg is free and open source, and this command generator is free too.